/** * @param $name * @return array */ static function get($name) { $conf = array('TokenColor' => '#ff3a3a', 'TokenTextColor' => '#ffffff'); switch ($name) { default: case 'ada': return array_merge($conf, array('id' => Uuid::get('user.id.ada'), 'name' => 'ada', 'FirstName' => 'Ada', 'LastName' => 'Lovelace', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'TokenCode' => 'ADA', 'PrivateKey' => 'ada_private.key', 'PublicKey' => 'ada_public.key')); break; case 'betty': return array_merge($conf, array('id' => Uuid::get('user.id.betty'), 'name' => 'betty', 'FirstName' => 'Betty', 'LastName' => 'Holberton', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'TokenCode' => 'BET', 'PrivateKey' => 'betty_private.key')); break; case 'carol': return array_merge($conf, array('id' => Uuid::get('user.id.carol'), 'name' => 'carol', 'FirstName' => 'Carol', 'LastName' => 'Shaw', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'TokenCode' => 'CAR', 'PrivateKey' => 'carol_private.key')); break; case 'frances': return array_merge($conf, array('id' => Uuid::get('user.id.frances'), 'name' => 'frances', 'FirstName' => 'Frances', 'LastName' => 'Allen', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'TokenCode' => 'FRA', 'PrivateKey' => 'frances_private.key')); break; case 'edith': return array_merge($conf, array('id' => Uuid::get('user.id.edith'), 'name' => 'edith', 'FirstName' => 'Edith', 'LastName' => 'Clarke', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'TokenCode' => 'EDI', 'PrivateKey' => 'edith_private.key')); break; case 'admin': return array_merge($conf, array('id' => Uuid::get('user.id.admin'), 'name' => 'admin', 'FirstName' => 'Admin', 'LastName' => 'User', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'TokenCode' => 'ADM', 'PrivateKey' => 'admin_private.key')); break; /*************************************************** * Definition of non existing users we can * reuse to create predictive data ***************************************************/ /*************************************************** * Definition of non existing users we can * reuse to create predictive data ***************************************************/ case 'john': return array_merge($conf, array('id' => Uuid::get('*****@*****.**'), 'name' => 'john', 'FirstName' => 'John', 'LastName' => 'Doe', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'PasswordStrength' => 'strong', 'TokenCode' => 'JON', 'PrivateKey' => Gpgkey::get(['name' => 'johndoe'])['filepath'])); break; case 'curtis': return array_merge($conf, array('id' => Uuid::get('*****@*****.**'), 'name' => 'curtis', 'FirstName' => 'Curtis', 'LastName' => 'Mayfield', 'Username' => '*****@*****.**', 'MasterPassword' => '*****@*****.**', 'PasswordStrength' => 'very strong', 'TokenCode' => 'CUR', 'PrivateKey' => Gpgkey::get(['name' => 'johndoe'])['filepath'])); break; } }
/** * Scenario : After creating an admin user, the given user should have access to the admin functionalities * Given I am admin * And I am logged in * When I go to user workspace * And I create a admin user * Then I could see the user is created * And I logout * * Given I am the user freshly created * And I access the email received regarding my account creation * And I click on the link inside the email * Then I should reach the setup page * When I complete the setup * Then I should be logged in with my new account * When I go to user workspace * Then I should see the create button * And I should see the edit button * And I should see the delete button */ public function testCreateAdminUserHasAdminRights() { // Reset database at the end of test. $this->resetDatabaseWhenComplete(); // Given I am Ada $user = User::get('admin'); $this->setClientConfig($user); // And I am logged in $this->loginAs($user); // Go to user workspace $this->gotoWorkspace('user'); $this->createUser(['first_name' => 'John', 'last_name' => 'Doe', 'username' => '*****@*****.**', 'admin' => true]); $this->logout(); // As AN, access the email sent after accoun creation $this->getUrl('seleniumTests/showLastEmail/' . urlencode('*****@*****.**')); // Follow the link in the email. $this->followLink('get started'); // Wait until I am sure that the page is loaded. $this->waitUntilISee('.plugin-check-wrapper', '/Plugin check/'); // Go to login page. we don't need to complete the setup since we just want to check the login. $this->completeSetupWithKeyImport(['private_key' => file_get_contents(Gpgkey::get(['name' => 'johndoe'])['filepath'])]); // Log in. $this->loginAs('*****@*****.**'); // Assert user is logged in. $this->assertElementContainsText($this->find('js_app_profile_dropdown'), '*****@*****.**'); // Go to user workspace $this->gotoWorkspace('user'); // Observe that create button is visible $this->assertVisible('js_wsp_create_button'); // Observe that edit button is visible $this->assertVisible('js_user_wk_menu_edition_button'); // Observe that delete button is visible $this->assertVisible('js_user_wk_menu_deletion_button'); }
/** * Scenario : As an admin I can modify the role of an admin user to non admin * * Given I am admin * And I am logged in on the user workspace * And I created a new admin user * And I logout * And I follow the setup procedure as the new user * And I am logged in automatically * And I logout * When I login as admin * And I go to user workspace * And I edit the newly created user * And I uncheck the admin role * And I click save * Then I can see a success notification * And I can see the user role is visible in the sidebar, and not admin role * When I log out * And I log in as the newly created user * And I go to user workspace * Then I should not see the create button * And I should not see the edit button * And I should not see the delete button */ public function testEditUserRoleChangeToNonAdmin() { // Reset database at the end of test. $this->resetDatabaseWhenComplete(); // Given I am Admin $user = User::get('admin'); $this->setClientConfig($user); // And I am logged in on the user workspace $this->loginAs($user['Username']); $this->gotoWorkspace('user'); // Create user $newUser = ['first_name' => 'John', 'last_name' => 'Doe', 'username' => '*****@*****.**', 'admin' => true]; $this->createUser($newUser); // Log out. $this->logout(); // As new user, access the email sent after accoun creation $this->getUrl('seleniumTests/showLastEmail/' . urlencode($newUser['username'])); // Follow the link in the email. $this->followLink('get started'); // Wait until I am sure that the page is loaded. $this->waitUntilISee('.plugin-check-wrapper', '/Plugin check/'); // Go to login page. we don't need to complete the setup since we just want to check the login. $this->completeSetupWithKeyImport(['private_key' => file_get_contents(Gpgkey::get(['name' => 'johndoe'])['filepath'])]); // Given I am Admin $user = User::get('admin'); $this->setClientConfig($user); // And I am logged in on the user workspace $this->loginAs($user['Username']); $this->gotoWorkspace('user'); // When I edit the new user $this->goToEditUser($newUser); // And I unselect the admin role $this->checkCheckbox('#js_field_role_id .role-admin input[type=checkbox]'); // And I submit the changes $this->click('.edit-user-dialog input[type=submit]'); // Then I should see a success message $this->assertNotification('app_users_edit_success'); // And I should see that the user is marked as admin in the sidebar $this->assertElementContainsText('#js_user_details .role', 'User'); // When I logout $this->logout(); // Through the dummies, we can predict the user that was created (predictible uuid). $user = User::get('john'); $this->setClientConfig($user); // And I login again as the newly created user $this->loginAs($newUser['username']); // And go to the user workspace $this->gotoWorkspace('user'); // Assert that the user doesn't have admin capabilities // Observe that create button is not visible $this->assertNotVisible('js_wsp_create_button'); // Observe that edit button is not visible $this->assertNotVisible('js_user_wk_menu_edition_button'); // Observe that delete button is not visible $this->assertNotVisible('js_user_wk_menu_deletion_button'); }
/** * Scenario : As an AP I should be able to import my own key during the setup * Given I am registered as John Doe, and I go to the setup * When I go through the setup until the import key step * And I test that I can import my key * Then I should see that the setup behaves as it should (defined in function testStepImportKey) * When I complete the setup * Then I should be logged in inside the app * And I should be able to visually confirm my account information * @throws Exception */ public function testFollowSetupWithImportKey() { // Reset database at the end of test. $this->resetDatabaseWhenComplete(); $key = Gpgkey::get(['name' => 'johndoe']); $john = User::get('john'); // Register John Doe as a user. $this->registerUser($john['FirstName'], $john['LastName'], $john['Username']); // Go to setup page and register $this->goToSetup($john['Username']); // Wait $this->waitForSection('domain_check'); // Wait for the server key to be retrieved. $this->waitUntilISee('.why-plugin-wrapper', '/I\'ve checked/i'); // Check box domain check. $this->checkCheckbox('js_setup_domain_check'); // Click Next. $this->clickLink("Next"); // Wait $this->waitForSection('generate_key_form'); // Click on import. $this->clickLink('import'); // Wait $this->waitForSection('import_key_form'); // Test step import key. $this->completeStepImportKey($key); // Click Next $this->clickLink('Next'); // Wait until next step. $this->waitForSection('security_token'); // Click Next. $this->clickLink("Next"); // Wait until sees next step. $this->waitForSection('login_redirect'); // Wait until I reach the login page $this->waitUntilISee('.information h2', '/Welcome back!/'); // Login as john doe $this->loginAs(['Username' => $key['owner_email'], 'MasterPassword' => $key['masterpassword']]); $this->waitCompletion(); // Check we are logged in. $this->waitUntilISee('.page.password', null, 20); // Check that the name is ok. $this->assertElementContainsText($this->findByCss('.header .user.profile .details .name'), $key['owner_name']); // Check that the email is ok. $this->assertElementContainsText($this->findByCss('.header .user.profile .details .email'), $key['owner_email']); }