Skip to content

Commit 4a353df

Browse files
authored
Merge pull request #444 from magento-commerce/MFTF_5.0.3_RC
MFTF_5.0.3_RC: MFTF 5.0.3 Release Check List
2 parents 78e8a83 + 2e46f03 commit 4a353df

File tree

7 files changed

+60
-7
lines changed

7 files changed

+60
-7
lines changed

CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Magento Functional Testing Framework Changelog
44
5.0.3
55
---------
66
### Fixes
7+
* Allowed additional actions to read from credentials file to fix page builder failures.
78
* Added support for chrome 131
89

910
5.0.2
@@ -68,16 +69,16 @@ Magento Functional Testing Framework Changelog
6869
4.7.2
6970
---------
7071
### Enhancements
71-
* Fail static test when introduced filename does not equal the MFTF object name
72+
* Fail static test when introduced filename does not equal the MFTF object name
7273
contained within.
7374

7475
4.7.1
7576
---------
7677
### Enhancements
7778
* Bumped all symfony dependencies to `^6.0
78-
* Removed abandoned package codacy/coverage
79+
* Removed abandoned package codacy/coverage
7980
* Removed abandoned package sebastian/phpcpd
80-
* Bumped monolog/monolog to ^3.0
81+
* Bumped monolog/monolog to ^3.0
8182
* Bumped nikic/php-parser to ^5.0
8283

8384
4.7.0

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

+28-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public function testInvalidSecretFunctions(): void
284284
{
285285
$this->expectException(TestReferenceException::class);
286286
$this->expectExceptionMessage(
287-
'You cannot reference secret data outside of the fillField, magentoCLI and createData actions'
287+
'You cannot reference secret data outside of the fillField, magentoCLI, seeInField and createData actions'
288288
);
289289

290290
$actionObjectOne = new ActionObject(
@@ -307,4 +307,31 @@ public static function tearDownAfterClass(): void
307307
{
308308
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
309309
}
310+
311+
/**
312+
* Verify that a <seeInField> action is replaced by <seeInSecretField> when secret _CREDS are referenced.
313+
*
314+
* @return void
315+
* @throws TestReferenceException
316+
* @throws XmlException
317+
*/
318+
public function testValidSeeInSecretFieldFunction(): void
319+
{
320+
$actionObjectOne = new ActionObject(
321+
'actionKey1',
322+
'seeInField',
323+
['userInput' => '{{_CREDS.username}}', 'requiredCredentials' => 'username']
324+
);
325+
$actionObject = [$actionObjectOne];
326+
327+
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
328+
$result = $actionMergeUtil->resolveActionSteps($actionObject);
329+
330+
$expectedValue = new ActionObject(
331+
'actionKey1',
332+
'seeInSecretField',
333+
['userInput' => '{{_CREDS.username}}','requiredCredentials' => 'username']
334+
);
335+
$this->assertEquals($expectedValue, $result['actionKey1']);
336+
}
310337
}

dev/tests/verification/Resources/BasicFunctionalTest.txt

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class BasicFunctionalTestCest
170170
$I->seeElementInDOM(".functionalTestSelector"); // stepKey: seeElementInDOMKey1
171171
$I->seeInCurrentUrl("/functionalUrl"); // stepKey: seeInCurrentUrlKey1
172172
$I->seeInField(".functionalTestSelector", "someInput"); // stepKey: seeInFieldKey1
173+
$I->seeInSecretField(".functionalTestSelector", $I->getSecret("someKey")); // stepKey: seeInFieldKey2
173174
$I->seeInPageSource("Home Page"); // stepKey: seeInPageSourceKey1
174175
$I->seeInPageSource("<h1 class=\"page-title\">"); // stepKey: seeInPageSourceKey2
175176
$I->seeInPopup("someInput"); // stepKey: seeInPopupKey1

dev/tests/verification/TestModule/Test/BasicFunctionalTest/BasicFunctionalTest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<seeElementInDOM selector=".functionalTestSelector" stepKey="seeElementInDOMKey1"/>
109109
<seeInCurrentUrl url="/functionalUrl" stepKey="seeInCurrentUrlKey1"/>
110110
<seeInField selector=".functionalTestSelector" userInput="someInput" stepKey="seeInFieldKey1" />
111+
<seeInField selector=".functionalTestSelector" userInput="{{_CREDS.someKey}}" stepKey="seeInFieldKey2" />
111112
<seeInPageSource html="Home Page" stepKey="seeInPageSourceKey1"/>
112113
<seeInPageSource html="&#60;h1 class&#61;&#34;page-title&#34;&#62;" stepKey="seeInPageSourceKey2"/>
113114
<seeInPopup userInput="someInput" stepKey="seeInPopupKey1"/>

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

+21
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,27 @@ public function magentoCLISecret($command, $timeout = null, $arguments = null)
864864
return $this->magentoCLI($decryptedCommand, $timeout, $arguments);
865865
}
866866

867+
/**
868+
* Function used to verify sensitive credentials in the data, data is decrypted immediately prior to see to avoid
869+
* exposure in console or log.
870+
*
871+
* @param string $field
872+
* @param string $value
873+
* @return void
874+
* @throws TestFrameworkException
875+
*/
876+
public function seeInSecretField(string $field, string $value):void
877+
{
878+
// to protect any secrets from being printed to console the values are executed only at the webdriver level as a
879+
// decrypted value
880+
881+
$decryptedValue = CredentialStore::getInstance()->decryptSecretValue($value);
882+
if ($decryptedValue === false) {
883+
throw new TestFrameworkException("\nFailed to decrypt value {$value} for field {$field}\n");
884+
}
885+
$this->seeInField($field, $decryptedValue);
886+
}
887+
867888
/**
868889
* Override for _failed method in Codeception method. Adds png and html attachments to allure report
869890
* following parent execution of test failure processing.

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class ActionMergeUtil
2626
const DEFAULT_SKIP_ON_ORDER = 'before';
2727
const DEFAULT_SKIP_OFF_ORDER = 'after';
2828
const DEFAULT_WAIT_ORDER = 'after';
29-
const APPROVED_ACTIONS = ['fillField', 'magentoCLI', 'field'];
30-
const SECRET_MAPPING = ['fillField' => 'fillSecretField', 'magentoCLI' => 'magentoCLISecret'];
29+
const APPROVED_ACTIONS = ['fillField', 'magentoCLI', 'field', 'seeInField'];
30+
const SECRET_MAPPING = ['fillField' => 'fillSecretField', 'magentoCLI' => 'magentoCLISecret',
31+
'seeInField' => 'seeInSecretField'];
3132
const CREDS_REGEX = "/{{_CREDS\.([\w|\/]+)}}/";
3233

3334
/**
@@ -110,7 +111,7 @@ private function resolveSecretFieldAccess($resolvedActions)
110111

111112
if ($actionHasSecretRef && !(in_array($actionType, self::APPROVED_ACTIONS))) {
112113
throw new TestReferenceException("You cannot reference secret data outside " .
113-
"of the fillField, magentoCLI and createData actions");
114+
"of the fillField, magentoCLI, seeInField and createData actions");
114115
}
115116

116117
// Do NOT remap actions that don't need it.

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+1
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
14131413
case "loadSessionSnapshot":
14141414
case "seeInField":
14151415
case "seeOptionIsSelected":
1416+
case "seeInSecretField":
14161417
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input);
14171418
break;
14181419
case "seeInPageSource":

0 commit comments

Comments
 (0)