Skip to content

MQE-1427 - Support _CREDS in <magentoCLI> action and in Data #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
66fb4c2
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 11, 2019
55e6421
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 11, 2019
5fc6347
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 13, 2019
052e15d
Merge branch 'develop' into MQE-1427
ivy00johns Jun 13, 2019
d9060d7
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 14, 2019
98480cf
Merge remote-tracking branch 'origin/MQE-1427' into MQE-1427
ivy00johns Jun 14, 2019
6dcd2f4
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 14, 2019
7b8de7e
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 14, 2019
acf87b6
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 14, 2019
ecb5a8a
Merge branch 'develop' into MQE-1427
ivy00johns Jun 14, 2019
b0e821f
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 14, 2019
bffe7d6
Merge remote-tracking branch 'origin/MQE-1427' into MQE-1427
ivy00johns Jun 14, 2019
847e5ff
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 14, 2019
eeb174a
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 17, 2019
352b660
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 17, 2019
0eaaa01
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 17, 2019
f83c893
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 17, 2019
2d5e178
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 18, 2019
7c837c3
Merge branch 'develop' into MQE-1427
ivy00johns Jun 18, 2019
7a1a4e5
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 18, 2019
e4ddde9
Merge remote-tracking branch 'origin/MQE-1427' into MQE-1427
ivy00johns Jun 18, 2019
ad99e96
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 18, 2019
0cd5a47
Merge branch 'develop' into MQE-1427
ivy00johns Jun 18, 2019
d1b3be3
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 18, 2019
6cf6400
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 18, 2019
1e22a8c
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 19, 2019
fd66a0c
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 19, 2019
537b404
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 19, 2019
82a80c6
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
c38ab37
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
a07275f
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
9510135
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
29b37f4
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
9f96927
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
3d2d857
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 20, 2019
8cd1a39
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 21, 2019
9ef7ea7
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 21, 2019
637c3eb
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 21, 2019
32fac0c
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 21, 2019
cd0d237
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 21, 2019
d103842
MQE-1427: Support _CREDS in <magentoCLI> action and in Data
ivy00johns Jun 24, 2019
c5286e6
Merge branch 'develop' into MQE-1427
KevinBKozan Jun 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
}

/**
* Function used to fill sensitive crednetials with user data, data is decrypted immediately prior to fill to avoid
* Function used to fill sensitive credentials with user data, data is decrypted immediately prior to fill to avoid
* exposure in console or log.
*
* @param string $field
Expand All @@ -636,6 +636,23 @@ public function fillSecretField($field, $value)
$this->fillField($field, $decryptedValue);
}

/**
* Function used to create data that contains sensitive credentials in a <createData> <field> override.
* The data is decrypted immediately prior to data creation to avoid exposure in console or log.
*
* @param string $command
* @throws TestFrameworkException
* @return void
*/
public function magentoCliSecret($command)
{
// to protect any secrets from being printed to console the values are executed only at the webdriver level as a
// decrypted value

$decryptedCommand = CredentialStore::getInstance()->decryptSecretValue($command);
$this->magentoCLI($decryptedCommand);
}

/**
* Override for _failed method in Codeception method. Adds png and html attachments to allure report
* following parent execution of test failure processing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function resolveActionSteps($parsedSteps, $skipActionGroupResolution = fa

/**
* Takes an array of actions and resolves any references to secret fields. The function then validates whether the
* refernece is valid and replaces the function name accordingly to hide arguments at runtime.
* reference is valid and replaces the function name accordingly to hide arguments at runtime.
*
* @param ActionObject[] $resolvedActions
* @return ActionObject[]
Expand All @@ -106,22 +106,28 @@ private function resolveSecretFieldAccess($resolvedActions)
$actions = [];
foreach ($resolvedActions as $resolvedAction) {
$action = $resolvedAction;
$hasSecretRef = $this->actionAttributeContainsSecretRef($resolvedAction->getCustomActionAttributes());

if ($resolvedAction->getType() !== 'fillField' && $hasSecretRef) {
throw new TestReferenceException("You cannot reference secret data outside of fill field actions");
$actionHasSecretRef = $this->actionAttributeContainsSecretRef($resolvedAction->getCustomActionAttributes());
$approvedActions = ['fillField', 'magentoCLI', 'field'];
$secretMapping = ['fillField' => 'fillSecretField'];
$actionType = $resolvedAction->getType();

if ($actionHasSecretRef && !(in_array($actionType, $approvedActions))) {
throw new TestReferenceException("You cannot reference secret data outside " .
"of the fillField, magentoCli and createData actions");
}

if ($resolvedAction->getType() === 'fillField' && $hasSecretRef) {
$action = new ActionObject(
$action->getStepKey(),
'fillSecretField',
$action->getCustomActionAttributes(),
$action->getLinkedAction(),
$action->getActionOrigin()
);
if (isset($secretMapping[$actionType])) {
$actionType = $secretMapping[$actionType];
}

$action = new ActionObject(
$action->getStepKey(),
$actionType,
$action->getCustomActionAttributes(),
$action->getLinkedAction(),
$action->getActionOrigin()
);

$actions[$action->getStepKey()] = $action;
}

Expand Down Expand Up @@ -151,6 +157,29 @@ private function actionAttributeContainsSecretRef($actionAttributes)
return false;
}

/**
* Returns a boolean based on whether or not the createData field contains a reference to a secret field.
*
* @param array $dataFields
* @return boolean
*/
private function dataFieldContainsSecretRef($dataFields)
{
foreach ($dataFields as $dataField) {
if (is_array($dataField)) {
return $this->dataFieldContainsSecretRef($dataField);
}

preg_match_all("/{{_CREDS\.([\w]+)}}/", $dataField, $matches);

if (!empty($matches[0])) {
return true;
}
}

return false;
}

/**
* Method to resolve action group references and insert relevant actions into step flow
*
Expand Down Expand Up @@ -261,7 +290,7 @@ private function insertReadinessSkips()
*
* @param array $parsedSteps
* @return void
* @throws XmlException
* @throws TestReferenceException
*/
private function sortActions($parsedSteps)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,11 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
$actionObject->getActionOrigin()
)[0];
$argRef = "\t\t\$";
$argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n";

$input = $this->resolveAllRuntimeReferences([$input])[0];
$argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) .
"Fields['{$fieldKey}'] = ${input};\n";

$testSteps .= $argRef;
break;
case "generateDate":
Expand Down