Skip to content

Commit

Permalink
Merge pull request magento#7800 from magento-gl/2.4.5-develop-sync
Browse files Browse the repository at this point in the history
2.4.5 develop sync
  • Loading branch information
sidolov committed Aug 10, 2022
2 parents 2854866 + 09a1d8f commit f9adcd9
Show file tree
Hide file tree
Showing 113 changed files with 1,795 additions and 828 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/AdminAdobeIms/Service/ImsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ImsConfig extends Config
public const XML_PATH_PROFILE_URL = 'adobe_ims/integration/profile_url';
public const XML_PATH_NEW_ADMIN_EMAIL_TEMPLATE = 'adobe_ims/email/content_template';
public const XML_PATH_VALIDATE_TOKEN_URL = 'adobe_ims/integration/validate_token_url';
public const XML_PATH_LOGOUT_URL = 'adobe_ims/integration/logout_url';
public const XML_PATH_ADMIN_LOGOUT_URL = 'adobe_ims/integration/admin_logout_url';
public const XML_PATH_CERTIFICATE_PATH = 'adobe_ims/integration/certificate_path';
public const XML_PATH_ADMIN_AUTH_URL_PATTERN = 'adobe_ims/integration/admin/auth_url_pattern';
public const XML_PATH_ADMIN_REAUTH_URL_PATTERN = 'adobe_ims/integration/admin/reauth_url_pattern';
Expand Down Expand Up @@ -353,7 +353,7 @@ public function getBackendLogoutUrl(string $accessToken) : string
return str_replace(
['#{access_token}', '#{client_secret}', '#{client_id}'],
[$accessToken, $this->getPrivateKey(), $this->getApiKey()],
$this->scopeConfig->getValue(self::XML_PATH_LOGOUT_URL)
$this->scopeConfig->getValue(self::XML_PATH_ADMIN_LOGOUT_URL)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<click selector="{{AdminAdobeImsSignInSection.AdobeImsUsernameContinueButton}}" stepKey="clickUsernameContinue"/>

<click selector="{{AdminAdobeImsSignInSection.AdobeImsProfileSelect}}" stepKey="clickProfile"/>

<wait time="10" stepKey="waitTenSeconds"/>
<fillField selector="{{AdminAdobeImsSignInSection.password}}" userInput="{{password}}" stepKey="fillPassword"/>
<click selector="{{AdminAdobeImsSignInSection.AdobeImsPasswordContinueButton}}" stepKey="clickPasswordContinue"/>
<waitForPageLoad stepKey="waitForLoginToFinish"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,38 @@
<arguments>
<argument name="role"/>
<argument name="user" defaultValue="newAdmin"/>
<argument name="password" type="string" defaultValue="{{_ENV.ADOBE_IMS_PASSWORD}}"/>
</arguments>

<amOnPage url="{{AdminNewUserPage.url}}" stepKey="navigateToNewUser"/>
<waitForPageLoad stepKey="waitForUsersPage"/>
<fillField selector="{{AdminCreateUserSection.usernameTextField}}" userInput="{{user.username}}" stepKey="enterUserName"/>
<fillField selector="{{AdminCreateUserSection.firstNameTextField}}" userInput="{{user.firstName}}" stepKey="enterFirstName"/>
<fillField selector="{{AdminCreateUserSection.lastNameTextField}}" userInput="{{user.lastName}}" stepKey="enterLastName"/>
<fillField selector="{{AdminCreateUserSection.emailTextField}}" userInput="{{user.username}}@magento.com" stepKey="enterEmail"/>
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
<click stepKey="clickUserRole" selector="{{AdminCreateUserSection.userRoleTab}}"/>
<click stepKey="chooseRole" selector="{{AdminStoreSection.createdRoleInUserPage(role.name)}}"/>
<!--Open New Admin User Page. -->
<amOnPage url="{{AdminNewUserPage.url}}" stepKey="navigateToNewAdminUser"/>
<waitForPageLoad stepKey="waitForNewAdminUserPage"/>

<!-- Fill admin user data. -->
<fillField selector="{{AdminCreateUserSection.usernameTextField}}" userInput="{{user.username}}" stepKey="enterAdminUserName"/>
<fillField selector="{{AdminCreateUserSection.firstNameTextField}}" userInput="{{user.firstName}}" stepKey="enterAdminFirstName"/>
<fillField selector="{{AdminCreateUserSection.lastNameTextField}}" userInput="{{user.lastName}}" stepKey="enterAdminLastName"/>
<fillField selector="{{AdminCreateUserSection.emailTextField}}" userInput="{{user.username}}@magento.com" stepKey="enterAdminEmail"/>

<!-- Verify Current Admin User Identity via Adobe IMS. -->
<click selector="{{AdminCreateUserSection.confirmIdentity}}" stepKey="clickConfirmIdentity"/>

<!-- Switch to Admin IMS Window. -->
<switchToNextTab stepKey="switchToNextTab"/>
<waitForElementVisible selector="{{AdminAdobeImsSignInSection.password}}" stepKey="waitForAdobeImsForm"/>
<fillField selector="{{AdminCreateUserSection.password}}" userInput="{{password}}" stepKey="fillPassword"/>
<click selector="{{AdminAdobeImsSignInSection.AdobeImsPasswordContinueButton}}" stepKey="clickPasswordContinue"/>
<waitForElementNotVisible selector="{{AdminAdobeImsSignInSection.password}}" time="30" stepKey="waitForAdobeImsFormToDisappear"/>

<!-- Switch to Adobe Commerce Window. -->
<switchToPreviousTab userInput="1" stepKey="switchPreviousTab"/>

<!-- Select Admin User Role. -->
<click selector="{{AdminCreateUserSection.userRoleTab}}" stepKey="clickUserRole"/>
<click selector="{{AdminStoreSection.createdRoleInUserPage(role.name)}}" stepKey="chooseRole"/>

<!-- Save admin user. -->
<click selector="{{AdminCreateUserSection.saveButton}}" stepKey="clickSaveUser"/>
<waitForPageLoad stepKey="waitForSaveTheUser"/>
<see userInput="You saved the user." stepKey="seeSuccessMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
</annotations>

<magentoCLI command="admin:adobe-ims:disable" stepKey="disableAdminAdobeImsModule"/>
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches1"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
</annotations>

<magentoCLI command="admin:adobe-ims:enable -o {{ClientCredentialsData.org_id}} -c {{ClientCredentialsData.client_id}} -s {{ClientCredentialsData.client_key}} -t yes" stepKey="enableAdminAdobeImsModule" />
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches1"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<section name="AdminAdobeImsSignInSection">
<element name="username" type="input" selector="#EmailPage-EmailField"/>
<element name="password" type="input" selector="#PasswordPage-PasswordField"/>
<element name="AdminAdobeImsSignInButton" type="button" selector=".adobe-ims-button button" timeout="30"/>
<element name="AdobeImsUsernameContinueButton" type="button" selector="//button[@data-id='EmailPage-ContinueButton']" timeout="30"/>
<element name="AdminAdobeImsSignInButton" type="button" selector=".adobe-ims-button button" timeout="15"/>
<element name="AdobeImsUsernameContinueButton" type="button" selector="//button[@data-id='EmailPage-ContinueButton']" timeout="15"/>
<element name="AdobeImsPasswordContinueButton" type="button" selector="//button[@data-id='PasswordPage-ContinueButton']"/>
<element name="AdobeImsProfileSelect" type="text" selector="//div[contains(text(),'Personal Account')]" timeout="30"/>
<element name="AdobeImsProfileSelect" type="text" selector="//div[contains(text(),'Personal Account')]" timeout="15"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminCreateUserSection">
<element name="confirmIdentity" type="button" selector="#user_ims_verification"/>
<element name="password" type="input" selector="#PasswordPage-PasswordField"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="CreateNewUserWithoutPasswordTest">
<test name="AdminCreateNewAdminUserWithAdobeImsTest">
<annotations>
<features value="Backend"/>
<stories value="Create a new admin user without password"/>
<title value="Create a new admin user without password"/>
<description value="Create a new admin user without password when AdminAdobeImsModule is enabled"/>
<stories value="Create a new admin user with enabled Adobe IMS integration"/>
<title value="Create a new admin user with enabled Adobe IMS integration"/>
<description value="Create a new admin user when AdminAdobeImsModule is enabled"/>
<severity value="CRITICAL"/>
<group value="admin_ims"/>
<testCaseId value="CABPI-227"/>
<skip>
<issueId value="AC-3153">Skipped</issueId>
</skip>
<testCaseId value="CABPI-227"/>
</annotations>
<before>
<actionGroup ref="AdminEnableAdobeImsActionGroup" stepKey="enableAdminAdobeImsModule" />
Expand All @@ -33,5 +33,7 @@
<argument name="user" value="activeAdmin"/>
<argument name="role" value="roleDefaultAdministrator"/>
</actionGroup>

<see userInput="You saved the user." stepKey="seeSuccessMessage"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
</annotations>
<before>
<actionGroup ref="AdminEnableAdobeImsActionGroup" stepKey="enableIms" />
<amOnPage url="{{AdminAdobeImsCallbackPage.url}}" stepKey="openCallbackUrl"/>
</before>
<after>
<actionGroup ref="AdminDisableAdobeImsActionGroup" stepKey="disableAdminAdobeImsModule" />
</after>

<!-- Open admin login page using callback URL with no code -->
<amOnPage url="{{AdminAdobeImsCallbackPage.url}}" stepKey="openCallbackUrl"/>
<waitForPageLoad stepKey="waitForAdminLoginPageLoad"/>

<!-- Check for Sign in with error message -->
<!-- Check for the error message on login page -->
<actionGroup ref="AssertAdminSignInEmptyCodeErrorMessageTestActionGroup"
stepKey="assertAdminLoginShowsErrorMessage"/>
</test>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdminAdobeIms/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<token_url>https://ims-na1.adobelogin.com/ims/token</token_url>
<profile_url><![CDATA[https://ims-na1.adobelogin.com/ims/profile/v1?client_id=#{client_id}]]></profile_url>
<organization_membership_url><![CDATA[https://graph.identity.adobe.com/#{org_id}@AdobeOrg/membership]]></organization_membership_url>
<logout_url><![CDATA[https://ims-na1.adobelogin.com/ims/logout/v1?access_token=#{access_token}&amp;client_id=#{client_id}&amp;client_secret=#{client_secret}]]></logout_url>
<admin_logout_url><![CDATA[https://ims-na1.adobelogin.com/ims/logout/v1?access_token=#{access_token}&client_id=#{client_id}&client_secret=#{client_secret}]]></admin_logout_url>
<certificate_path><![CDATA[https://static.adobelogin.com/keys/prod/]]></certificate_path>
<validate_token_url><![CDATA[https://ims-na1.adobelogin.com/ims/validate_token/v1?token=#{token}&client_id=#{client_id}&type=#{token_type}]]></validate_token_url>
</integration>
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/AdobeIms/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ private function getLocale(): string
*/
public function getLogoutUrl(string $accessToken, string $redirectUrl = '') : string
{
// there is no success response with empty redirect url
if ($redirectUrl === '') {
$redirectUrl = 'self';
}
return str_replace(
['#{access_token}', '#{redirect_uri}'],
[$accessToken, $redirectUrl],
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/AdobeIms/Model/GetAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public function execute(int $adminUserId = null): ?string
{
try {
$adminUserId = $adminUserId ?? (int) $this->userContext->getUserId();
return $this->userProfileRepository->getByUserId($adminUserId)->getAccessToken();
return $this->encryptor->decrypt(
$this->userProfileRepository->getByUserId($adminUserId)->getAccessToken()
);
} catch (NoSuchEntityException $exception) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public function testExecute(?string $token): void
->willReturn($userProfileMock);
$userProfileMock->expects($this->once())->method('getAccessToken')->willReturn($token);

$decryptedToken = $token ?? '';

$this->encryptor->expects($this->once())
->method('decrypt')
->with($token)
->willReturn($decryptedToken);

$this->assertEquals($token, $this->getAccessToken->execute());
}

Expand Down
Loading

0 comments on commit f9adcd9

Please sign in to comment.