diff --git a/application/common/components/adapters/IdpIdBroker.php b/application/common/components/adapters/IdpIdBroker.php index 46443ba..55d982a 100644 --- a/application/common/components/adapters/IdpIdBroker.php +++ b/application/common/components/adapters/IdpIdBroker.php @@ -30,42 +30,6 @@ public function init() parent::init(); } - /** - * Activate a user. - * - * @param string $employeeId The Employee ID of the user to activate. - * @throws Exception - */ - public function activateUser(string $employeeId) - { - $this->getClient()->updateUser([ - 'employee_id' => $employeeId, - 'active' => 'yes', - ]); - } - - /** - * Attempt to authenticate using the given credentials, getting back - * information about the authenticated user (if the credentials were - * acceptable) or null (if unacceptable). - * - * @param string $username The username. - * @param string $password The password (in plaintext). - * @return User|null User information (if valid), or null. - * @throws Exception - */ - public function authenticate(string $username, string $password) - { - $authenticatedUserInfo = $this->getClient()->authenticate( - $username, - $password - ); - if ($authenticatedUserInfo === null) { - return null; - } - return new User($authenticatedUserInfo); - } - /** * Create a user with the given information. * @@ -154,19 +118,6 @@ public function listUsers($fields = null): array return self::getAsUsers($result); } - /** - * Set the password for the specified user. - * - * @param string $employeeId The Employee ID of the user whose password we - * are trying to set. - * @param string $password The desired (new) password, in plaintext. - * @throws Exception - */ - public function setPassword(string $employeeId, string $password) - { - $this->getClient()->setPassword($employeeId, $password); - } - /** * Update the specified user with the given information. * diff --git a/application/common/components/adapters/fakes/FakeIdBroker.php b/application/common/components/adapters/fakes/FakeIdBroker.php index 474caa6..12a59f0 100644 --- a/application/common/components/adapters/fakes/FakeIdBroker.php +++ b/application/common/components/adapters/fakes/FakeIdBroker.php @@ -18,16 +18,6 @@ public function __construct(array $usersByEmployeeId = [], array $config = []) parent::__construct($config); } - public function activateUser(string $employeeId) - { - $this->usersByEmployeeId[$employeeId]['active'] = 'yes'; - } - - public function authenticate(string $username, string $password) - { - throw new NotSupportedException(); - } - public function createUser(array $config = []) { /* @@ -86,11 +76,6 @@ public function listUsers($fields = null) return $results; } - public function setPassword(string $employeeId, string $password) - { - throw new NotSupportedException(); - } - public function updateUser(array $config = []) { if (array_key_exists('email', $config) && empty($config['email'])) { diff --git a/application/common/interfaces/IdBrokerInterface.php b/application/common/interfaces/IdBrokerInterface.php index a8544dd..86745b6 100644 --- a/application/common/interfaces/IdBrokerInterface.php +++ b/application/common/interfaces/IdBrokerInterface.php @@ -7,26 +7,6 @@ interface IdBrokerInterface { - /** - * Activate a user. - * - * @param string $employeeId The Employee ID of the user to activate. - * @throws Exception - */ - public function activateUser(string $employeeId); - - /** - * Attempt to authenticate using the given credentials, getting back - * information about the authenticated user (if the credentials were - * acceptable) or null (if unacceptable). - * - * @param string $username The username. - * @param string $password The password (in plaintext). - * @return User|null User information (if valid), or null. - * @throws Exception - */ - public function authenticate(string $username, string $password); - /** * Create a user with the given information. * @@ -72,16 +52,6 @@ public function getUser(string $employeeId); */ public function listUsers($fields = null); - /** - * Set the password for the specified user. - * - * @param string $employeeId The Employee ID of the user whose password we - * are trying to set. - * @param string $password The desired (new) password, in plaintext. - * @throws Exception - */ - public function setPassword(string $employeeId, string $password); - /** * Update the specified user with the given information. * diff --git a/application/features/bootstrap/IdpIdBrokerIntegrationContext.php b/application/features/bootstrap/IdpIdBrokerIntegrationContext.php index 69af53a..4004f3f 100644 --- a/application/features/bootstrap/IdpIdBrokerIntegrationContext.php +++ b/application/features/bootstrap/IdpIdBrokerIntegrationContext.php @@ -60,9 +60,9 @@ protected function generateDummyPassword() } /** - * @Given a user exists + * @Given an active user exists */ - public function aUserExists() + public function anActiveUserExists() { $newUser = $this->idBroker->createUser($this->testUserData); Assert::assertNotNull($newUser); @@ -85,23 +85,6 @@ public function thatUserIsNotActive() Assert::assertEquals('no', $user->getActive()); } - /** - * @When I activate that user - */ - public function iActivateThatUser() - { - // Activate the user. - $this->idBroker->activateUser( - $this->testUserData['employee_id'] - ); - - // Confirm that it worked. - $user = $this->idBroker->getUser( - $this->testUserData['employee_id'] - ); - Assert::assertEquals('yes', $user->getActive()); - } - /** * @Then that user should now be active */ @@ -113,30 +96,6 @@ public function thatUserShouldNowBeActive() Assert::assertEquals('yes', $user->getActive()); } - /** - * @Given that user has a password - */ - public function thatUserHasAPassword() - { - $this->testUserData['password'] = $this->generateDummyPassword(); - - $this->idBroker->setPassword( - $this->testUserData['employee_id'], - $this->testUserData['password'] - ); - } - - /** - * @When I try to authenticate as that user - */ - public function iTryToAuthenticateAsThatUser() - { - $this->result = $this->idBroker->authenticate( - $this->testUserData['username'], - $this->testUserData['password'] - ); - } - /** * @Then I should receive back information about that user */ @@ -180,16 +139,6 @@ public function thatUserShouldNowExist() Assert::assertSame($this->testUserData['email'], $user->getEmail()); } - /** - * @Given that user is active - */ - public function thatUserIsActive() - { - $this->idBroker->activateUser( - $this->testUserData['employee_id'] - ); - } - /** * @When I deactivate that user */ @@ -268,46 +217,6 @@ public function eachEntryInTheResultingListShouldHaveUserInformation() } } - /** - * @When I set that user's password to something else - */ - public function iSetThatUsersPasswordToSomethingElse() - { - $this->oldPassword = $this->testUserData['password']; - $this->newPassword = $this->generateDummyPassword(); - - $this->testUserData['password'] = $this->newPassword; - - $this->idBroker->setPassword( - $this->testUserData['employee_id'], - $this->newPassword - ); - } - - /** - * @Then I should NOT be able to authenticate with the old password - */ - public function iShouldNotBeAbleToAuthenticateWithTheOldPassword() - { - $authenticatedUser = $this->idBroker->authenticate( - $this->testUserData['username'], - $this->oldPassword - ); - Assert::assertNull($authenticatedUser); - } - - /** - * @Then I SHOULD be able to authenticate with the new password - */ - public function iShouldBeAbleToAuthenticateWithTheNewPassword() - { - $authenticatedUser = $this->idBroker->authenticate( - $this->testUserData['username'], - $this->newPassword - ); - Assert::assertNotNull($authenticatedUser); - } - /** * @When I update that user */ diff --git a/application/features/idp-id-broker-integration.feature b/application/features/idp-id-broker-integration.feature index 6d7dbd4..112a681 100644 --- a/application/features/idp-id-broker-integration.feature +++ b/application/features/idp-id-broker-integration.feature @@ -1,31 +1,18 @@ Feature: Integration with IdP ID Broker - Scenario: Activate user - Given a user exists - And that user is not active - When I activate that user - Then that user should now be active - - Scenario: Authenticate - Given a user exists - And that user has a password - When I try to authenticate as that user - Then I should receive back information about that user - Scenario: Create user Given a user does not exist When I create that user Then that user should now exist Scenario: Deactivate user - Given a user exists - And that user is active + Given an active user exists When I deactivate that user Then that user should now NOT be active Scenario: Get user - Given a user exists + Given an active user exists When I get that user Then I should receive back information about that user @@ -35,14 +22,7 @@ Feature: Integration with IdP ID Broker Then I should receive a list of at least 3 users And each entry in the resulting list should have user information - Scenario: Set password - Given a user exists - And that user has a password - When I set that user's password to something else - Then I should NOT be able to authenticate with the old password - And I SHOULD be able to authenticate with the new password - Scenario: Update user - Given a user exists + Given an active user exists When I update that user Then when I get that user I should receive the updated information