|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © 2016 Magento. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +namespace Magento\Security\Test\TestCase; |
| 7 | +use Magento\User\Test\Page\Adminhtml\UserRoleEditRole; |
| 8 | +use Magento\User\Test\Page\Adminhtml\UserRoleIndex; |
| 9 | +use Magento\Mtf\TestCase\Injectable; |
| 10 | +use Magento\User\Test\Fixture\User; |
| 11 | +use Magento\User\Test\Fixture\Role; |
| 12 | +use Magento\Backend\Test\Page\AdminAuthLogin; |
| 13 | +/** |
| 14 | + * Preconditions: |
| 15 | + * 1. Create new admin user and assign it to new role. |
| 16 | + * 2. Configure 'Maximum Login Failures to Lockout Account'. |
| 17 | + * |
| 18 | + * Steps: |
| 19 | + * 1. Log in to backend as new created admin user. |
| 20 | + * 2. Navigate to System > User Roles. |
| 21 | + * 3. Start editing existing User Role. |
| 22 | + * 4. Fill in all data according to data set (password is incorrect). |
| 23 | + * 5. Perform action 4 specified number of times. |
| 24 | + * 6. Admin account is locked. |
| 25 | + * 7. Perform all assertions. |
| 26 | + * |
| 27 | + * @ZephyrId MAGETWO-49037 |
| 28 | + * @Group Security |
| 29 | + * |
| 30 | + */ |
| 31 | +class LockAdminUserWhenEditingRoleTest extends Injectable |
| 32 | +{ |
| 33 | + /* tags */ |
| 34 | + const MVP = 'yes'; |
| 35 | + const SEVERITY = 'S2'; |
| 36 | + /* end tags */ |
| 37 | + /** |
| 38 | + * UserRoleIndex page. |
| 39 | + * |
| 40 | + * @var UserRoleIndex |
| 41 | + */ |
| 42 | + protected $userRoleIndex; |
| 43 | + /** |
| 44 | + * UserRoleEditRole page. |
| 45 | + * |
| 46 | + * @var UserRoleEditRole |
| 47 | + */ |
| 48 | + protected $userRoleEditRole; |
| 49 | + /** |
| 50 | + * Configuration setting. |
| 51 | + * |
| 52 | + * @var string |
| 53 | + */ |
| 54 | + protected $configData; |
| 55 | + /** |
| 56 | + * Admin login Page. |
| 57 | + * |
| 58 | + * @var AdminAuthLogin |
| 59 | + */ |
| 60 | + protected $adminAuthLogin; |
| 61 | + /** |
| 62 | + * Setup data for test. |
| 63 | + * |
| 64 | + * @param UserRoleIndex $userRoleIndex |
| 65 | + * @param UserRoleEditRole $userRoleEditRole |
| 66 | + * @param AdminAuthLogin $adminAuthLogin |
| 67 | + * @return void |
| 68 | + */ |
| 69 | + public function __inject( |
| 70 | + UserRoleIndex $userRoleIndex, |
| 71 | + UserRoleEditRole $userRoleEditRole, |
| 72 | + AdminAuthLogin $adminAuthLogin |
| 73 | + ) { |
| 74 | + $this->userRoleIndex = $userRoleIndex; |
| 75 | + $this->userRoleEditRole = $userRoleEditRole; |
| 76 | + $this->adminAuthLogin = $adminAuthLogin; |
| 77 | + } |
| 78 | + /** |
| 79 | + * Runs Lock admin user when editing existing role test. |
| 80 | + * |
| 81 | + * @param Role $role |
| 82 | + * @param Role $initrole |
| 83 | + * @param int $attempts |
| 84 | + * @param User $customAdmin |
| 85 | + * @param string $configData |
| 86 | + * @return void |
| 87 | + */ |
| 88 | + public function test( |
| 89 | + Role $role, |
| 90 | + Role $initrole, |
| 91 | + $attempts, |
| 92 | + User $customAdmin, |
| 93 | + $configData |
| 94 | + ) { |
| 95 | + $this->configData = $configData; |
| 96 | + // Preconditions |
| 97 | + $this->objectManager->create( |
| 98 | + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, |
| 99 | + ['configData' => $this->configData] |
| 100 | + )->run(); |
| 101 | + $customAdmin->persist(); |
| 102 | + $initrole->persist(); |
| 103 | + // Steps login to backend with new user |
| 104 | + $this->adminAuthLogin->open(); |
| 105 | + $this->adminAuthLogin->getLoginBlock()->fill($customAdmin); |
| 106 | + $this->adminAuthLogin->getLoginBlock()->submit(); |
| 107 | + $filter = ['rolename' => $initrole->getRolename()]; |
| 108 | + $this->userRoleIndex->open(); |
| 109 | + $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter); |
| 110 | + for ($i = 0; $i < $attempts; $i++) { |
| 111 | + $this->userRoleEditRole->getRoleFormTabs()->fill($role); |
| 112 | + $this->userRoleEditRole->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