-
Notifications
You must be signed in to change notification settings - Fork 14
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 #1316 from alphagov/content-modelling/783-add-api-…
…adapters-for-signon (783) Add an API adapter for the signon users endpoint
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require_relative "base" | ||
|
||
class GdsApi::SignonApi < GdsApi::Base | ||
# Get users with specific UUIDs | ||
# | ||
# @param uuids [Array] | ||
# | ||
# signon_api.users( | ||
# ["7ac47b33-c09c-4c1d-a9a7-0cfef99081ac"], | ||
# ) | ||
# | ||
# @return [GdsApi::Response] A response containing a list of users with the specified UUIDs | ||
def get_users(uuids:) | ||
query = query_string(uuids:) | ||
get_json("#{endpoint}/api/users#{query}") | ||
end | ||
end |
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,52 @@ | ||
require "test_helper" | ||
require "gds_api/support_api" | ||
|
||
describe "GdsApi::SignonApi pact tests" do | ||
include PactTest | ||
|
||
describe "#get_users" do | ||
let(:bearer_token) { "SOME_BEARER_TOKEN" } | ||
let(:api_client) { GdsApi::SignonApi.new(signon_api_host, { bearer_token: }) } | ||
|
||
it "returns a list of users" do | ||
uuids = %w[9ef9779f-3cba-481a-9a73-00d39e33eb7b b55873b4-bc83-4efe-bdc9-6b7d381a723e 64c7d994-17e0-44d9-97b0-87b43a581eb9] | ||
signon_api | ||
.given("users exist with the UUIDs #{uuids[0]}, #{uuids[1]} and #{uuids[2]}") | ||
.upon_receiving("a raise ticket request") | ||
.with( | ||
method: :get, | ||
path: "/api/users", | ||
headers: GdsApi::JsonClient.default_request_headers.merge("Authorization" => "Bearer #{bearer_token}"), | ||
query: "uuids%5B%5D=#{uuids[0]}&uuids%5B%5D=#{uuids[1]}&uuids%5B%5D=#{uuids[2]}", | ||
) | ||
.will_respond_with( | ||
status: 200, | ||
body: [ | ||
{ | ||
"uid": "9ef9779f-3cba-481a-9a73-00d39e33eb7b", | ||
"name": Pact.like("Some user"), | ||
"email": Pact.like("[email protected]"), | ||
"organisation": nil, | ||
}, | ||
{ | ||
"uid": "b55873b4-bc83-4efe-bdc9-6b7d381a723e", | ||
"name": Pact.like("Some user"), | ||
"email": Pact.like("[email protected]"), | ||
"organisation": nil, | ||
}, | ||
{ | ||
"uid": "64c7d994-17e0-44d9-97b0-87b43a581eb9", | ||
"name": Pact.like("Some user"), | ||
"email": Pact.like("[email protected]"), | ||
"organisation": nil, | ||
}, | ||
], | ||
headers: { | ||
"Content-Type" => "application/json; charset=utf-8", | ||
}, | ||
) | ||
|
||
api_client.get_users(uuids:) | ||
end | ||
end | ||
end |
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