-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from silinternational/feature/IDP-1182-update…
…-groups-external [IDP-1182] Add endpoint for updating `groups_external`
- Loading branch information
Showing
9 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,24 @@ types: | |
"code": 0, | ||
"status": 400 | ||
} | ||
GroupsExternalUpdate: | ||
type: object | ||
properties: | ||
email_address: string | ||
app_prefix: | ||
type: string | ||
description: > | ||
The app-specific prefix, without the trailing hyphen. | ||
groups: | ||
type: string[] | ||
description: > | ||
The desired list of groups, including the app-prefix. | ||
example: | | ||
{ | ||
"email_address": "[email protected]", | ||
"app_prefix": "myapp", | ||
"groups": ["myapp-users", "myapp-managers"] | ||
} | ||
UserResponse: | ||
description: > | ||
Information on user record. Password is not included if a password | ||
|
@@ -418,6 +436,25 @@ types: | |
description: A server-side error occurred. | ||
body: | ||
type: Error | ||
/external-groups: | ||
put: | ||
description: > | ||
Update a user's list of external groups for a given app-prefix to be | ||
exactly the given list, leaving external groups with other prefixes | ||
unchanged. | ||
body: | ||
type: GroupsExternalUpdate | ||
responses: | ||
204: | ||
description: > | ||
The user's external groups for that app-prefix were updated. | ||
404: | ||
description: > | ||
No such user found. | ||
422: | ||
description: The given data does not satisfy some validation rule. | ||
body: | ||
type: Error | ||
/{employee_id}: | ||
get: | ||
description: Get information about a specific user. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
application/features/bootstrap/GroupsExternalUpdatesContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Sil\SilIdBroker\Behat\Context; | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
use common\models\User; | ||
use Webmozart\Assert\Assert; | ||
|
||
class GroupsExternalUpdatesContext extends GroupsExternalContext | ||
{ | ||
/** | ||
* @When I update that user's list of :appPrefix external groups to the following: | ||
*/ | ||
public function iUpdateThatUsersListOfExternalGroupsToTheFollowing($appPrefix, TableNode $table) | ||
{ | ||
$externalGroups = []; | ||
foreach ($table as $row) { | ||
$externalGroups[] = $row['externalGroup']; | ||
} | ||
|
||
$this->cleanRequestBody(); | ||
$this->setRequestBody('email_address', $this->getUserEmailAddress()); | ||
$this->setRequestBody('app_prefix', $appPrefix); | ||
$this->setRequestBody('groups', $externalGroups); | ||
|
||
$this->iRequestTheResourceBe('/user/external-groups', 'updated'); | ||
} | ||
|
||
/** | ||
* @Then that user's list of external groups should be :commaSeparatedExternalGroups | ||
*/ | ||
public function thatUsersListOfExternalGroupsShouldBe($commaSeparatedExternalGroups) | ||
{ | ||
$user = User::findByEmail($this->getUserEmailAddress()); | ||
Assert::same($user->groups_external, $commaSeparatedExternalGroups); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Feature: Updating a User's list of external groups | ||
|
||
Background: | ||
Given the requester is authorized | ||
|
||
Scenario: Add an external group to a user's list for a particular app | ||
Given a user exists | ||
And that user's list of external groups is "wiki-users" | ||
When I update that user's list of "wiki" external groups to the following: | ||
| externalGroup | | ||
| wiki-users | | ||
| wiki-managers | | ||
Then the response status code should be 204 | ||
And that user's list of external groups should be "wiki-users,wiki-managers" | ||
|
||
Scenario: Remove an external group from a user's list for a particular app | ||
Given a user exists | ||
And that user's list of external groups is "wiki-users,wiki-managers" | ||
When I update that user's list of "wiki" external groups to the following: | ||
| externalGroup | | ||
| wiki-managers | | ||
Then the response status code should be 204 | ||
And that user's list of external groups should be "wiki-managers" | ||
|
||
Scenario: Leave a user's external groups for a different app unchanged | ||
Given a user exists | ||
And that user's list of external groups is "wiki-users,map-europe" | ||
When I update that user's list of "map" external groups to the following: | ||
| externalGroup | | ||
| map-america | | ||
Then the response status code should be 204 | ||
And that user's list of external groups should be "wiki-users,map-america" | ||
|
||
Scenario: Try to add an external group that does not match the given app-prefix | ||
Given a user exists | ||
And that user's list of external groups is "wiki-users" | ||
When I update that user's list of "wiki" external groups to the following: | ||
| externalGroup | | ||
| map-america | | ||
Then the response status code should be 422 | ||
And the response body should contain "prefix" | ||
And that user's list of external groups should be "wiki-users" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters