Skip to content

Commit

Permalink
added cli test for changing password of non-existing user
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Panta committed Jul 11, 2024
1 parent d351535 commit 3095d84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,24 @@ public function theAdministratorHasStartedTheServer(): void {
}

/**
* @When the administrator resets the password of user :user to :password using the CLI
* @When /^the administrator resets the password of (non-existing|existing) user "([^"]*)" to "([^"]*)" using the CLI$/
*
* @param string $status
* @param string $user
* @param string $password
*
* @return void
*/
public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $user, string $password): void {
public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $status, string $user, string $password): void {
$command = "idm resetpassword -u $user";
$body = [
"command" => $command,
"inputs" => [$password, $password]
];

$this->featureContext->setResponse(CliHelper::runCommand($body));
if ($status === "non-existing") {
return;
}
$this->featureContext->updateUserPassword($user, $password);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ Feature: reset user password via CLI command
| displayName | Alice Hansen |
| password | %alt1% |
And the administrator has stopped the server
When the administrator resets the password of user "Alice" to "newpass" using the CLI
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 has started the server
And user "Alice" should be able to create folder "newFolder" using password "newpass"
But user "Alice" should not be able to create folder "anotherFolder" using password "%alt1%"


Scenario: try to reset password of non-existing user
Given the administrator has stopped the server
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"

0 comments on commit 3095d84

Please sign in to comment.