Skip to content

Commit 661b556

Browse files
committed
Add support for GCP and Azure KMS providers
1 parent 530b87d commit 661b556

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/SpecTests/Context.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ public static function fromClientSideEncryption(stdClass $test, $databaseName, $
118118
if (isset($autoEncryptionOptions['kmsProviders']->aws)) {
119119
$autoEncryptionOptions['kmsProviders']->aws = self::getAWSCredentials();
120120
}
121+
122+
if (isset($autoEncryptionOptions['kmsProviders']->azure)) {
123+
$autoEncryptionOptions['kmsProviders']->azure = self::getAzureCredentials();
124+
}
125+
126+
if (isset($autoEncryptionOptions['kmsProviders']->gcp)) {
127+
$autoEncryptionOptions['kmsProviders']->gcp = self::getGCPCredentials();
128+
}
121129
}
122130

123131
if (isset($test->outcome->collection->name)) {
@@ -260,6 +268,41 @@ public static function getAWSCredentials()
260268
];
261269
}
262270

271+
/**
272+
* @return array
273+
*
274+
* @throws SkippedTestError
275+
*/
276+
public static function getAzureCredentials()
277+
{
278+
if (! getenv('AZURE_TENANT_ID') || ! getenv('AZURE_CLIENT_ID') || ! getenv('AZURE_CLIENT_SECRET')) {
279+
throw new SkippedTestError('Please configure Azure credentials to use Azure KMS provider.');
280+
}
281+
282+
return [
283+
'tenantId' => getenv('AZURE_TENANT_ID'),
284+
'clientId' => getenv('AZURE_CLIENT_ID'),
285+
'clientSecret' => getenv('AZURE_CLIENT_SECRET'),
286+
];
287+
}
288+
289+
/**
290+
* @return array
291+
*
292+
* @throws SkippedTestError
293+
*/
294+
public static function getGCPCredentials()
295+
{
296+
if (! getenv('GCP_EMAIL') || ! getenv('GCP_PRIVATE_KEY')) {
297+
throw new SkippedTestError('Please configure GCP credentials to use GCP KMS provider.');
298+
}
299+
300+
return [
301+
'email' => getenv('GCP_EMAIL'),
302+
'privateKey' => getenv('GCP_PRIVATE_KEY'),
303+
];
304+
}
305+
263306
/**
264307
* @return Client
265308
*/

0 commit comments

Comments
 (0)