diff --git a/tests/ui/features/bootstrap/BasicStructure.php b/tests/ui/features/bootstrap/BasicStructure.php index 9aa7756e65a0..8a08ca69dac0 100644 --- a/tests/ui/features/bootstrap/BasicStructure.php +++ b/tests/ui/features/bootstrap/BasicStructure.php @@ -439,17 +439,17 @@ public function setUpScenarioGetRegularUsersAndGroups( */ public function tearDownScenarioDeleteCreatedUsersAndGroups() { $baseUrl = $this->getMinkParameter("base_url"); - foreach ($this->getCreatedUserNames() as $user) { + foreach ($this->getCreatedUsers() as $username => $user) { $result = UserHelper::deleteUser( $baseUrl, - $user, + $username, "admin", $this->getUserPassword("admin") ); - if ($result->getStatusCode() !== 200) { + if ($user['shouldHaveBeenCreated'] && ($result->getStatusCode() !== 200)) { error_log( - "INFORMATION: could not delete user. '" . $user . "'" + "INFORMATION: could not delete user '" . $username . "' " . $result->getStatusCode() . " " . $result->getBody() ); } @@ -558,12 +558,13 @@ public function getCreatedGroupNames() { * @return void */ public function addUserToCreatedUsersList( - $user, $password, $displayName = null, $email = null + $user, $password, $displayName = null, $email = null, $shouldHaveBeenCreated = true ) { $this->createdUsers [$user] = [ "password" => $password, "displayname" => $displayName, - "email" => $email + "email" => $email, + "shouldHaveBeenCreated" => $shouldHaveBeenCreated ]; } diff --git a/tests/ui/features/bootstrap/UsersContext.php b/tests/ui/features/bootstrap/UsersContext.php index 8804652ad094..bf1fc7d7cf1b 100644 --- a/tests/ui/features/bootstrap/UsersContext.php +++ b/tests/ui/features/bootstrap/UsersContext.php @@ -82,7 +82,7 @@ public function quotaOfUserIsSetTo($username, $quota) { } /** - * @When /^I create a user with the name "([^"]*)" (?:and )?the password "([^"]*)"(?: and the email "([^"]*)")?(?: that is a member of these groups)?$/ + * @When /^I (attempt to |)create a user with the name "([^"]*)" (?:and )?the password "([^"]*)"(?: and the email "([^"]*)")?(?: that is a member of these groups)?$/ * @param string $username * @param string $password * @param string $email @@ -90,7 +90,7 @@ public function quotaOfUserIsSetTo($username, $quota) { * @return void */ public function iCreateAUserInTheGUI( - $username, $password, $email=null, TableNode $groupsTable=null + $attemptTo, $username, $password, $email=null, TableNode $groupsTable=null ) { if (!is_null($groupsTable)) { $groups = $groupsTable->getColumn(0); @@ -102,8 +102,11 @@ public function iCreateAUserInTheGUI( $this->usersPage->createUser( $this->getSession(), $username, $password, $email, $groups ); + + $shouldHaveBeenCreated = ($attemptTo === ""); + $this->featureContext->addUserToCreatedUsersList( - $username, $password, "", $email + $username, $password, "", $email, $shouldHaveBeenCreated ); if (is_array($groups)) { foreach ($groups as $group) { diff --git a/tests/ui/features/other/login.feature b/tests/ui/features/other/login.feature index 5d21e3212cd8..1d077d21e020 100644 --- a/tests/ui/features/other/login.feature +++ b/tests/ui/features/other/login.feature @@ -34,7 +34,7 @@ So that unauthorised access is impossible Scenario Outline: use the webUI to create a user with special invalid characters Given I am logged in as admin And I am on the users page - When I create a user with the name and the password + When I attempt to create a user with the name and the password Then notifications should be displayed with the text |Error creating user: Only the following characters are allowed in a username: "a-z", "A-Z", "0-9", and "_.@-'"| And I should be redirected to a page with the title "Users - ownCloud" @@ -49,7 +49,7 @@ So that unauthorised access is impossible Scenario: use the webUI to create a user with empty password Given I am logged in as admin And I am on the users page - When I create a user with the name "bijay" and the password "" + When I attempt to create a user with the name "bijay" and the password "" Then notifications should be displayed with the text |Error creating user: A valid password must be provided| And I should be redirected to a page with the title "Users - ownCloud" @@ -57,7 +57,7 @@ So that unauthorised access is impossible Scenario Outline: use the webUI to create a user with less than 3 characters Given I am logged in as admin And I am on the users page - When I create a user with the name and the password + When I attempt to create a user with the name and the password Then notifications should be displayed with the text |Error creating user: The username must be at least 3 characters long| Examples: