gds-api-adapters 71.6.0 → 71.7.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1177b1955f1d71f876486faf8932550ff11330dbc69bfcf4b3e04eea88ce2fa
|
4
|
+
data.tar.gz: ca001da8d98cab308f0ce695aa46700c3c07d2fd2cd63e3ceea51868013ef4ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75a3f20f1364ecf6d0e76f02622b95337b2ec4a8dbb2bc77e4a46a99787c855063454fe92835dee4b105b03ab066c2b0d85c16b98bb57bce0e34009aadbf9a4b
|
7
|
+
data.tar.gz: 282abe1e9269b6fa087f1a6e7205f49eef22f12670d3d7592f3a56acce50a97fab79c68a227be7d2b7a4a1e8e29cd1805738769d2a41e5399199a8c117352ee9
|
@@ -188,6 +188,32 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
188
188
|
)
|
189
189
|
end
|
190
190
|
|
191
|
+
# Mark a subscriber as "linked" to its corresponding GOV.UK Account.
|
192
|
+
# In practice "linking" will mean that email-alert-frontend and
|
193
|
+
# account-api will treat the subscriber specially (eg, only allowing
|
194
|
+
# address changes via the account).
|
195
|
+
#
|
196
|
+
# @param [string] govuk_account_session The request's session identifier
|
197
|
+
#
|
198
|
+
# @return [Hash] subscriber
|
199
|
+
def link_subscriber_to_govuk_account(govuk_account_session:)
|
200
|
+
post_json(
|
201
|
+
"#{endpoint}/subscribers/govuk-account/link",
|
202
|
+
govuk_account_session: govuk_account_session,
|
203
|
+
)
|
204
|
+
end
|
205
|
+
|
206
|
+
# Find a subscriber which has been "linked" to a GOV.UK Account.
|
207
|
+
#
|
208
|
+
# @param [String] govuk_account_id An ID for the account.
|
209
|
+
#
|
210
|
+
# @return [Hash] subscriber
|
211
|
+
def find_subscriber_by_govuk_account(govuk_account_id:)
|
212
|
+
get_json(
|
213
|
+
"#{endpoint}/subscribers/govuk-account/#{govuk_account_id}",
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
191
217
|
# Verify a subscriber has control of a provided email
|
192
218
|
#
|
193
219
|
# @param [string] address Address to send verification email to
|
@@ -61,11 +61,12 @@ module GdsApi
|
|
61
61
|
###############
|
62
62
|
# GET /api/user
|
63
63
|
###############
|
64
|
-
def stub_account_api_user_info(level_of_authentication: "level0", email: "email@example.com", email_verified: true, has_unconfirmed_email: false, services: {}, **options)
|
64
|
+
def stub_account_api_user_info(id: "user-id", level_of_authentication: "level0", email: "email@example.com", email_verified: true, has_unconfirmed_email: false, services: {}, **options)
|
65
65
|
stub_account_api_request(
|
66
66
|
:get,
|
67
67
|
"/api/user",
|
68
68
|
response_body: {
|
69
|
+
id: id,
|
69
70
|
level_of_authentication: level_of_authentication,
|
70
71
|
email: email,
|
71
72
|
email_verified: email_verified,
|
@@ -6,11 +6,11 @@ module GdsApi
|
|
6
6
|
module EmailAlertApi
|
7
7
|
EMAIL_ALERT_API_ENDPOINT = Plek.find("email-alert-api")
|
8
8
|
|
9
|
-
def stub_email_alert_api_has_updated_subscriber(id, new_address)
|
9
|
+
def stub_email_alert_api_has_updated_subscriber(id, new_address, govuk_account_id: nil)
|
10
10
|
stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}")
|
11
11
|
.to_return(
|
12
12
|
status: 200,
|
13
|
-
body: get_subscriber_response(id, new_address).to_json,
|
13
|
+
body: get_subscriber_response(id, new_address, govuk_account_id).to_json,
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
@@ -265,11 +265,11 @@ module GdsApi
|
|
265
265
|
).to_return(status: 422)
|
266
266
|
end
|
267
267
|
|
268
|
-
def stub_email_alert_api_sends_subscriber_verification_email(subscriber_id, address)
|
268
|
+
def stub_email_alert_api_sends_subscriber_verification_email(subscriber_id, address, govuk_account_id: nil)
|
269
269
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/auth-token")
|
270
270
|
.to_return(
|
271
271
|
status: 201,
|
272
|
-
body: get_subscriber_response(subscriber_id, address).to_json,
|
272
|
+
body: get_subscriber_response(subscriber_id, address, govuk_account_id).to_json,
|
273
273
|
)
|
274
274
|
end
|
275
275
|
|
@@ -283,7 +283,7 @@ module GdsApi
|
|
283
283
|
.to_return(status: 404)
|
284
284
|
end
|
285
285
|
|
286
|
-
def stub_email_alert_api_authenticate_subscriber_by_govuk_account(govuk_account_session, subscriber_id, address, new_govuk_account_session: nil)
|
286
|
+
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
287
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account")
|
288
288
|
.with(
|
289
289
|
body: { govuk_account_session: govuk_account_session }.to_json,
|
@@ -291,7 +291,7 @@ module GdsApi
|
|
291
291
|
status: 200,
|
292
292
|
body: {
|
293
293
|
govuk_account_session: new_govuk_account_session,
|
294
|
-
}.compact.merge(get_subscriber_response(subscriber_id, address)).to_json,
|
294
|
+
}.compact.merge(get_subscriber_response(subscriber_id, address, govuk_account_id)).to_json,
|
295
295
|
)
|
296
296
|
end
|
297
297
|
|
@@ -328,6 +328,52 @@ module GdsApi
|
|
328
328
|
)
|
329
329
|
end
|
330
330
|
|
331
|
+
def stub_email_alert_api_link_subscriber_to_govuk_account(govuk_account_session, subscriber_id, address, govuk_account_id: "user-id", new_govuk_account_session: nil)
|
332
|
+
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link")
|
333
|
+
.with(
|
334
|
+
body: { govuk_account_session: govuk_account_session }.to_json,
|
335
|
+
).to_return(
|
336
|
+
status: 200,
|
337
|
+
body: {
|
338
|
+
govuk_account_session: new_govuk_account_session,
|
339
|
+
}.compact.merge(get_subscriber_response(subscriber_id, address, govuk_account_id)).to_json,
|
340
|
+
)
|
341
|
+
end
|
342
|
+
|
343
|
+
def stub_email_alert_api_link_subscriber_to_govuk_account_session_invalid(govuk_account_session)
|
344
|
+
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link")
|
345
|
+
.with(
|
346
|
+
body: { govuk_account_session: govuk_account_session }.to_json,
|
347
|
+
).to_return(
|
348
|
+
status: 401,
|
349
|
+
)
|
350
|
+
end
|
351
|
+
|
352
|
+
def stub_email_alert_api_link_subscriber_to_govuk_account_email_unverified(govuk_account_session, new_govuk_account_session: nil)
|
353
|
+
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link")
|
354
|
+
.with(
|
355
|
+
body: { govuk_account_session: govuk_account_session }.to_json,
|
356
|
+
).to_return(
|
357
|
+
status: 403,
|
358
|
+
body: {
|
359
|
+
govuk_account_session: new_govuk_account_session,
|
360
|
+
}.compact.to_json,
|
361
|
+
)
|
362
|
+
end
|
363
|
+
|
364
|
+
def stub_email_alert_api_find_subscriber_by_govuk_account(govuk_account_id, subscriber_id, address)
|
365
|
+
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/#{govuk_account_id}")
|
366
|
+
.to_return(
|
367
|
+
status: 200,
|
368
|
+
body: get_subscriber_response(subscriber_id, address, govuk_account_id).to_json,
|
369
|
+
)
|
370
|
+
end
|
371
|
+
|
372
|
+
def stub_email_alert_api_find_subscriber_by_govuk_account_no_subscriber(govuk_account_id)
|
373
|
+
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/#{govuk_account_id}")
|
374
|
+
.to_return(status: 404)
|
375
|
+
end
|
376
|
+
|
331
377
|
def assert_unsubscribed(uuid)
|
332
378
|
assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/unsubscribe/#{uuid}", times: 1)
|
333
379
|
end
|
@@ -359,11 +405,12 @@ module GdsApi
|
|
359
405
|
|
360
406
|
private
|
361
407
|
|
362
|
-
def get_subscriber_response(id, address)
|
408
|
+
def get_subscriber_response(id, address, govuk_account_id)
|
363
409
|
{
|
364
410
|
"subscriber" => {
|
365
411
|
"id" => id,
|
366
412
|
"address" => address,
|
413
|
+
"govuk_account_id" => govuk_account_id,
|
367
414
|
},
|
368
415
|
}
|
369
416
|
end
|
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: 71.
|
4
|
+
version: 71.7.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-
|
11
|
+
date: 2021-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|