From 3095d843b81c312a8e5503911ea9e9fbb120f120 Mon Sep 17 00:00:00 2001 From: Sabin Date: Wed, 10 Jul 2024 12:13:16 +0545 Subject: [PATCH] added cli test for changing password of non-existing user --- tests/acceptance/features/bootstrap/CliContext.php | 9 ++++++--- .../features/cliCommands/resetUserPassword.feature | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/CliContext.php b/tests/acceptance/features/bootstrap/CliContext.php index 51a7c7e5af..654a6415a6 100644 --- a/tests/acceptance/features/bootstrap/CliContext.php +++ b/tests/acceptance/features/bootstrap/CliContext.php @@ -68,21 +68,24 @@ class CliContext implements Context { } /** - * @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); } diff --git a/tests/acceptance/features/cliCommands/resetUserPassword.feature b/tests/acceptance/features/cliCommands/resetUserPassword.feature index c5a015c9d9..16dc0ca22b 100644 --- a/tests/acceptance/features/cliCommands/resetUserPassword.feature +++ b/tests/acceptance/features/cliCommands/resetUserPassword.feature @@ -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"