Skip to content

Commit 3b313a5

Browse files
magento2-login-as-customer/issues/40: "Login into Magento Admin panel as user that does not have access to 'Login as customer' button" test added.
1 parent affcbe9 commit 3b313a5

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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="AdminNoAccessToLoginAsCustomerButtonTest">
12+
<annotations>
13+
<features value="Login As Customer"/>
14+
<stories value="Permissions and ACl"/>
15+
<title value="User does not have access to 'Login as customer' button"/>
16+
<description value="Login into Magento Admin panel as user that does not have access to 'Login as customer' button"/>
17+
<severity value="CRITICAL"/>
18+
<group value="login_as_customer"/>
19+
</annotations>
20+
<before>
21+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1" stepKey="enableLoginAsCustomer"/>
22+
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
28+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUserBefore"/>
29+
30+
<!--Create New User-->
31+
<actionGroup ref="AdminOpenNewUserPageActionGroup" stepKey="goToNewUserPage"/>
32+
<actionGroup ref="AdminFillNewUserFormRequiredFieldsActionGroup" stepKey="fillNewUserForm">
33+
<argument name="user" value="NewAdminUser"/>
34+
</actionGroup>
35+
<actionGroup ref="AdminClickSaveButtonOnUserFormActionGroup" stepKey="saveNewUser"/>
36+
37+
<!--Create New Role-->
38+
<actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePage"/>
39+
<actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleForm">
40+
<argument name="role" value="roleSales"/>
41+
</actionGroup>
42+
<actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRole"/>
43+
</before>
44+
<after>
45+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
46+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
47+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
48+
49+
<!--Delete new User-->
50+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsSaleRoleUser"/>
51+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUserAfter"/>
52+
<actionGroup ref="AdminDeleteCustomUserActionGroup" stepKey="deleteNewUser">
53+
<argument name="user" value="AdminUserWithUpdatedUserRoleToSales"/>
54+
</actionGroup>
55+
56+
<!--Delete new Role-->
57+
<actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteCustomRole">
58+
<argument name="roleName" value="{{roleSales.rolename}}"/>
59+
</actionGroup>
60+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logOut"/>
61+
62+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0" stepKey="disableLoginAsCustomer"/>
63+
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestRun"/>
64+
</after>
65+
66+
<!--Assign new role-->
67+
<actionGroup ref="AdminOpenUserEditPageActionGroup" stepKey="openUserEditPage">
68+
<argument name="user" value="NewAdminUser"/>
69+
</actionGroup>
70+
<actionGroup ref="AdminFillNewUserFormRequiredFieldsActionGroup" stepKey="fillUserForm">
71+
<argument name="user" value="AdminUserWithUpdatedUserRoleToSales"/>
72+
</actionGroup>
73+
<actionGroup ref="AdminClickSaveButtonOnUserFormActionGroup" stepKey="saveUser"/>
74+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage">
75+
<argument name="message" value="You saved the user."/>
76+
</actionGroup>
77+
78+
<!-- Login as new User -->
79+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logOutFromAdminPanel"/>
80+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsSaleRoleUser">
81+
<argument name="adminUser" value="AdminUserWithUpdatedUserRoleToSales"/>
82+
</actionGroup>
83+
84+
<!-- Verify Login As Customer Login action is absent on Customer page -->
85+
<actionGroup ref="AdminLoginAsCustomerAbsentOnCustomerPageActionGroup" stepKey="verifyLoginAsCustomerAbsentOnCustomerPage">
86+
<argument name="customerId" value="$createCustomer.id$"/>
87+
</actionGroup>
88+
89+
<!-- Create order -->
90+
<actionGroup ref="CreateOrderActionGroup" stepKey="createOrder">
91+
<argument name="product" value="$$createSimpleProduct$$"/>
92+
<argument name="customer" value="$$createCustomer$$"/>
93+
</actionGroup>
94+
<grabTextFrom selector="{{AdminOrderDetailsInformationSection.orderId}}" stepKey="grabOrderId"/>
95+
96+
<!-- Verify Login As Customer Login action is absent on Order page -->
97+
<actionGroup ref="AdminLoginAsCustomerAbsentOnOrderPageActionGroup" stepKey="verifyLoginAsCustomerAbsentOnOrderPage">
98+
<argument name="orderId" value="{$grabOrderId}"/>
99+
</actionGroup>
100+
</test>
101+
</tests>

0 commit comments

Comments
 (0)