Skip to content

Commit c365c6e

Browse files
committed
ACQE-3401 Remove environment variable MAGENTO_ADMIN_PASSWORD
1 parent a628e57 commit c365c6e

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

etc/config/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ MAGENTO_BASE_URL=http://devdocs.magento.com/
1010
#*** Set the Admin Username and Password for your Magento instance ***#
1111
MAGENTO_BACKEND_NAME=admin
1212
MAGENTO_ADMIN_USERNAME=admin
13-
MAGENTO_ADMIN_PASSWORD=123123q
1413

1514
#*** Path to CLI entry point and command parameter name. Uncomment and change if folder structure differs from standard Magento installation
1615
#MAGENTO_CLI_COMMAND_PATH=dev/tests/acceptance/utils/command.php

src/Magento/FunctionalTestingFramework/DataTransport/AdminFormExecutor.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\FunctionalTestingFramework\DataTransport;
88

9+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
910
use Magento\FunctionalTestingFramework\Util\MftfGlobals;
1011
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
1112
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlTransport;
@@ -73,9 +74,11 @@ private function authorize()
7374

7475
// Authenticate admin user
7576
$authUrl = MftfGlobals::getBackendBaseUrl() . 'admin/auth/login/';
77+
$encryptedSecret = CredentialStore::getInstance()->getSecret('magento/MAGENTO_ADMIN_PASSWORD');
78+
$secret = CredentialStore::getInstance()->decryptSecretValue($encryptedSecret);
7679
$data = [
7780
'login[username]' => getenv('MAGENTO_ADMIN_USERNAME'),
78-
'login[password]' => getenv('MAGENTO_ADMIN_PASSWORD'),
81+
'login[password]' => $secret,
7982
'form_key' => $this->formKey,
8083
];
8184
$this->transport->write($authUrl, $data, CurlInterface::POST);

src/Magento/FunctionalTestingFramework/DataTransport/Auth/WebApiAuth.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\FunctionalTestingFramework\DataTransport\Auth;
88

9+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
910
use Magento\FunctionalTestingFramework\Exceptions\FastFailException;
1011
use Magento\FunctionalTestingFramework\Util\MftfGlobals;
1112
use Magento\FunctionalTestingFramework\DataTransport\Protocol\CurlInterface;
@@ -57,14 +58,16 @@ class WebApiAuth
5758
public static function getAdminToken($username = null, $password = null)
5859
{
5960
$login = $username ?? getenv('MAGENTO_ADMIN_USERNAME');
60-
$password = $password ?? getenv('MAGENTO_ADMIN_PASSWORD');
61+
$encryptedSecret = CredentialStore::getInstance()->getSecret('magento/MAGENTO_ADMIN_PASSWORD');
62+
$secret = CredentialStore::getInstance()->decryptSecretValue($encryptedSecret);
63+
$password = $password ?? $secret;
6164
if (!$login || !$password) {
6265
$message = 'Cannot retrieve API token without credentials. Please fill out .env.';
6366
$context = [
6467
'MAGENTO_BASE_URL' => getenv('MAGENTO_BASE_URL'),
6568
'MAGENTO_BACKEND_BASE_URL' => getenv('MAGENTO_BACKEND_BASE_URL'),
6669
'MAGENTO_ADMIN_USERNAME' => getenv('MAGENTO_ADMIN_USERNAME'),
67-
'MAGENTO_ADMIN_PASSWORD' => getenv('MAGENTO_ADMIN_PASSWORD'),
70+
'MAGENTO_ADMIN_PASSWORD' => $secret,
6871
];
6972
throw new FastFailException($message, $context);
7073
}

src/Magento/FunctionalTestingFramework/Util/ModuleResolver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\FunctionalTestingFramework\Util;
88

99
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
10+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
1011
use Magento\FunctionalTestingFramework\Exceptions\FastFailException;
1112
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
1213
use Magento\FunctionalTestingFramework\Util\ModuleResolver\ModuleResolverService;
@@ -198,10 +199,12 @@ public function getEnabledModules()
198199

199200
if (!$response) {
200201
$message = "Could not retrieve Modules from Magento Instance.";
202+
$encryptedSecret = CredentialStore::getInstance()->getSecret('magento/MAGENTO_ADMIN_PASSWORD');
203+
$secret = CredentialStore::getInstance()->decryptSecretValue($encryptedSecret);
201204
$context = [
202205
"Admin Module List Url" => $url,
203206
"MAGENTO_ADMIN_USERNAME" => getenv("MAGENTO_ADMIN_USERNAME"),
204-
"MAGENTO_ADMIN_PASSWORD" => getenv("MAGENTO_ADMIN_PASSWORD"),
207+
"MAGENTO_ADMIN_PASSWORD" => $secret,
205208
];
206209
throw new FastFailException($message, $context);
207210
}

0 commit comments

Comments
 (0)