gds-api-adapters 71.9.0 → 72.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gds_api/account_api.rb +1 -31
- data/lib/gds_api/exceptions.rb +1 -1
- data/lib/gds_api/test_helpers/account_api.rb +4 -89
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f884f8a2e2cd91ddec2d467ae503ae442ce852b033a5dfc3cf7d374f8fd60a0
|
4
|
+
data.tar.gz: aa34f87913d8ff559a85b99dd5c1fecf82bfddffad74fa2fea19fefbc3f2128d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6ca46bd2cd504c1a434d6fbf7f91399b4542beb2ddc996452236e429abf66530f43ddf00b6078630fc034b9f533f91ae8ca59ba4937a9b31dcb2aea936dc0ea
|
7
|
+
data.tar.gz: d31a33695afd0f60cdedc7cd70babbc0f01db7fa4abda227d7d0de8f0e5d237ee260e47a0e528ac90db220de1a4ebc1ab9ba6a3dd62a1c86272cf9fc4ddcf7a5
|
data/lib/gds_api/account_api.rb
CHANGED
@@ -11,15 +11,13 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
11
11
|
# Get an OAuth sign-in URL to redirect the user to
|
12
12
|
#
|
13
13
|
# @param [String, nil] redirect_path path on GOV.UK to send the user to after authentication
|
14
|
-
# @param [String, nil] state_id identifier originally returned by #create_registration_state
|
15
14
|
# @param [String, nil] level_of_authentication either "level1" (require MFA) or "level0" (do not require MFA)
|
16
15
|
#
|
17
16
|
# @return [Hash] An authentication URL and the OAuth state parameter (for CSRF protection)
|
18
|
-
def get_sign_in_url(redirect_path: nil,
|
17
|
+
def get_sign_in_url(redirect_path: nil, level_of_authentication: nil)
|
19
18
|
querystring = nested_query_string(
|
20
19
|
{
|
21
20
|
redirect_path: redirect_path,
|
22
|
-
state_id: state_id,
|
23
21
|
level_of_authentication: level_of_authentication,
|
24
22
|
}.compact,
|
25
23
|
)
|
@@ -36,15 +34,6 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
36
34
|
post_json("#{endpoint}/api/oauth2/callback", code: code, state: state)
|
37
35
|
end
|
38
36
|
|
39
|
-
# Register some initial state, to pass to get_sign_in_url, which is used to initialise the account if the user signs up
|
40
|
-
#
|
41
|
-
# @param [Hash, nil] attributes Initial attributes to store
|
42
|
-
#
|
43
|
-
# @return [Hash] The state ID to pass to get_sign_in_url
|
44
|
-
def create_registration_state(attributes:)
|
45
|
-
post_json("#{endpoint}/api/oauth2/state", attributes: attributes)
|
46
|
-
end
|
47
|
-
|
48
37
|
# Get all the information about a user needed to render the account home page
|
49
38
|
#
|
50
39
|
# @param [String] govuk_account_session Value of the session header
|
@@ -72,25 +61,6 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
72
61
|
patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", params)
|
73
62
|
end
|
74
63
|
|
75
|
-
# Check if a user has an email subscription for the Transition Checker
|
76
|
-
#
|
77
|
-
# @param [String] govuk_account_session Value of the session header
|
78
|
-
#
|
79
|
-
# @return [Hash] Whether the user has a subscription, and a new session header
|
80
|
-
def check_for_email_subscription(govuk_account_session:)
|
81
|
-
get_json("#{endpoint}/api/transition-checker-email-subscription", auth_headers(govuk_account_session))
|
82
|
-
end
|
83
|
-
|
84
|
-
# Create or update a user's email subscription for the Transition Checker
|
85
|
-
#
|
86
|
-
# @param [String] govuk_account_session Value of the session header
|
87
|
-
# @param [String] slug The email topic slug
|
88
|
-
#
|
89
|
-
# @return [Hash] Whether the user has a subscription, and a new session header
|
90
|
-
def set_email_subscription(govuk_account_session:, slug:)
|
91
|
-
post_json("#{endpoint}/api/transition-checker-email-subscription", { slug: slug }, auth_headers(govuk_account_session))
|
92
|
-
end
|
93
|
-
|
94
64
|
# Look up the values of a user's attributes
|
95
65
|
#
|
96
66
|
# @param [String] attributes Names of the attributes to check
|
data/lib/gds_api/exceptions.rb
CHANGED
@@ -3,7 +3,7 @@ module GdsApi
|
|
3
3
|
class BaseError < StandardError
|
4
4
|
# Give Sentry extra context about this event
|
5
5
|
# https://docs.sentry.io/clients/ruby/context/
|
6
|
-
def
|
6
|
+
def sentry_context
|
7
7
|
{
|
8
8
|
# Make Sentry group exceptions by type instead of message, so all
|
9
9
|
# exceptions like `GdsApi::TimedOutException` will get grouped as one
|
@@ -19,8 +19,8 @@ module GdsApi
|
|
19
19
|
#########################
|
20
20
|
# GET /api/oauth2/sign-in
|
21
21
|
#########################
|
22
|
-
def stub_account_api_get_sign_in_url(redirect_path: nil,
|
23
|
-
querystring = Rack::Utils.build_nested_query({ redirect_path: redirect_path,
|
22
|
+
def stub_account_api_get_sign_in_url(redirect_path: nil, level_of_authentication: nil, auth_uri: "http://auth/provider", state: "state")
|
23
|
+
querystring = Rack::Utils.build_nested_query({ redirect_path: redirect_path, level_of_authentication: level_of_authentication }.compact)
|
24
24
|
stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/sign-in?#{querystring}")
|
25
25
|
.to_return(
|
26
26
|
status: 200,
|
@@ -46,18 +46,6 @@ module GdsApi
|
|
46
46
|
.to_return(status: 401)
|
47
47
|
end
|
48
48
|
|
49
|
-
########################
|
50
|
-
# POST /api/oauth2/state
|
51
|
-
########################
|
52
|
-
def stub_account_api_create_registration_state(attributes: nil, state_id: "state-id")
|
53
|
-
stub_request(:post, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/state")
|
54
|
-
.with(body: hash_including({ attributes: attributes }.compact))
|
55
|
-
.to_return(
|
56
|
-
status: 200,
|
57
|
-
body: { state_id: state_id }.to_json,
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
49
|
###############
|
62
50
|
# GET /api/user
|
63
51
|
###############
|
@@ -138,7 +126,7 @@ module GdsApi
|
|
138
126
|
)
|
139
127
|
end
|
140
128
|
|
141
|
-
def
|
129
|
+
def stub_account_api_unauthorized_get_email_subscription(name:, **options)
|
142
130
|
stub_account_api_request(
|
143
131
|
:get,
|
144
132
|
"/api/email-subscriptions/#{name}",
|
@@ -205,79 +193,6 @@ module GdsApi
|
|
205
193
|
)
|
206
194
|
end
|
207
195
|
|
208
|
-
################################################
|
209
|
-
# GET /api/transition-checker-email-subscription
|
210
|
-
################################################
|
211
|
-
def stub_account_api_has_email_subscription(**options)
|
212
|
-
stub_account_api_request(
|
213
|
-
:get,
|
214
|
-
"/api/transition-checker-email-subscription",
|
215
|
-
response_body: { has_subscription: true },
|
216
|
-
**options,
|
217
|
-
)
|
218
|
-
end
|
219
|
-
|
220
|
-
def stub_account_api_does_not_have_email_subscription(**options)
|
221
|
-
stub_account_api_request(
|
222
|
-
:get,
|
223
|
-
"/api/transition-checker-email-subscription",
|
224
|
-
response_body: { has_subscription: false },
|
225
|
-
**options,
|
226
|
-
)
|
227
|
-
end
|
228
|
-
|
229
|
-
def stub_account_api_unauthorized_get_email_subscription(**options)
|
230
|
-
stub_account_api_request(
|
231
|
-
:get,
|
232
|
-
"/api/transition-checker-email-subscription",
|
233
|
-
response_status: 401,
|
234
|
-
**options,
|
235
|
-
)
|
236
|
-
end
|
237
|
-
|
238
|
-
def stub_account_api_forbidden_get_email_subscription(needed_level_of_authentication: "level1", **options)
|
239
|
-
stub_account_api_request(
|
240
|
-
:get,
|
241
|
-
"/api/transition-checker-email-subscription",
|
242
|
-
response_status: 403,
|
243
|
-
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
244
|
-
**options,
|
245
|
-
)
|
246
|
-
end
|
247
|
-
|
248
|
-
#################################################
|
249
|
-
# POST /api/transition-checker-email-subscription
|
250
|
-
#################################################
|
251
|
-
def stub_account_api_set_email_subscription(slug: nil, **options)
|
252
|
-
stub_account_api_request(
|
253
|
-
:post,
|
254
|
-
"/api/transition-checker-email-subscription",
|
255
|
-
with: { body: hash_including({ slug: slug }.compact) },
|
256
|
-
**options,
|
257
|
-
)
|
258
|
-
end
|
259
|
-
|
260
|
-
def stub_account_api_unauthorized_set_email_subscription(slug: nil, **options)
|
261
|
-
stub_account_api_request(
|
262
|
-
:post,
|
263
|
-
"/api/transition-checker-email-subscription",
|
264
|
-
with: { body: hash_including({ slug: slug }.compact) },
|
265
|
-
response_status: 401,
|
266
|
-
**options,
|
267
|
-
)
|
268
|
-
end
|
269
|
-
|
270
|
-
def stub_account_api_forbidden_set_email_subscription(slug: nil, needed_level_of_authentication: "level1", **options)
|
271
|
-
stub_account_api_request(
|
272
|
-
:post,
|
273
|
-
"/api/transition-checker-email-subscription",
|
274
|
-
with: { body: hash_including({ slug: slug }.compact) },
|
275
|
-
response_status: 403,
|
276
|
-
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
277
|
-
**options,
|
278
|
-
)
|
279
|
-
end
|
280
|
-
|
281
196
|
#####################
|
282
197
|
# GET /api/attributes
|
283
198
|
#####################
|
@@ -507,7 +422,7 @@ module GdsApi
|
|
507
422
|
)
|
508
423
|
end
|
509
424
|
|
510
|
-
def
|
425
|
+
def stub_account_api_unauthorized_delete_saved_page(page_path:, **options)
|
511
426
|
stub_account_api_request(
|
512
427
|
:delete,
|
513
428
|
"/api/saved-pages/#{CGI.escape(page_path)}",
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 72.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|