Skip to content

Commit 3c3f7de

Browse files
magento2-login-as-customer/issues/40: "Change admin user's access to 'Login as Customer Log'" test added.
1 parent 73c429c commit 3c3f7de

File tree

4 files changed

+152
-0
lines changed

4 files changed

+152
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<!-- Open User Role resources for edit -->
11+
<actionGroup name="AdminEditUserRoleActionGroup">
12+
<arguments>
13+
<argument name="roleName" type="string"/>
14+
</arguments>
15+
<amOnPage url="{{AdminRolesPage.url}}" stepKey="navigateToUserRolesGrid"/>
16+
<fillField selector="{{AdminRoleGridSection.roleNameFilterTextField}}" userInput="{{roleName}}"
17+
stepKey="enterRoleName"/>
18+
<click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickSearch"/>
19+
<see selector="{{AdminDataGridTableSection.row('1')}}" userInput="{{roleName}}" stepKey="seeUserRole"/>
20+
<click selector="{{AdminDataGridTableSection.row('1')}}" stepKey="openRoleEditPage"/>
21+
<waitForPageLoad stepKey="waitForRoleEditPageLoad"/>
22+
<fillField selector="{{AdminEditRoleInfoSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="enterThePassword" />
23+
<click selector="{{AdminCreateRoleSection.roleResources}}" stepKey="clickToOpenRoleResources"/>
24+
<waitForPageLoad stepKey="waitForRoleResourceTab"/>
25+
<selectOption userInput="Custom" selector="{{AdminCreateRoleSection.resourceAccess}}"
26+
stepKey="selectResourceAccess"/>
27+
</actionGroup>
28+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<!-- Navigate to Login As Customer Log from Menu -->
12+
<actionGroup name="AdminOpenLoginAsCustomerLogFromMenuActionGroup">
13+
<click selector="{{AdminMenuSection.menuItem(AdminMenuCustomers.dataUiId)}}"
14+
stepKey="clickOnCustomersMenuItem"/>
15+
<click selector="{{AdminMenuSection.menuItem(AdminMenuLoginAsCustomer.dataUiId)}}"
16+
stepKey="openLoginAsCustomerLog"/>
17+
<waitForPageLoad stepKey="waitForLoginAsCustomerLog"/>
18+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Login As Customer Log"
19+
stepKey="seeForLoginAsCustomerLog"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
9+
<page name="AdminRoleEditPage" url="admin/user_role/editrole/rid/{{roleId}}/" module="Magento_User" area="admin" parameterized="true">
10+
<section name="AdminRoleGridSection"/>
11+
</page>
12+
</pages>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminChangUserAccessToLoginAsCustomerLogTest">
12+
<annotations>
13+
<features value="Login As Customer"/>
14+
<stories value="Permissions and ACl"/>
15+
<title value="Change admin user's access to 'Login as Customer Log'"/>
16+
<description
17+
value="Verify admin user's access to 'Login as Customer Log' can be changed"/>
18+
<severity value="CRITICAL"/>
19+
<group value="login_as_customer"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
23+
stepKey="enableLoginAsCustomer"/>
24+
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
25+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUserBefore"/>
26+
27+
<!--Create New Role-->
28+
<actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePage"/>
29+
<actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleForm">
30+
<argument name="role" value="customRoleAllResources"/>
31+
</actionGroup>
32+
<actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRole"/>
33+
34+
<!--Create New User-->
35+
<actionGroup ref="AdminCreateUserWithApiRoleActionGroup" stepKey="adminCreateUser">
36+
<argument name="user" value="NewAdminUser"/>
37+
<argument name="role" value="customRoleAllResources"/>
38+
</actionGroup>
39+
</before>
40+
<after>
41+
<!--Delete new User-->
42+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutNewUserAfter"/>
43+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUserAfter"/>
44+
<actionGroup ref="AdminDeleteCustomUserActionGroup" stepKey="deleteNewUser">
45+
<argument name="user" value="NewAdminUser"/>
46+
</actionGroup>
47+
48+
<!--Delete new Role-->
49+
<actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteCustomRoleAllResources">
50+
<argument name="roleName" value="{{customRoleAllResources.rolename}}"/>
51+
</actionGroup>
52+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logOut"/>
53+
54+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0"
55+
stepKey="disableLoginAsCustomer"/>
56+
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestRun"/>
57+
</after>
58+
59+
<!-- Login as new User -->
60+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logOutFromAdminPanel"/>
61+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsNewUser">
62+
<argument name="adminUser" value="NewAdminUser"/>
63+
</actionGroup>
64+
65+
<!-- Verify new User has access to 'Login as Customer Log' -->
66+
<actionGroup ref="AdminOpenLoginAsCustomerLogFromMenuActionGroup" stepKey="openLoginAsCustomerLog"/>
67+
68+
<!-- Revoke 'Login as Customer Log' access for new User -->
69+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutNewUser"/>
70+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUser"/>
71+
72+
<actionGroup ref="AdminEditUserRoleActionGroup" stepKey="openEditUserRole">
73+
<argument name="roleName" value="{{customRoleAllResources.rolename}}"/>
74+
</actionGroup>
75+
<actionGroup ref="AdminRevokeRoleResourceActionGroup" stepKey="revokeLoginAsCustomerAccess">
76+
<argument name="resourceName" value="Login As Customer Log"/>
77+
</actionGroup>
78+
<actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveEditedRole"/>
79+
80+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutDefaultAdminUserAfterRevoke"/>
81+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsNewUserAfterRevoke">
82+
<argument name="adminUser" value="NewAdminUser"/>
83+
</actionGroup>
84+
85+
<!-- Verify new User no longer has access to 'Login as Customer Log' menu item -->
86+
<actionGroup ref="AdminLoginAsCustomerLogAbsentInMenuActionGroup" stepKey="verifyLoginAsCustomerLogAbsentInMenu"/>
87+
88+
<!-- Verify new User no longer has access to 'Login as Customer Log' -->
89+
<actionGroup ref="AdminLoginAsCustomerLogPageNotAvailableActionGroup" stepKey="verifyLoginAsCustomerLogPageNotAvailable"/>
90+
</test>
91+
</tests>

0 commit comments

Comments
 (0)