Skip to content

Commit

Permalink
Merge pull request #53 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 3.1.0 -- add password assess endpoint
  • Loading branch information
briskt authored Apr 10, 2019
2 parents e21bfe8 + b49cb51 commit 60b5831
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [3.1.0] - 2019-04-10
### Added
- new 'assessPassword' method, executes validation but does not save password

## [3.0.0] - 2019-03-13
### Changed
- 'mfaVerify' now returns the MFA object
Expand Down Expand Up @@ -69,7 +73,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Initial version of ID Broker API client.

[Unreleased]: https://github.com/silinternational/idp-id-broker-php-client/compare/3.0.0...HEAD
[Unreleased]: https://github.com/silinternational/idp-id-broker-php-client/compare/3.1.0...HEAD
[3.1.0]: https://github.com/silinternational/idp-id-broker-php-client/compare/3.0.0...3.1.0
[3.0.0]: https://github.com/silinternational/idp-id-broker-php-client/compare/2.6.0...3.0.0
[2.6.0]: https://github.com/silinternational/idp-id-broker-php-client/compare/2.5.1...2.6.0
[2.5.1]: https://github.com/silinternational/idp-id-broker-php-client/compare/2.5.0...2.5.1
Expand Down
11 changes: 11 additions & 0 deletions features/request/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ public function iCallSetpassword()
);
}

/**
* @When I call assessPassword
*/
public function iCallAssessPassword()
{
$this->getIdBrokerClient()->assessPassword(
$this->requestData['employee_id'],
$this->requestData['password']
);
}

/**
* @When I call updateUser
*/
Expand Down
16 changes: 16 additions & 0 deletions features/request/request.feature
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ Feature: Formatting requests for sending to the ID Broker API
}
"""

Scenario: Validating a password
Given I am using a baseUri of "https://api.example.com/"
And I have indicated not to validate the id broker ip
And I provide an "employee_id" of "123"
And I provide a "password" of "correcthorsebatterystaple"
When I call assessPassword
Then the method should be "PUT"
And the url should be 'https://api.example.com/user/123/password/assess'
And an authorization header should be present
And the body should equal the following:
"""
{
"password": "correcthorsebatterystaple"
}
"""

Scenario: Creating a recovery method
Given I am using a baseUri of "https://api.example.com/"
And I have indicated not to validate the id broker ip
Expand Down
15 changes: 15 additions & 0 deletions features/response/ResponseContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,21 @@ public function iCallSetpasswordWithTheNecessaryData()
}
}

/**
* @When I call assessPassword with the necessary data
*/
public function iCallAssessPasswordWithTheNecessaryData()
{
try {
$this->result = $this->getIdBrokerClient()->assessPassword(
'12345',
'correcthorsebatterystaple'
);
} catch (Exception $e) {
$this->exceptionThrown = $e;
}
}

/**
* @Then an exception should NOT have been thrown
*/
Expand Down
15 changes: 15 additions & 0 deletions features/response/response.feature
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ Feature: Handling responses from the ID Broker API
When I call setPassword with the necessary data
Then an exception should NOT have been thrown

Scenario: Handling a successful assessPassword call
Given a call to "assessPassword" will return a 204 response
When I call assessPassword with the necessary data
Then the result should be true

Scenario: Handling a negative assessPassword call
Given a call to "assessPassword" will return a 409 response
When I call assessPassword with the necessary data
Then an exception with status code 409 SHOULD have been thrown

Scenario: Handling a negative assessPassword call
Given a call to "assessPassword" will return a 422 response
When I call assessPassword with the necessary data
Then an exception with status code 422 SHOULD have been thrown

Scenario: Handling a "correct" response from mfaVerify
Given a call to "mfaVerify" will return a 200 response
When I call mfaVerify with the necessary data
Expand Down
25 changes: 25 additions & 0 deletions src/IdBrokerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,31 @@ public function setPassword(string $employeeId, string $password)
$this->reportUnexpectedResponse($result, 1490808839);
}

/**
* Validate a new password for a specified user, but do not save it.
*
* @param string $employeeId The Employee ID of the user for whom we
* are validating a new password.
* @param string $password The desired password, in plaintext.
*
* @return bool
* @throws ServiceException
*/
public function assessPassword(string $employeeId, string $password)
{
$result = $this->assessPasswordInternal([
'employee_id' => $employeeId,
'password' => $password,
]);
$statusCode = (int)$result[ 'statusCode' ];

if ($statusCode >= 200 && $statusCode <= 299) {
return true;
}

$this->reportUnexpectedResponse($result, 1554404870);
}

/**
* @param \GuzzleHttp\Command\Result $response
* @param int $uniqueErrorCode
Expand Down
17 changes: 17 additions & 0 deletions src/descriptions/id-broker-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,23 @@
],
],
],
'assessPasswordInternal' => [
'httpMethod' => 'PUT',
'uri' => '/user/{employee_id}/password/assess',
'responseModel' => 'Result',
'parameters' => [
'employee_id' => [
'required' => true,
'type' => 'string',
'location' => 'uri',
],
'password' => [
'required' => true,
'type' => 'string',
'location' => 'json',
],
],
],
'updateUserInternal' => [
'httpMethod' => 'PUT',
'uri' => '/user/{employee_id}',
Expand Down

0 comments on commit 60b5831

Please sign in to comment.