gds-api-adapters 71.7.0 → 72.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: a1177b1955f1d71f876486faf8932550ff11330dbc69bfcf4b3e04eea88ce2fa
4
- data.tar.gz: ca001da8d98cab308f0ce695aa46700c3c07d2fd2cd63e3ceea51868013ef4ed
3
+ metadata.gz: 51407d1cee42f0e1fbdf73f71f91f8e2b179adb56b81a9737ce26e334084644a
4
+ data.tar.gz: e8d397558f602abf5989795c92a2ec62880f0919d72897fde2e8e0ce83af2cdc
5
5
  SHA512:
6
- metadata.gz: 75a3f20f1364ecf6d0e76f02622b95337b2ec4a8dbb2bc77e4a46a99787c855063454fe92835dee4b105b03ab066c2b0d85c16b98bb57bce0e34009aadbf9a4b
7
- data.tar.gz: 282abe1e9269b6fa087f1a6e7205f49eef22f12670d3d7592f3a56acce50a97fab79c68a227be7d2b7a4a1e8e29cd1805738769d2a41e5399199a8c117352ee9
6
+ metadata.gz: 64ea0ab0af3fd9e4f4fe99a8bd8eab5179dc8216a2c45f4e76691150eaf8421d89ba197f923e56246ed5ed1292c49c5697e0c6c56043702e0a0cf1defd0fa402
7
+ data.tar.gz: 5a04715d1b8711171adb7d34cafc0f5f4ac499cf5157563c9f39c4fe949fef397ddbc1eab7a40eb9e5f355154cec76ff5b892d7f238515747390a3cb8ec82b3f
@@ -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,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
@@ -54,6 +43,13 @@ class GdsApi::AccountApi < GdsApi::Base
54
43
  get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
55
44
  end
56
45
 
46
+ # Delete a users account
47
+ #
48
+ # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
49
+ def delete_user_by_subject_identifier(subject_identifier:)
50
+ delete_json("#{endpoint}/api/oidc-users/#{subject_identifier}")
51
+ end
52
+
57
53
  # Update the user record with privileged information from the auth service. Only the auth service will call this.
58
54
  #
59
55
  # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
@@ -72,25 +68,6 @@ class GdsApi::AccountApi < GdsApi::Base
72
68
  patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", params)
73
69
  end
74
70
 
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
71
  # Look up the values of a user's attributes
95
72
  #
96
73
  # @param [String] attributes Names of the attributes to check
@@ -156,10 +156,10 @@ class GdsApi::EmailAlertApi < GdsApi::Base
156
156
  # @param [string] Subscriber new_address
157
157
  #
158
158
  # @return [Hash] subscriber
159
- def change_subscriber(id:, new_address:)
159
+ def change_subscriber(id:, new_address:, on_conflict: nil)
160
160
  patch_json(
161
161
  "#{endpoint}/subscribers/#{uri_encode(id)}",
162
- new_address: new_address,
162
+ { new_address: new_address, on_conflict: on_conflict }.compact,
163
163
  )
164
164
  end
165
165
 
@@ -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,
@@ -31,12 +31,12 @@ module GdsApi
31
31
  ###########################
32
32
  # POST /api/oauth2/callback
33
33
  ###########################
34
- def stub_account_api_validates_auth_response(code: nil, state: nil, govuk_account_session: "govuk-account-session", redirect_path: "/", ga_client_id: "ga-client-id")
34
+ def stub_account_api_validates_auth_response(code: nil, state: nil, govuk_account_session: "govuk-account-session", redirect_path: "/", ga_client_id: "ga-client-id", cookie_consent: false)
35
35
  stub_request(:post, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/callback")
36
36
  .with(body: hash_including({ code: code, state: state }.compact))
37
37
  .to_return(
38
38
  status: 200,
39
- body: { govuk_account_session: govuk_account_session, redirect_path: redirect_path, ga_client_id: ga_client_id }.to_json,
39
+ body: { govuk_account_session: govuk_account_session, redirect_path: redirect_path, ga_client_id: ga_client_id, cookie_consent: cookie_consent }.to_json,
40
40
  )
41
41
  end
42
42
 
@@ -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
  ###############
@@ -94,6 +82,26 @@ module GdsApi
94
82
  )
95
83
  end
96
84
 
85
+ ############################################
86
+ # DELETE /api/oidc-users/:subject_identifier
87
+ ############################################
88
+
89
+ def stub_account_api_delete_user_by_subject_identifier(subject_identifier:)
90
+ stub_account_api_request(
91
+ :delete,
92
+ "/api/oidc-users/#{subject_identifier}",
93
+ response_status: 204,
94
+ )
95
+ end
96
+
97
+ def stub_account_api_delete_user_by_subject_identifier_does_not_exist(subject_identifier:)
98
+ stub_account_api_request(
99
+ :delete,
100
+ "/api/oidc-users/#{subject_identifier}",
101
+ response_status: 404,
102
+ )
103
+ end
104
+
97
105
  ###########################################
98
106
  # PATCH /api/oidc-users/:subject_identifier
99
107
  ###########################################
@@ -138,7 +146,7 @@ module GdsApi
138
146
  )
139
147
  end
140
148
 
141
- def stub_account_api_get_email_subscription_unauthorized(name:, **options)
149
+ def stub_account_api_unauthorized_get_email_subscription(name:, **options)
142
150
  stub_account_api_request(
143
151
  :get,
144
152
  "/api/email-subscriptions/#{name}",
@@ -205,79 +213,6 @@ module GdsApi
205
213
  )
206
214
  end
207
215
 
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
216
  #####################
282
217
  # GET /api/attributes
283
218
  #####################
@@ -507,7 +442,7 @@ module GdsApi
507
442
  )
508
443
  end
509
444
 
510
- def stub_account_api_delete_saved_page_unauthorised(page_path:, **options)
445
+ def stub_account_api_unauthorized_delete_saved_page(page_path:, **options)
511
446
  stub_account_api_request(
512
447
  :delete,
513
448
  "/api/saved-pages/#{CGI.escape(page_path)}",
@@ -283,6 +283,11 @@ module GdsApi
283
283
  .to_return(status: 404)
284
284
  end
285
285
 
286
+ def stub_email_alert_api_subscriber_verification_email_linked_to_govuk_account
287
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/auth-token")
288
+ .to_return(status: 403)
289
+ end
290
+
286
291
  def stub_email_alert_api_authenticate_subscriber_by_govuk_account(govuk_account_session, subscriber_id, address, govuk_account_id: "user-id", new_govuk_account_session: nil)
287
292
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account")
288
293
  .with(
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "71.7.0".freeze
2
+ VERSION = "72.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.7.0
4
+ version: 72.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-06-29 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable