|
| 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\Integration\Test\Fixture\Integration; |
| 10 | +use Magento\User\Test\Fixture\User; |
| 11 | +use Magento\Integration\Test\Page\Adminhtml\IntegrationIndex; |
| 12 | +use Magento\Integration\Test\Page\Adminhtml\IntegrationNew; |
| 13 | +use Magento\Mtf\TestCase\Injectable; |
| 14 | +use Magento\Backend\Test\Page\AdminAuthLogin; |
| 15 | + |
| 16 | + |
| 17 | +/** |
| 18 | + * Preconditions: |
| 19 | + * 1. Create admin user. |
| 20 | + * 2. Create integration. |
| 21 | + * 3. Configure 'Maximum Login Failures to Lockout Account'. |
| 22 | + * |
| 23 | + * Steps: |
| 24 | + * 1. Log in to backend as admin user. |
| 25 | + * 2. Navigate to System > Extensions > Integrations. |
| 26 | + * 3. Start to edit existing Integration. |
| 27 | + * 4. Fill in all data according to data set (password is incorrect). |
| 28 | + * 5. Perform action 4 specified number of times. |
| 29 | + * 6. "You have entered an invalid password for current user." appears after each attempt. |
| 30 | + * 7. Perform all assertions. |
| 31 | + * |
| 32 | + * @ZephyrId MAGETWO-49039 |
| 33 | + */ |
| 34 | +class LockAdminUserWhenEditingIntegrationTest extends Injectable |
| 35 | +{ |
| 36 | + /* tags */ |
| 37 | + const MVP = 'yes'; |
| 38 | + /* end tags */ |
| 39 | + |
| 40 | + /** |
| 41 | + * Integration grid page. |
| 42 | + * |
| 43 | + * @var IntegrationIndex |
| 44 | + */ |
| 45 | + protected $integrationIndexPage; |
| 46 | + |
| 47 | + /** |
| 48 | + * Integration new page. |
| 49 | + * |
| 50 | + * @var IntegrationNew |
| 51 | + */ |
| 52 | + protected $integrationNewPage; |
| 53 | + |
| 54 | + /** |
| 55 | + * Configuration setting. |
| 56 | + * |
| 57 | + * @var string |
| 58 | + */ |
| 59 | + protected $configData; |
| 60 | + |
| 61 | + /** |
| 62 | + * @var AdminAuthLogin |
| 63 | + */ |
| 64 | + protected $adminAuthLogin; |
| 65 | + |
| 66 | + /** |
| 67 | + * Preparing pages for test. |
| 68 | + * |
| 69 | + * @param IntegrationIndex $integrationIndex |
| 70 | + * @param IntegrationNew $integrationNew |
| 71 | + * @param AdminAuthLogin $adminAuthLogin |
| 72 | + * @return void |
| 73 | + */ |
| 74 | + public function __inject( |
| 75 | + IntegrationIndex $integrationIndex, |
| 76 | + IntegrationNew $integrationNew, |
| 77 | + AdminAuthLogin $adminAuthLogin |
| 78 | + ) { |
| 79 | + $this->integrationIndexPage = $integrationIndex; |
| 80 | + $this->integrationNewPage = $integrationNew; |
| 81 | + $this->adminAuthLogin = $adminAuthLogin; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Run Lock user when creating new integration test. |
| 86 | + * |
| 87 | + * @param Integration $initintegration |
| 88 | + * @param Integration $integration |
| 89 | + * @param int $attempts |
| 90 | + * @param User $customAdmin |
| 91 | + * @param string $configData |
| 92 | + * @return void |
| 93 | + */ |
| 94 | + public function test( |
| 95 | + Integration $initintegration, |
| 96 | + Integration $integration, |
| 97 | + $attempts, |
| 98 | + User $customAdmin, |
| 99 | + $configData = null |
| 100 | + ) { |
| 101 | + $this->configData = $configData; |
| 102 | + |
| 103 | + // Preconditions |
| 104 | + $this->objectManager->create( |
| 105 | + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, |
| 106 | + ['configData' => $this->configData] |
| 107 | + )->run(); |
| 108 | + $customAdmin->persist(); |
| 109 | + $initintegration->persist(); |
| 110 | + |
| 111 | + // login to backend with new user |
| 112 | + $this->adminAuthLogin->open(); |
| 113 | + $this->adminAuthLogin->getLoginBlock()->fill($customAdmin); |
| 114 | + $this->adminAuthLogin->getLoginBlock()->submit(); |
| 115 | + |
| 116 | + // Steps |
| 117 | + $filter = ['name' => $initintegration->getName()]; |
| 118 | + $this->integrationIndexPage->open(); |
| 119 | + $this->integrationIndexPage->getIntegrationGrid()->searchAndOpen($filter); |
| 120 | + for ($i = 0; $i < $attempts; $i++) { |
| 121 | + $this->integrationNewPage->getIntegrationForm()->fill($integration); |
| 122 | + $this->integrationNewPage->getFormPageActions()->save(); |
| 123 | + } |
| 124 | + |
| 125 | + // Reload page |
| 126 | + $this->adminAuthLogin->open(); |
| 127 | + $this->adminAuthLogin->getLoginBlock()->fill($customAdmin); |
| 128 | + $this->adminAuthLogin->getLoginBlock()->submit(); |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Clean data after running test. |
| 133 | + * |
| 134 | + * @return void |
| 135 | + */ |
| 136 | + public function tearDown() |
| 137 | + { |
| 138 | + $this->objectManager->create( |
| 139 | + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, |
| 140 | + ['configData' => $this->configData, 'rollback' => true] |
| 141 | + )->run(); |
| 142 | + } |
| 143 | +} |
0 commit comments