1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \Security \Test \TestCase ;
8
+
9
+ use Magento \User \Test \Page \Adminhtml \UserEdit ;
10
+ use Magento \User \Test \Page \Adminhtml \UserIndex ;
11
+ use Magento \Backend \Test \Page \AdminAuthLogin ;
12
+ use Magento \User \Test \Fixture \User ;
13
+ use Magento \Mtf \TestCase \Injectable ;
14
+
15
+ /**
16
+ * Preconditions:
17
+ * 1. Create new admin user.
18
+ * 2. Configure 'Maximum Login Failures to Lockout Account'.
19
+ *
20
+ * Steps:
21
+ * 1. Log in to backend as new created admin user.
22
+ * 2. Navigate to System > All Users.
23
+ * 3. Start editing existing User.
24
+ * 4. Fill in all data according to data set (password is incorrect).
25
+ * 5. Perform action 4 specified number of times.
26
+ * 6. Admin account is locked.
27
+ * 7. Perform all assertions.
28
+ *
29
+ * @ZephyrId MAGETWO-49035
30
+ */
31
+ class LockAdminUserWhenEditingUserTest extends Injectable
32
+ {
33
+ /* tags */
34
+ const MVP = 'yes ' ;
35
+ const DOMAIN = 'PS ' ;
36
+ /* end tags */
37
+
38
+ /**
39
+ * User grid page
40
+ *
41
+ * @var UserIndex
42
+ */
43
+ protected $ userIndexPage ;
44
+
45
+ /**
46
+ * User edit page
47
+ *
48
+ * @var UserEdit
49
+ */
50
+ protected $ userEditPage ;
51
+
52
+ /**
53
+ * @var $configData
54
+ */
55
+ protected $ configData ;
56
+
57
+ /**
58
+ * @var AdminAuthLogin page
59
+ */
60
+ protected $ adminAuthLogin ;
61
+
62
+ /**
63
+ * Setup data for test.
64
+ * @param UserIndex $userIndex
65
+ * @param UserEdit $userEdit
66
+ * @param AdminAuthLogin $adminAuthLogin
67
+ */
68
+ public function __inject (
69
+ UserIndex $ userIndex ,
70
+ UserEdit $ userEdit ,
71
+ AdminAuthLogin $ adminAuthLogin
72
+ ) {
73
+ $ this ->userIndexPage = $ userIndex ;
74
+ $ this ->userEditPage = $ userEdit ;
75
+ $ this ->adminAuthLogin = $ adminAuthLogin ;
76
+ }
77
+ /**
78
+ * Runs Lock admin user when editing existing role test.
79
+ *
80
+ * @param User $user
81
+ * @param int $attempts
82
+ * @param User $customAdmin
83
+ * @param string $configData
84
+ * @return void
85
+ */
86
+ public function test (
87
+ $ attempts ,
88
+ User $ customAdmin ,
89
+ User $ user ,
90
+ $ configData = null
91
+ ) {
92
+ $ this ->configData = $ configData ;
93
+
94
+ // Preconditions
95
+ $ this ->objectManager ->create (
96
+ \Magento \Config \Test \TestStep \SetupConfigurationStep::class,
97
+ ['configData ' => $ this ->configData ]
98
+ )->run ();
99
+ $ customAdmin ->persist ();
100
+
101
+ // Steps login to backend with new user
102
+ $ this ->adminAuthLogin ->open ();
103
+ $ this ->adminAuthLogin ->getLoginBlock ()->fill ($ customAdmin );
104
+ $ this ->adminAuthLogin ->getLoginBlock ()->submit ();
105
+ // Select user to edit.
106
+ $ filter = ['username ' => $ customAdmin ->getUsername ()];
107
+ $ this ->userIndexPage ->open ();
108
+ $ this ->userIndexPage ->getUserGrid ()->searchAndOpen ($ filter );
109
+ // Edit user with wrong password
110
+ for ($ i = 0 ; $ i < $ attempts ; $ i ++) {
111
+ $ this ->userEditPage ->getUserForm ()->fill ($ user );
112
+ $ this ->userEditPage ->getPageActions ()->save ();
113
+ }
114
+ // Reload
115
+ $ this ->adminAuthLogin ->open ();
116
+ $ this ->adminAuthLogin ->getLoginBlock ()->fill ($ customAdmin );
117
+ $ this ->adminAuthLogin ->getLoginBlock ()->submit ();
118
+ }
119
+ /**
120
+ * Clean data after running test.
121
+ *
122
+ * @return void
123
+ */
124
+ public function tearDown ()
125
+ {
126
+ $ this ->objectManager ->create (
127
+ \Magento \Config \Test \TestStep \SetupConfigurationStep::class,
128
+ ['configData ' => $ this ->configData , 'rollback ' => true ]
129
+ )->run ();
130
+ }
131
+ }
0 commit comments