Skip to content

Commit b552483

Browse files
authored
Merge pull request #554 from magento/MQE-1919
MFTF AWS Secrets Manager - CI Use
2 parents a84ee26 + df5f4f6 commit b552483

File tree

14 files changed

+825
-66
lines changed

14 files changed

+825
-66
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"require": {
1212
"php": "7.0.2||7.0.4||~7.0.6||~7.1.0||~7.2.0||~7.3.0",
1313
"ext-curl": "*",
14+
"ext-json": "*",
15+
"ext-openssl": "*",
1416
"allure-framework/allure-codeception": "~1.3.0",
17+
"aws/aws-sdk-php": "^3.132",
1518
"codeception/codeception": "~2.4.5",
1619
"composer/composer": "^1.4",
1720
"consolidation/robo": "^1.0.0",

composer.lock

Lines changed: 146 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\SecretStorage;
8+
9+
use Aws\SecretsManager\SecretsManagerClient;
10+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretsManagerStorage;
11+
use Aws\Result;
12+
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
13+
use ReflectionClass;
14+
15+
class AwsSecretsManagerStorageTest extends MagentoTestCase
16+
{
17+
/**
18+
* Test encryption/decryption functionality in AwsSecretsManagerStorage class.
19+
*/
20+
public function testEncryptAndDecrypt()
21+
{
22+
// Setup test data
23+
$testProfile = 'profile';
24+
$testRegion = 'region';
25+
$testLongKey = 'magento/myKey';
26+
$testShortKey = 'myKey';
27+
$testValue = 'myValue';
28+
$data = [
29+
'Name' => 'mftf/magento/' . $testShortKey,
30+
'SecretString' => json_encode([$testShortKey => $testValue])
31+
];
32+
/** @var Result */
33+
$result = new Result($data);
34+
35+
$mockClient = $this->getMockBuilder(SecretsManagerClient::class)
36+
->disableOriginalConstructor()
37+
->setMethods(['__call'])
38+
->getMock();
39+
40+
$mockClient->expects($this->once())
41+
->method('__call')
42+
->willReturnCallback(function ($name, $args) use ($result) {
43+
return $result;
44+
});
45+
46+
/** @var SecretsManagerClient */
47+
$credentialStorage = new AwsSecretsManagerStorage($testRegion, $testProfile);
48+
$reflection = new ReflectionClass($credentialStorage);
49+
$reflection_property = $reflection->getProperty('client');
50+
$reflection_property->setAccessible(true);
51+
$reflection_property->setValue($credentialStorage, $mockClient);
52+
53+
// Test getEncryptedValue()
54+
$encryptedCred = $credentialStorage->getEncryptedValue($testLongKey);
55+
56+
// Assert the value we've gotten is in fact not identical to our test value
57+
$this->assertNotEquals($testValue, $encryptedCred);
58+
59+
// Test getDecryptedValue()
60+
$actualValue = $credentialStorage->getDecryptedValue($encryptedCred);
61+
62+
// Assert that we are able to successfully decrypt our secret value
63+
$this->assertEquals($testValue, $actualValue);
64+
}
65+
}

docs/configuration.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,28 @@ Example:
277277
CREDENTIAL_VAULT_SECRET_BASE_PATH=secret
278278
```
279279

280+
### CREDENTIAL_AWS_SECRETS_MANAGER_REGION
281+
282+
The region that AWS Secrets Manager is located.
283+
284+
Example:
285+
286+
```conf
287+
# Region of AWS Secrets Manager
288+
CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1
289+
```
290+
291+
### CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE
292+
293+
The profile used to connect to AWS Secrets Manager.
294+
295+
Example:
296+
297+
```conf
298+
# Profile used to connect to AWS Secrets Manager.
299+
CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default
300+
```
301+
280302
### ENABLE_BROWSER_LOG
281303

282304
Enables addition of browser logs to Allure steps

0 commit comments

Comments
 (0)