Skip to content

Commit 5fc6347

Browse files
committed
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
- Correcting the magentoCLI action when secret data is present. - Adding support for createData when secret data is present.
1 parent 55e6421 commit 5fc6347

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Codeception\Exception\ModuleException;
1515
use Codeception\Util\Uri;
1616
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
17-
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
1817
use Magento\FunctionalTestingFramework\DataGenerator\Persist\Curl\WebapiExecutor;
1918
use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport;
2019
use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface;
@@ -638,20 +637,16 @@ public function fillSecretField($field, $value)
638637
}
639638

640639
/**
641-
* @param string $key
642-
* @param string $scope
643-
* @param string $entity
644-
* @param array $requiredEntity
645-
* @param object $overrideFields
646-
* @throws \Exception
640+
* @param string $command
641+
* @throws TestFrameworkException
647642
*/
648-
public function createSecretData($key, $scope, $entity, $requiredEntity, $overrideFields)
643+
public function magentoCliSecret($command)
649644
{
650645
// to protect any secrets from being printed to console the values are executed only at the webdriver level as a
651646
// decrypted value
652647

653-
$decryptedValue = CredentialStore::getInstance()->decryptSecretValue($overrideFields);
654-
PersistedObjectHandler::getInstance()->createEntity($key, $scope, $entity, $requiredEntity, $decryptedValue);
648+
$decryptedCommand = CredentialStore::getInstance()->decryptSecretValue($command);
649+
$this->magentoCLI($decryptedCommand);
655650
}
656651

657652
/**

src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,7 @@ private function resolveSecretFieldAccess($resolvedActions)
128128
if ($actionType === 'magentoCLI' && $actionHasSecretRef) {
129129
$action = new ActionObject(
130130
$action->getStepKey(),
131-
'magentoCliSecretData',
132-
$action->getCustomActionAttributes(),
133-
$action->getLinkedAction(),
134-
$action->getActionOrigin()
135-
);
136-
}
137-
138-
if ($actionType === 'createData' && $dataHasSecretRef) {
139-
$action = new ActionObject(
140-
$action->getStepKey(),
141-
'createData',
131+
'magentoCLI',
142132
$action->getCustomActionAttributes(),
143133
$action->getLinkedAction(),
144134
$action->getActionOrigin()

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,16 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
12671267
$actionObject->getActionOrigin()
12681268
)[0];
12691269
$argRef = "\t\t\$";
1270-
$argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n";
1270+
1271+
preg_match_all("/{{_CREDS\.([\w]+)}}/", "${input}", $matches);
1272+
1273+
if (!empty($matches[0])) {
1274+
$secretFieldValue = $matches[1][0];
1275+
$argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = CredentialStore::getInstance()->decryptSecretValue(CredentialStore::getInstance()->getSecret(\"{$secretFieldValue}\"));\n";
1276+
} else {
1277+
$argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n";
1278+
}
1279+
12711280
$testSteps .= $argRef;
12721281
break;
12731282
case "generateDate":

0 commit comments

Comments
 (0)