mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-04 11:19:39 -06:00
Merge pull request #9593 from owncloud/cli-test-reset-admin-credentials
[tests-only][full-ci] added test for updating admin password via cli
This commit is contained in:
@@ -60,7 +60,7 @@ class CliContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given the administrator has started the server
|
||||
* @Given /^the administrator (?:starts|has started) the server$/
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -2647,4 +2647,58 @@ class GraphContext implements Context {
|
||||
"Response contains email '$email' but should not."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then user :byUser using password :password should be able to create a new user :user with default attributes
|
||||
*
|
||||
* @param string $byUser
|
||||
* @param string $password
|
||||
* @param string $user
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes(string $byUser, string $password, string $user): void {
|
||||
$response = GraphHelper::createUser(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$byUser,
|
||||
$password,
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user)
|
||||
);
|
||||
Assert::assertEquals(
|
||||
201,
|
||||
$response->getStatusCode(),
|
||||
__METHOD__ . " cannot create new user '$user' by user '$byUser'.\nResponse:" .
|
||||
json_encode($this->featureContext->getJsonDecodedResponse($response))
|
||||
);
|
||||
$this->featureContext->addUserToCreatedUsersList($user, $this->featureContext->getPasswordForUser($user));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given user :byUser has changed the username to :userName
|
||||
*
|
||||
* @param string $byUser
|
||||
* @param string $userName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function theUserHasChangedItsOwnUsernameTo(string $byUser, string $userName): void {
|
||||
$userId = $this->featureContext->getUserIdByUserName($byUser);
|
||||
$response = GraphHelper::editUser(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$byUser,
|
||||
$this->featureContext->getPasswordForUser($byUser),
|
||||
$userId,
|
||||
'PATCH',
|
||||
$userName,
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
$this->featureContext->updateUsernameInCreatedUserList($byUser, $userName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1156,6 +1156,26 @@ trait Provisioning {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oldUserName
|
||||
* @param string $newUserName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateUsernameInCreatedUserList(string $oldUserName, string $newUserName) :void {
|
||||
$normalizedUsername = $this->normalizeUsername($oldUserName);
|
||||
$normalizeNewUserName = $this->normalizeUsername($newUserName);
|
||||
if (\array_key_exists($normalizedUsername, $this->createdUsers)) {
|
||||
foreach ($this->createdUsers as $createdUser) {
|
||||
if ($createdUser['actualUsername'] === $oldUserName) {
|
||||
$this->createdUsers[$normalizeNewUserName] = $this->createdUsers[$normalizedUsername];
|
||||
$this->createdUsers[$normalizeNewUserName]['actualUsername'] = $newUserName;
|
||||
unset($this->createdUsers[$normalizedUsername]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remembers that a user from the list of users that were created during
|
||||
* test runs is no longer expected to exist. Useful if a user was created
|
||||
|
||||
@@ -22,3 +22,34 @@ Feature: reset user password via CLI command
|
||||
When the administrator resets the password of non-existing user "Alice" to "newpass" using the CLI
|
||||
Then the command should be successful
|
||||
But the command output should contain "Failed to update user password: entry does not exist"
|
||||
|
||||
|
||||
Scenario: reset password of admin user
|
||||
Given the user "Admin" has created a new user with the following attributes:
|
||||
| userName | Alice |
|
||||
| displayName | Alice Hansen |
|
||||
| password | %alt1% |
|
||||
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
|
||||
And the administrator has stopped the server
|
||||
When the administrator resets the password of existing user "Alice" to "newpass" using the CLI
|
||||
Then the command should be successful
|
||||
And the command output should contain "Password for user 'uid=Alice,ou=users,o=libregraph-idm' updated."
|
||||
But the command output should not contain "Failed to update user password: entry does not exist"
|
||||
And the administrator starts the server
|
||||
And user "Alice" using password "newpass" should be able to create a new user "Brian" with default attributes
|
||||
|
||||
|
||||
Scenario: reset password after renaming the admin user
|
||||
Given the user "Admin" has created a new user with the following attributes:
|
||||
| userName | Alice |
|
||||
| displayName | Alice Hansen |
|
||||
| password | %alt1% |
|
||||
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has changed the username to "superUser"
|
||||
And the administrator has stopped the server
|
||||
When the administrator resets the password of existing user "superUser" to "newpass" using the CLI
|
||||
Then the command should be successful
|
||||
And the command output should contain "Password for user 'uid=superUser,ou=users,o=libregraph-idm' updated."
|
||||
But the command output should not contain "Failed to update user password: entry does not exist"
|
||||
And the administrator starts the server
|
||||
And user "superUser" using password "newpass" should be able to create a new user "Brian" with default attributes
|
||||
|
||||
Reference in New Issue
Block a user