Skip to content

Commit 09f81b6

Browse files
ivy00johnsKevinBKozan
authored andcommitted
MQE-1427 - Support _CREDS in <magentoCLI> action and in Data (#368)
- added support for _creds in magentoCLI and Data
1 parent 4d55d3f commit 09f81b6

34 files changed

+322
-65
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ActionMergeUtilTest.php

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use AspectMock\Test as AspectMock;
99
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
1010
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
11+
use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException;
12+
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
1113
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1214
use Magento\FunctionalTestingFramework\Test\Util\ActionMergeUtil;
1315
use Magento\FunctionalTestingFramework\Test\Util\ActionObjectExtractor;
@@ -100,7 +102,7 @@ public function testResolveActionStepEntityData()
100102
$dataFieldName = 'myfield';
101103
$dataFieldValue = 'myValue';
102104
$userInputKey = "userInput";
103-
$userinputValue = "{{" . "${dataObjectName}.${dataFieldName}}}";
105+
$userInputValue = "{{" . "${dataObjectName}.${dataFieldName}}}";
104106
$actionName = "myAction";
105107
$actionType = "myCustomType";
106108

@@ -113,10 +115,10 @@ public function testResolveActionStepEntityData()
113115
AspectMock::double(DataObjectHandler::class, ['getInstance' => $mockDOHInstance]);
114116

115117
// Create test object and action object
116-
$actionAttributes = [$userInputKey => $userinputValue];
118+
$actionAttributes = [$userInputKey => $userInputValue];
117119
$actions[$actionName] = new ActionObject($actionName, $actionType, $actionAttributes);
118120

119-
$this->assertEquals($userinputValue, $actions[$actionName]->getCustomActionAttributes()[$userInputKey]);
121+
$this->assertEquals($userInputValue, $actions[$actionName]->getCustomActionAttributes()[$userInputKey]);
120122

121123
$mergeUtil = new ActionMergeUtil("test", "TestCase");
122124
$resolvedActions = $mergeUtil->resolveActionSteps($actions);
@@ -127,8 +129,14 @@ public function testResolveActionStepEntityData()
127129
/**
128130
* Verify that an XmlException is thrown when an action references a non-existant action.
129131
*
132+
* @throws TestReferenceException
133+
* @throws XmlException
130134
* @return void
131135
*/
136+
/**
137+
* @throws TestReferenceException
138+
* @throws XmlException
139+
*/
132140
public function testNoActionException()
133141
{
134142
$actionObjects = [];
@@ -151,6 +159,8 @@ public function testNoActionException()
151159
/**
152160
* Verify that a <waitForPageLoad> action is added after actions that have a wait (timeout property).
153161
*
162+
* @throws TestReferenceException
163+
* @throws XmlException
154164
* @return void
155165
*/
156166
public function testInsertWait()
@@ -173,6 +183,111 @@ public function testInsertWait()
173183
$this->assertEquals($expected, $actual);
174184
}
175185

186+
/**
187+
* Verify that a <fillField> action is replaced by <fillSecretField> when secret _CREDS are referenced.
188+
*
189+
* @throws TestReferenceException
190+
* @throws XmlException
191+
*/
192+
public function testValidFillFieldSecretFunction()
193+
{
194+
$actionObjectOne = new ActionObject(
195+
'actionKey1',
196+
'fillField',
197+
['userInput' => '{{_CREDS.username}}']
198+
);
199+
$actionObject = [$actionObjectOne];
200+
201+
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
202+
203+
$result = $actionMergeUtil->resolveActionSteps($actionObject);
204+
205+
$expectedValue = new ActionObject(
206+
'actionKey1',
207+
'fillSecretField',
208+
['userInput' => '{{_CREDS.username}}']
209+
);
210+
$this->assertEquals($expectedValue, $result['actionKey1']);
211+
}
212+
213+
/**
214+
* Verify that a <magentoCLI> action uses <magentoCLI> when secret _CREDS are referenced.
215+
*
216+
* @throws TestReferenceException
217+
* @throws XmlException
218+
*/
219+
public function testValidMagentoCLISecretFunction()
220+
{
221+
$actionObjectOne = new ActionObject(
222+
'actionKey1',
223+
'magentoCLI',
224+
['command' => 'config:set cms/wysiwyg/enabled {{_CREDS.payment_authorizenet_login}}']
225+
);
226+
$actionObject = [$actionObjectOne];
227+
228+
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
229+
230+
$result = $actionMergeUtil->resolveActionSteps($actionObject);
231+
232+
$expectedValue = new ActionObject(
233+
'actionKey1',
234+
'magentoCLISecret',
235+
['command' => 'config:set cms/wysiwyg/enabled {{_CREDS.payment_authorizenet_login}}']
236+
);
237+
$this->assertEquals($expectedValue, $result['actionKey1']);
238+
}
239+
240+
/**
241+
* Verify that a <field> override in a <createData> action uses <field> when secret _CREDS are referenced.
242+
*
243+
* @throws TestReferenceException
244+
* @throws XmlException
245+
*/
246+
public function testValidCreateDataSecretFunction()
247+
{
248+
$actionObjectOne = new ActionObject(
249+
'actionKey1',
250+
'field',
251+
['value' => '{{_CREDS.payment_authorizenet_login}}']
252+
);
253+
$actionObject = [$actionObjectOne];
254+
255+
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
256+
257+
$result = $actionMergeUtil->resolveActionSteps($actionObject);
258+
259+
$expectedValue = new ActionObject(
260+
'actionKey1',
261+
'field',
262+
['value' => '{{_CREDS.payment_authorizenet_login}}']
263+
);
264+
$this->assertEquals($expectedValue, $result['actionKey1']);
265+
}
266+
267+
/**
268+
* Verify that a <click> action throws an exception when secret _CREDS are referenced.
269+
*
270+
* @throws TestReferenceException
271+
* @throws XmlException
272+
*/
273+
public function testInvalidSecretFunctions()
274+
{
275+
$this->expectException(TestReferenceException::class);
276+
$this->expectExceptionMessage(
277+
'You cannot reference secret data outside of the fillField, magentoCLI and createData actions'
278+
);
279+
280+
$actionObjectOne = new ActionObject(
281+
'actionKey1',
282+
'click',
283+
['userInput' => '{{_CREDS.username}}']
284+
);
285+
$actionObject = [$actionObjectOne];
286+
287+
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
288+
$actionMergeUtil->resolveActionSteps($actionObject);
289+
}
290+
176291
/**
177292
* After class functionality
178293
* @return void

dev/tests/verification/Resources/ActionGroupUsingCreateData.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActionGroupUsingCreateDataCest
3131
"hook",
3232
"ApiCategory",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("[createConfigProductKey1] create 'ApiConfigurableProduct' entity");
@@ -40,7 +40,7 @@ class ActionGroupUsingCreateDataCest
4040
"hook",
4141
"ApiConfigurableProduct",
4242
["createCategoryKey1"],
43-
null
43+
[]
4444
);
4545

4646
$I->comment("Exiting Action Group [Key1] actionGroupWithCreateData");

dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActionGroupWithDataOverrideTestCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

dev/tests/verification/Resources/ActionGroupWithDataTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActionGroupWithDataTestCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActionGroupWithNoDefaultTestCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

dev/tests/verification/Resources/ActionGroupWithPersistedData.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActionGroupWithPersistedDataCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");
@@ -78,7 +78,7 @@ class ActionGroupWithPersistedDataCest
7878
"test",
7979
"DefaultPerson",
8080
[],
81-
null
81+
[]
8282
);
8383

8484
$I->comment("Entering Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData");

dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ActionGroupWithStepKeyReferencesCest
3434
"test",
3535
"simpleData",
3636
[],
37-
null
37+
[]
3838
);
3939

4040
$grabTextDataActionGroup = $I->grabTextFrom(".class"); // stepKey: grabTextDataActionGroup
@@ -46,7 +46,6 @@ class ActionGroupWithStepKeyReferencesCest
4646
$action3ActionGroup = $I->executeJS($action3ActionGroup); // stepKey: action3ActionGroup
4747
$action4ActionGroup = $I->magentoCLI($action4ActionGroup, "\"stuffHere\""); // stepKey: action4ActionGroup
4848
$I->comment($action4ActionGroup);
49-
5049
$date = new \DateTime();
5150
$date->setTimestamp(strtotime("{$action5}"));
5251
$date->setTimezone(new \DateTimeZone("America/Los_Angeles"));
@@ -82,7 +81,7 @@ class ActionGroupWithStepKeyReferencesCest
8281
"test",
8382
"{$action10}",
8483
[],
85-
null
84+
[]
8685
);
8786

8887
$action11ActionGroup = $I->grabAttributeFrom($action11ActionGroup, "someInput"); // stepKey: action11ActionGroup

dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActionGroupWithTopLevelPersistedDataCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ArgumentWithSameNameAsElementCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

dev/tests/verification/Resources/AssertTest.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AssertTestCest
3030
"hook",
3131
"ReplacementPerson",
3232
[],
33-
null
33+
[]
3434
);
3535

3636
}
@@ -50,7 +50,7 @@ class AssertTestCest
5050
"test",
5151
"UniquePerson",
5252
[],
53-
null
53+
[]
5454
);
5555

5656
$grabTextFrom1 = $I->grabTextFrom(".copyright>span"); // stepKey: grabTextFrom1

dev/tests/verification/Resources/BasicActionGroupTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BasicActionGroupTestCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

dev/tests/verification/Resources/BasicFunctionalTest.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class BasicFunctionalTestCest
121121
$grabValueFromKey1 = $I->grabValueFrom(".functionalTestSelector"); // stepKey: grabValueFromKey1
122122
$magentoCli1 = $I->magentoCLI("maintenance:enable", "\"stuffHere\""); // stepKey: magentoCli1
123123
$I->comment($magentoCli1);
124-
125124
$I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1
126125
$I->maximizeWindow(); // stepKey: maximizeWindowKey1
127126
$I->moveBack(); // stepKey: moveBackKey1

dev/tests/verification/Resources/DataActionsTest.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DataActionsTestCest
3030
"hook",
3131
"entity",
3232
[],
33-
null
33+
[]
3434
);
3535

3636
$I->comment("[updateInBefore] update 'createdInBefore' entity to 'entity'");
@@ -64,7 +64,7 @@ class DataActionsTestCest
6464
"test",
6565
"entity",
6666
[],
67-
null
67+
[]
6868
);
6969

7070
$I->comment("[updateInTest] update 'createdInTest' entity to 'entity'");

dev/tests/verification/Resources/DataReplacementTest.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@ class DataReplacementTestCest
5353
$I->fillField(".selector", "0"); // stepKey: insertZero
5454
$insertCommand = $I->magentoCLI("do something Doe" . msq("uniqueData") . " with uniqueness"); // stepKey: insertCommand
5555
$I->comment($insertCommand);
56-
5756
}
5857
}

dev/tests/verification/Resources/ExtendParentDataTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ExtendParentDataTestCest
3333
"test",
3434
"extendParentData",
3535
[],
36-
null
36+
[]
3737
);
3838

3939
$I->searchAndMultiSelectOption("#selector", ["otherName"]); // stepKey: getName

dev/tests/verification/Resources/ExtendedParameterArrayTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ExtendParentDataTestCest
3333
"test",
3434
"extendParentData",
3535
[],
36-
null
36+
[]
3737
);
3838
$I->searchAndMultiSelectOption("#selector", ["otherName"]);
3939
$I->searchAndMultiSelectOption("#selector", ["extendName"]);

dev/tests/verification/Resources/HookActionsTest.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class HookActionsTestCest
3030
"hook",
3131
"sampleCreatedEntity",
3232
[],
33-
null
33+
[]
3434
);
3535

3636
$I->comment("[sampleDeleteBefore] delete entity 'sampleCreateBefore'");
@@ -45,7 +45,7 @@ class HookActionsTestCest
4545
"hook",
4646
"sampleCreatedEntity",
4747
[],
48-
null
48+
[]
4949
);
5050

5151
}
@@ -62,7 +62,7 @@ class HookActionsTestCest
6262
"hook",
6363
"sampleCreatedEntity",
6464
[],
65-
null
65+
[]
6666
);
6767

6868
$I->comment("[sampleDeleteAfter] delete entity 'sampleCreateForAfter'");

dev/tests/verification/Resources/LocatorFunctionTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LocatorFunctionTestCest
3333
"test",
3434
"ReplacementPerson",
3535
[],
36-
null
36+
[]
3737
);
3838

3939
$I->click(Locator::contains("'label'", "'Name'")); // stepKey: SimpleLocator

dev/tests/verification/Resources/MergedActionGroupTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MergedActionGroupTestCest
3131
"hook",
3232
"ReplacementPerson",
3333
[],
34-
null
34+
[]
3535
);
3636

3737
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");

0 commit comments

Comments
 (0)