gds-api-adapters 75.1.0 → 77.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36e41430cc8105c52489b3ba8bde38b4027a124a4a0cc3ca4ddabf120dd97de8
4
- data.tar.gz: c61130dc56390e9a6ff2962589686bb232abbd506b742c14d6d77a9f6ac7500a
3
+ metadata.gz: 2ea534ae361e87fde66ed0a9909c3920b0a58c86ad5e26b3dd4c7d13baabe15c
4
+ data.tar.gz: a24876d1c08767f5d934e9327feb212a6e35f33142c4c6764e85f28eca525de5
5
5
  SHA512:
6
- metadata.gz: 2b3b29f19b7f55cff24242a9370bfc3cc7b4392de6f9fe84e4d64067bdeabf56b8d35468f2556d86648efb5f7189e3c527203d63ace5ffd6745ad513701addd6
7
- data.tar.gz: 5efaa1939f0b3c8644ee3e8c19dc208419cfc6344d3b644c506e76e87965923f3f1c1c9427dc1702be32560caeea38fee900ec5a06ee09b47533324bb3c9e8e0
6
+ metadata.gz: 23a867c3eb864e2078989ac9f395d572a3679a06ad1efc20f080563d4aabd65e46e27b29118e77daa130924d00c9de4c6f7a7a4f1131d2b242099dc3a05783d6
7
+ data.tar.gz: 2340a2464e1971055760d1169f05e18c40e9ef50e75610b763f6c6018fcae863a8669aa77a8c9aedaa9ed3632c8e463f0147b92a80d2a811c69d2f4b1ec47a94
@@ -52,6 +52,17 @@ class GdsApi::AccountApi < GdsApi::Base
52
52
  get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
53
53
  end
54
54
 
55
+ # Find a user by email address, returning whether they match the given session (if any)
56
+ #
57
+ # @param [String] email The email address to search for
58
+ # @param [String, nil] govuk_account_session Value of the session header, if not given just checks if the given email address exists.
59
+ #
60
+ # @return [Hash] One field, "match", indicating whether the session matches the given email address
61
+ def match_user_by_email(email:, govuk_account_session: nil)
62
+ querystring = nested_query_string({ email: email })
63
+ get_json("#{endpoint}/api/user/match-by-email?#{querystring}", auth_headers(govuk_account_session))
64
+ end
65
+
55
66
  # Delete a users account
56
67
  #
57
68
  # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
@@ -62,20 +73,14 @@ class GdsApi::AccountApi < GdsApi::Base
62
73
  # Update the user record with privileged information from the auth service. Only the auth service will call this.
63
74
  #
64
75
  # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
65
- # @param [String, nil] email The user's current
76
+ # @param [String, nil] email The user's current email address
66
77
  # @param [Boolean, nil] email_verified Whether the user's current email address is verified
67
- # @param [Boolean, nil] has_unconfirmed_email Whether the user has a new, pending, email address
68
- # @param [Boolean, nil] cookie_consent Whether the user has consented to analytics cookies
69
- # @param [Boolean, nil] feedback_consent Whether the user has consented to being contacted for feedback
70
78
  #
71
79
  # @return [Hash] The user's subject identifier and email attributes
72
- def update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil, has_unconfirmed_email: nil, cookie_consent: nil, feedback_consent: nil)
80
+ def update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil)
73
81
  params = {
74
82
  email: email,
75
83
  email_verified: email_verified,
76
- has_unconfirmed_email: has_unconfirmed_email,
77
- cookie_consent: cookie_consent,
78
- feedback_consent: feedback_consent,
79
84
  }.compact
80
85
 
81
86
  patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", params)
@@ -138,6 +143,6 @@ private
138
143
  end
139
144
 
140
145
  def auth_headers(govuk_account_session)
141
- { AUTH_HEADER_NAME => govuk_account_session }
146
+ { AUTH_HEADER_NAME => govuk_account_session }.compact
142
147
  end
143
148
  end
@@ -10,8 +10,9 @@ class GdsApi::EmailAlertApi < GdsApi::Base
10
10
  #
11
11
  # @param attributes [Hash] document_type, links, tags used to search existing subscriber lists
12
12
  def find_or_create_subscriber_list(attributes)
13
- if attributes["tags"] && attributes["links"]
14
- message = "please provide either tags or links (or neither), but not both"
13
+ present_fields = [attributes["content_id"], attributes["links"], attributes["tags"]].compact.count
14
+ if present_fields > 1
15
+ message = "please provide content_id, tags, or links (or none), but not more than one of them"
15
16
  raise ArgumentError, message
16
17
  end
17
18
 
@@ -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", cookie_consent: false)
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, feedback_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, cookie_consent: cookie_consent }.to_json,
39
+ body: { govuk_account_session: govuk_account_session, redirect_path: redirect_path, ga_client_id: ga_client_id, cookie_consent: cookie_consent, feedback_consent: feedback_consent }.to_json,
40
40
  )
41
41
  end
42
42
 
@@ -69,7 +69,7 @@ module GdsApi
69
69
  ###############
70
70
  # GET /api/user
71
71
  ###############
72
- def stub_account_api_user_info(id: "user-id", mfa: false, email: "email@example.com", email_verified: true, has_unconfirmed_email: false, services: {}, **options)
72
+ def stub_account_api_user_info(id: "user-id", mfa: false, email: "email@example.com", email_verified: true, services: {}, **options)
73
73
  stub_account_api_request(
74
74
  :get,
75
75
  "/api/user",
@@ -78,7 +78,6 @@ module GdsApi
78
78
  mfa: mfa,
79
79
  email: email,
80
80
  email_verified: email_verified,
81
- has_unconfirmed_email: has_unconfirmed_email,
82
81
  services: services,
83
82
  },
84
83
  **options,
@@ -102,6 +101,41 @@ module GdsApi
102
101
  )
103
102
  end
104
103
 
104
+ ##############################
105
+ # GET /api/user/match-by-email
106
+ ##############################
107
+
108
+ def stub_account_api_match_user_by_email_matches(email:, **options)
109
+ stub_account_api_request(
110
+ :get,
111
+ "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}",
112
+ response_body: {
113
+ match: true,
114
+ },
115
+ **options,
116
+ )
117
+ end
118
+
119
+ def stub_account_api_match_user_by_email_does_not_match(email:, **options)
120
+ stub_account_api_request(
121
+ :get,
122
+ "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}",
123
+ response_body: {
124
+ match: false,
125
+ },
126
+ **options,
127
+ )
128
+ end
129
+
130
+ def stub_account_api_match_user_by_email_does_not_exist(email:, **options)
131
+ stub_account_api_request(
132
+ :get,
133
+ "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}",
134
+ response_status: 404,
135
+ **options,
136
+ )
137
+ end
138
+
105
139
  ############################################
106
140
  # DELETE /api/oidc-users/:subject_identifier
107
141
  ############################################
@@ -125,18 +159,15 @@ module GdsApi
125
159
  ###########################################
126
160
  # PATCH /api/oidc-users/:subject_identifier
127
161
  ###########################################
128
- def stub_update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil, has_unconfirmed_email: nil, cookie_consent: nil, feedback_consent: nil, old_email: nil, old_email_verified: nil, old_has_unconfirmed_email: nil, old_cookie_consent: nil, old_feedback_consent: nil)
162
+ def stub_update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil, old_email: nil, old_email_verified: nil)
129
163
  stub_account_api_request(
130
164
  :patch,
131
165
  "/api/oidc-users/#{subject_identifier}",
132
- with: { body: hash_including({ email: email, email_verified: email_verified, has_unconfirmed_email: has_unconfirmed_email, cookie_consent: cookie_consent, feedback_consent: feedback_consent }.compact) },
166
+ with: { body: hash_including({ email: email, email_verified: email_verified }.compact) },
133
167
  response_body: {
134
168
  sub: subject_identifier,
135
169
  email: email || old_email,
136
170
  email_verified: email_verified || old_email_verified,
137
- has_unconfirmed_email: has_unconfirmed_email || old_has_unconfirmed_email,
138
- cookie_consent: cookie_consent || old_cookie_consent,
139
- feedback_consent: feedback_consent || old_feedback_consent,
140
171
  },
141
172
  )
142
173
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "75.1.0".freeze
2
+ VERSION = "77.0.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: 75.1.0
4
+ version: 77.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-10-14 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable