gds-api-adapters 71.9.0 → 73.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8670645ff0ca90d1b259b0607aca69f3164d91330b33f3d05f2e741fbbd334e6
4
- data.tar.gz: 7ac9e476e7ab01e1ad992bb9fd6dcb0fc4e494fcf05400e0df5cdc3a6b201a2e
3
+ metadata.gz: d35a5a4781f1983405b899ebeba4aecbf9d91728a9f82e7ac0a2b75b6c937181
4
+ data.tar.gz: 33c37300639794ce84a6afbf35d142afc572b1e17a67e60e1204c7b8d51b8b6a
5
5
  SHA512:
6
- metadata.gz: fb5bdf29581b987c5be58ffc9ccba0e5f950194a3e8f26d2ec9eb83b87db370a618716fb1d9a9cfd7db6049309e7d136ae2815cdc365205392a6634603583f5d
7
- data.tar.gz: 7f37ede40200371ead2740f89d44c4a588a0b488c0ae3516232370d6d65234b99e30a31c7fe36524b20ce19ebdcd222f81d72549627cb7182673389c030443eb
6
+ metadata.gz: 86c6188ed9f79fa7b5d8d0426e49453c864b9f4f1c8260f2e25291ad6266de37c869a22ec5298a9c57913f8d4a7141aac8c184cf6b2a1c5eed5ac040b895b608
7
+ data.tar.gz: 6361bff544285f8b60dfa099120b0e6b0ffea107dcf592c5ef151d337bd48458354ccfa52528d231cebd6a52211e4cdc0168135ff4e2d41819520e338367368e
@@ -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, state_id: nil, level_of_authentication: 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,13 +34,13 @@ 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
37
+ # Get an OIDC end-session URL to redirect the user to
40
38
  #
41
- # @param [Hash, nil] attributes Initial attributes to store
39
+ # @param [String, nil] govuk_account_session Value of the session header
42
40
  #
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)
41
+ # @return [Hash] An end-session URL
42
+ def get_end_session_url(govuk_account_session: nil)
43
+ get_json("#{endpoint}/api/oauth2/end-session", auth_headers(govuk_account_session))
46
44
  end
47
45
 
48
46
  # Get all the information about a user needed to render the account home page
@@ -54,6 +52,13 @@ class GdsApi::AccountApi < GdsApi::Base
54
52
  get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
55
53
  end
56
54
 
55
+ # Delete a users account
56
+ #
57
+ # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
58
+ def delete_user_by_subject_identifier(subject_identifier:)
59
+ delete_json("#{endpoint}/api/oidc-users/#{subject_identifier}")
60
+ end
61
+
57
62
  # Update the user record with privileged information from the auth service. Only the auth service will call this.
58
63
  #
59
64
  # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
@@ -72,25 +77,6 @@ class GdsApi::AccountApi < GdsApi::Base
72
77
  patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", params)
73
78
  end
74
79
 
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
80
  # Look up the values of a user's attributes
95
81
  #
96
82
  # @param [String] attributes Names of the attributes to check
@@ -112,17 +98,6 @@ class GdsApi::AccountApi < GdsApi::Base
112
98
  patch_json("#{endpoint}/api/attributes", { attributes: attributes }, auth_headers(govuk_account_session))
113
99
  end
114
100
 
115
- # Look up the names of a user's attributes
116
- #
117
- # @param [String] attributes Names of the attributes to check
118
- # @param [String] govuk_account_session Value of the session header
119
- #
120
- # @return [Hash] The attribute names (if present), and a new session header
121
- def get_attributes_names(attributes:, govuk_account_session:)
122
- querystring = nested_query_string({ attributes: attributes }.compact)
123
- get_json("#{endpoint}/api/attributes/names?#{querystring}", auth_headers(govuk_account_session))
124
- end
125
-
126
101
  # Get the details of an account-linked email subscription.
127
102
  #
128
103
  # @param [String] name Name of the subscription
@@ -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 raven_context
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, state_id: nil, level_of_authentication: nil, auth_uri: "http://auth/provider", state: "state")
23
- querystring = Rack::Utils.build_nested_query({ redirect_path: redirect_path, state_id: state_id, level_of_authentication: level_of_authentication }.compact)
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,16 +46,24 @@ 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
- )
49
+ #############################
50
+ # GET /api/oauth2/end-session
51
+ #############################
52
+ def stub_account_api_get_end_session_url(govuk_account_session: nil, end_session_uri: "http://auth/provider")
53
+ if govuk_account_session
54
+ stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/end-session")
55
+ .with(headers: { GdsApi::AccountApi::AUTH_HEADER_NAME => govuk_account_session })
56
+ .to_return(
57
+ status: 200,
58
+ body: { end_session_uri: end_session_uri }.to_json,
59
+ )
60
+ else
61
+ stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/end-session")
62
+ .to_return(
63
+ status: 200,
64
+ body: { end_session_uri: end_session_uri }.to_json,
65
+ )
66
+ end
59
67
  end
60
68
 
61
69
  ###############
@@ -94,6 +102,26 @@ module GdsApi
94
102
  )
95
103
  end
96
104
 
105
+ ############################################
106
+ # DELETE /api/oidc-users/:subject_identifier
107
+ ############################################
108
+
109
+ def stub_account_api_delete_user_by_subject_identifier(subject_identifier:)
110
+ stub_account_api_request(
111
+ :delete,
112
+ "/api/oidc-users/#{subject_identifier}",
113
+ response_status: 204,
114
+ )
115
+ end
116
+
117
+ def stub_account_api_delete_user_by_subject_identifier_does_not_exist(subject_identifier:)
118
+ stub_account_api_request(
119
+ :delete,
120
+ "/api/oidc-users/#{subject_identifier}",
121
+ response_status: 404,
122
+ )
123
+ end
124
+
97
125
  ###########################################
98
126
  # PATCH /api/oidc-users/:subject_identifier
99
127
  ###########################################
@@ -138,7 +166,7 @@ module GdsApi
138
166
  )
139
167
  end
140
168
 
141
- def stub_account_api_get_email_subscription_unauthorized(name:, **options)
169
+ def stub_account_api_unauthorized_get_email_subscription(name:, **options)
142
170
  stub_account_api_request(
143
171
  :get,
144
172
  "/api/email-subscriptions/#{name}",
@@ -205,79 +233,6 @@ module GdsApi
205
233
  )
206
234
  end
207
235
 
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
236
  #####################
282
237
  # GET /api/attributes
283
238
  #####################
@@ -345,40 +300,6 @@ module GdsApi
345
300
  )
346
301
  end
347
302
 
348
- ###########################
349
- # GET /api/attributes/names
350
- ###########################
351
- def stub_account_api_get_attributes_names(attributes: [], **options)
352
- querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
353
- stub_account_api_request(
354
- :get,
355
- "/api/attributes/names?#{querystring}",
356
- response_body: { values: attributes },
357
- **options,
358
- )
359
- end
360
-
361
- def stub_account_api_unauthorized_get_attributes_names(attributes: [], **options)
362
- querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
363
- stub_account_api_request(
364
- :get,
365
- "/api/attributes/names?#{querystring}",
366
- response_status: 401,
367
- **options,
368
- )
369
- end
370
-
371
- def stub_account_api_forbidden_get_attributes_names(attributes: [], needed_level_of_authentication: "level1", **options)
372
- querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
373
- stub_account_api_request(
374
- :get,
375
- "/api/attributes/names?#{querystring}",
376
- response_status: 403,
377
- response_body: { needed_level_of_authentication: needed_level_of_authentication },
378
- **options,
379
- )
380
- end
381
-
382
303
  ######################
383
304
  # GET /api/saved-pages
384
305
  ######################
@@ -507,7 +428,7 @@ module GdsApi
507
428
  )
508
429
  end
509
430
 
510
- def stub_account_api_delete_saved_page_unauthorised(page_path:, **options)
431
+ def stub_account_api_unauthorized_delete_saved_page(page_path:, **options)
511
432
  stub_account_api_request(
512
433
  :delete,
513
434
  "/api/saved-pages/#{CGI.escape(page_path)}",
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "71.9.0".freeze
2
+ VERSION = "73.1.0".freeze
3
3
  end
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: 71.9.0
4
+ version: 73.1.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-06 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable