gds-api-adapters 70.0.0 → 71.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/account_api.rb +81 -3
- data/lib/gds_api/exceptions.rb +4 -3
- data/lib/gds_api/json_client.rb +4 -4
- data/lib/gds_api/link_checker_api.rb +0 -31
- data/lib/gds_api/test_helpers/account_api.rb +340 -47
- data/lib/gds_api/test_helpers/link_checker_api.rb +0 -17
- data/lib/gds_api/version.rb +1 -1
- metadata +3 -7
- data/lib/gds_api/performance_platform/data_in.rb +0 -27
- data/lib/gds_api/performance_platform/data_out.rb +0 -131
- data/lib/gds_api/test_helpers/performance_platform/data_in.rb +0 -45
- data/lib/gds_api/test_helpers/performance_platform/data_out.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1bcd6f2192952444f80e49762cc4d1e2820c767162d194de9ce6c0f1b78ad2c
|
4
|
+
data.tar.gz: cc96d6dc6f18b3ec2a58187977147b8be0bf6025e7a47c4b55671f2ab900c78f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b0911632959b5c61c22ca3c5f208bd69d8cd6db5984fe83c4912251d38f1e895f8a90eda372de721a9f85a59af4931517eb468c3a23d554d9d3a9e4ecd24734
|
7
|
+
data.tar.gz: 1ed0f2a61ed3833a05283684a443ae148324ae22e92daa49e14982af4e908ea5e4f96cda2f74ad20bedae96fdad3d4641fee09c01b958fd63e53190e319b7357
|
data/lib/gds_api/account_api.rb
CHANGED
@@ -12,10 +12,17 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
12
12
|
#
|
13
13
|
# @param [String, nil] redirect_path path on GOV.UK to send the user to after authentication
|
14
14
|
# @param [String, nil] state_id identifier originally returned by #create_registration_state
|
15
|
+
# @param [String, nil] level_of_authentication either "level1" (require MFA) or "level0" (do not require MFA)
|
15
16
|
#
|
16
17
|
# @return [Hash] An authentication URL and the OAuth state parameter (for CSRF protection)
|
17
|
-
def get_sign_in_url(redirect_path: nil, state_id: nil)
|
18
|
-
querystring = nested_query_string(
|
18
|
+
def get_sign_in_url(redirect_path: nil, state_id: nil, level_of_authentication: nil)
|
19
|
+
querystring = nested_query_string(
|
20
|
+
{
|
21
|
+
redirect_path: redirect_path,
|
22
|
+
state_id: state_id,
|
23
|
+
level_of_authentication: level_of_authentication,
|
24
|
+
}.compact,
|
25
|
+
)
|
19
26
|
get_json("#{endpoint}/api/oauth2/sign-in?#{querystring}")
|
20
27
|
end
|
21
28
|
|
@@ -38,6 +45,26 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
38
45
|
post_json("#{endpoint}/api/oauth2/state", attributes: attributes)
|
39
46
|
end
|
40
47
|
|
48
|
+
# Get all the information about a user needed to render the account home page
|
49
|
+
#
|
50
|
+
# @param [String] govuk_account_session Value of the session header
|
51
|
+
#
|
52
|
+
# @return [Hash] Information about the user and the services they've used, and a new session header
|
53
|
+
def get_user(govuk_account_session:)
|
54
|
+
get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
|
55
|
+
end
|
56
|
+
|
57
|
+
# Update the user record with privileged information from the auth service. Only the auth service will call this.
|
58
|
+
#
|
59
|
+
# @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
|
60
|
+
# @param [String, nil] email The new email address
|
61
|
+
# @param [Boolean, nil] email_verified Whether the new email address is verified
|
62
|
+
#
|
63
|
+
# @return [Hash] The user's subject identifier and email attributes
|
64
|
+
def update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil)
|
65
|
+
patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", { email: email, email_verified: email_verified }.compact)
|
66
|
+
end
|
67
|
+
|
41
68
|
# Check if a user has an email subscription for the Transition Checker
|
42
69
|
#
|
43
70
|
# @param [String] govuk_account_session Value of the session header
|
@@ -75,7 +102,58 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
75
102
|
#
|
76
103
|
# @return [Hash] A new session header
|
77
104
|
def set_attributes(attributes:, govuk_account_session:)
|
78
|
-
patch_json("#{endpoint}/api/attributes", { attributes: attributes
|
105
|
+
patch_json("#{endpoint}/api/attributes", { attributes: attributes }, auth_headers(govuk_account_session))
|
106
|
+
end
|
107
|
+
|
108
|
+
# Look up the names of a user's attributes
|
109
|
+
#
|
110
|
+
# @param [String] attributes Names of the attributes to check
|
111
|
+
# @param [String] govuk_account_session Value of the session header
|
112
|
+
#
|
113
|
+
# @return [Hash] The attribute names (if present), and a new session header
|
114
|
+
def get_attributes_names(attributes:, govuk_account_session:)
|
115
|
+
querystring = nested_query_string({ attributes: attributes }.compact)
|
116
|
+
get_json("#{endpoint}/api/attributes/names?#{querystring}", auth_headers(govuk_account_session))
|
117
|
+
end
|
118
|
+
|
119
|
+
# Look up all pages saved by a user in their Account
|
120
|
+
#
|
121
|
+
# @param [String] govuk_account_session Value of the session header
|
122
|
+
#
|
123
|
+
# @return [Hash] containing :saved_pages, an array of single saved page hashes def get_saved_pages(govuk_account_session:)
|
124
|
+
def get_saved_pages(govuk_account_session:)
|
125
|
+
get_json("#{endpoint}/api/saved-pages", auth_headers(govuk_account_session))
|
126
|
+
end
|
127
|
+
|
128
|
+
# Return a single page by unique URL
|
129
|
+
#
|
130
|
+
# @param [String] the path of a page to check
|
131
|
+
# @param [String] govuk_account_session Value of the session header
|
132
|
+
#
|
133
|
+
# @return [Hash] containing :saved_page, a hash of a single saved page value
|
134
|
+
def get_saved_page(page_path:, govuk_account_session:)
|
135
|
+
get_json("#{endpoint}/api/saved-pages/#{CGI.escape(page_path)}", auth_headers(govuk_account_session))
|
136
|
+
end
|
137
|
+
|
138
|
+
# Upsert a single saved page entry in a users account
|
139
|
+
#
|
140
|
+
# @param [String] the path of a page to check
|
141
|
+
# @param [String] govuk_account_session Value of the session header
|
142
|
+
#
|
143
|
+
# @return [Hash] A single saved page value (if sucessful)
|
144
|
+
def save_page(page_path:, govuk_account_session:)
|
145
|
+
put_json("#{endpoint}/api/saved-pages/#{CGI.escape(page_path)}", {}, auth_headers(govuk_account_session))
|
146
|
+
end
|
147
|
+
|
148
|
+
# Delete a single saved page entry from a users account
|
149
|
+
#
|
150
|
+
# @param [String] the path of a page to check
|
151
|
+
# @param [String] govuk_account_session Value of the session header
|
152
|
+
#
|
153
|
+
# @return [GdsApi::Response] A status code of 204 indicates the saved page has been successfully deleted.
|
154
|
+
# A status code of 404 indicates there is no saved page with this path.
|
155
|
+
def delete_saved_page(page_path:, govuk_account_session:)
|
156
|
+
delete_json("#{endpoint}/api/saved-pages/#{CGI.escape(page_path)}", {}, auth_headers(govuk_account_session))
|
79
157
|
end
|
80
158
|
|
81
159
|
private
|
data/lib/gds_api/exceptions.rb
CHANGED
@@ -23,12 +23,13 @@ module GdsApi
|
|
23
23
|
|
24
24
|
# Superclass for all 4XX and 5XX errors
|
25
25
|
class HTTPErrorResponse < BaseError
|
26
|
-
attr_accessor :code, :error_details
|
26
|
+
attr_accessor :code, :error_details, :http_body
|
27
27
|
|
28
|
-
def initialize(code, message = nil, error_details = nil)
|
28
|
+
def initialize(code, message = nil, error_details = nil, http_body = nil)
|
29
29
|
super(message)
|
30
30
|
@code = code
|
31
31
|
@error_details = error_details
|
32
|
+
@http_body = http_body
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -72,7 +73,7 @@ module GdsApi
|
|
72
73
|
def build_specific_http_error(error, url, details = nil)
|
73
74
|
message = "URL: #{url}\nResponse body:\n#{error.http_body}"
|
74
75
|
code = error.http_code
|
75
|
-
error_class_for_code(code).new(code, message, details)
|
76
|
+
error_class_for_code(code).new(code, message, details, error.http_body)
|
76
77
|
end
|
77
78
|
|
78
79
|
def error_class_for_code(code)
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -180,10 +180,10 @@ module GdsApi
|
|
180
180
|
raise GdsApi::EndpointNotFound, "Could not connect to #{url}"
|
181
181
|
rescue RestClient::Exceptions::Timeout => e
|
182
182
|
logger.error loggable.merge(status: "timeout", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
183
|
-
raise GdsApi::TimedOutException
|
183
|
+
raise GdsApi::TimedOutException, e.message
|
184
184
|
rescue URI::InvalidURIError => e
|
185
185
|
logger.error loggable.merge(status: "invalid_uri", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
186
|
-
raise GdsApi::InvalidUrl
|
186
|
+
raise GdsApi::InvalidUrl, e.message
|
187
187
|
rescue RestClient::Exception => e
|
188
188
|
# Log the error here, since we have access to loggable, but raise the
|
189
189
|
# exception up to the calling method to deal with
|
@@ -192,10 +192,10 @@ module GdsApi
|
|
192
192
|
raise
|
193
193
|
rescue Errno::ECONNRESET => e
|
194
194
|
logger.error loggable.merge(status: "connection_reset", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
195
|
-
raise GdsApi::TimedOutException
|
195
|
+
raise GdsApi::TimedOutException, e.message
|
196
196
|
rescue SocketError => e
|
197
197
|
logger.error loggable.merge(status: "socket_error", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
198
|
-
raise GdsApi::SocketErrorException
|
198
|
+
raise GdsApi::SocketErrorException, e.message
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
@@ -89,37 +89,6 @@ class GdsApi::LinkCheckerApi < GdsApi::Base
|
|
89
89
|
)
|
90
90
|
end
|
91
91
|
|
92
|
-
# Update or create a set of links to be monitored for a resource.
|
93
|
-
#
|
94
|
-
# Makes a +POST+ request to the link checker api to create a resource monitor.
|
95
|
-
#
|
96
|
-
# @param links [Array] A list of URIs to monitor.
|
97
|
-
# @param reference [String] A unique id for the resource being monitored
|
98
|
-
# @param app [String] The name of the service the call originated e.g. 'whitehall'
|
99
|
-
# @return [MonitorReport] A +SimpleDelegator+ of the +GdsApi::Response+ which
|
100
|
-
# responds to:
|
101
|
-
# :id the ID of the created resource monitor
|
102
|
-
#
|
103
|
-
# @raise [HTTPErrorResponse] if the request returns an error
|
104
|
-
|
105
|
-
def upsert_resource_monitor(links, app, reference)
|
106
|
-
payload = {
|
107
|
-
links: links,
|
108
|
-
app: app,
|
109
|
-
reference: reference,
|
110
|
-
}
|
111
|
-
|
112
|
-
response = post_json("#{endpoint}/monitor", payload)
|
113
|
-
|
114
|
-
MonitorReport.new(response.to_hash)
|
115
|
-
end
|
116
|
-
|
117
|
-
class MonitorReport < SimpleDelegator
|
118
|
-
def id
|
119
|
-
self["id"]
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
92
|
class LinkReport < SimpleDelegator
|
124
93
|
def uri
|
125
94
|
self["uri"]
|
@@ -5,8 +5,8 @@ module GdsApi
|
|
5
5
|
module AccountApi
|
6
6
|
ACCOUNT_API_ENDPOINT = Plek.find("account-api")
|
7
7
|
|
8
|
-
def stub_account_api_get_sign_in_url(redirect_path: nil, state_id: nil, auth_uri: "http://auth/provider", state: "state")
|
9
|
-
querystring = Rack::Utils.build_nested_query({ redirect_path: redirect_path, state_id: state_id }.compact)
|
8
|
+
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")
|
9
|
+
querystring = Rack::Utils.build_nested_query({ redirect_path: redirect_path, state_id: state_id, level_of_authentication: level_of_authentication }.compact)
|
10
10
|
stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/sign-in?#{querystring}")
|
11
11
|
.to_return(
|
12
12
|
status: 200,
|
@@ -38,63 +38,356 @@ module GdsApi
|
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
def stub_account_api_user_info(level_of_authentication: "level0", email: "email@example.com", email_verified: true, services: {}, **options)
|
42
|
+
stub_account_api_request(
|
43
|
+
:get,
|
44
|
+
"/api/user",
|
45
|
+
response_body: {
|
46
|
+
level_of_authentication: level_of_authentication,
|
47
|
+
email: email,
|
48
|
+
email_verified: email_verified,
|
49
|
+
services: services,
|
50
|
+
},
|
51
|
+
**options,
|
52
|
+
)
|
50
53
|
end
|
51
54
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
.
|
56
|
-
|
57
|
-
|
58
|
-
stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/transition-checker-email-subscription")
|
59
|
-
.to_return(status: 200, body: { govuk_account_session: new_govuk_account_session, has_subscription: false }.compact.to_json)
|
60
|
-
end
|
55
|
+
def stub_account_api_user_info_service_state(service:, service_state: "yes", **options)
|
56
|
+
stub_account_api_user_info(
|
57
|
+
**options.merge(
|
58
|
+
services: options.fetch(:services, {}).merge(service => service_state),
|
59
|
+
),
|
60
|
+
)
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
def stub_account_api_unauthorized_user_info(**options)
|
64
|
+
stub_account_api_request(
|
65
|
+
:get,
|
66
|
+
"/api/user",
|
67
|
+
response_status: 401,
|
68
|
+
**options,
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def stub_update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil, old_email: nil, old_email_verified: nil)
|
73
|
+
stub_account_api_request(
|
74
|
+
:patch,
|
75
|
+
"/api/oidc-users/#{subject_identifier}",
|
76
|
+
with: { body: hash_including({ email: email, email_verified: email_verified }.compact) },
|
77
|
+
response_body: {
|
78
|
+
sub: subject_identifier,
|
79
|
+
email: email || old_email,
|
80
|
+
email_verified: email_verified || old_email_verified,
|
81
|
+
},
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def stub_account_api_has_email_subscription(**options)
|
86
|
+
stub_account_api_request(
|
87
|
+
:get,
|
88
|
+
"/api/transition-checker-email-subscription",
|
89
|
+
response_body: { has_subscription: true },
|
90
|
+
**options,
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def stub_account_api_does_not_have_email_subscription(**options)
|
95
|
+
stub_account_api_request(
|
96
|
+
:get,
|
97
|
+
"/api/transition-checker-email-subscription",
|
98
|
+
response_body: { has_subscription: false },
|
99
|
+
**options,
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def stub_account_api_unauthorized_get_email_subscription(**options)
|
104
|
+
stub_account_api_request(
|
105
|
+
:get,
|
106
|
+
"/api/transition-checker-email-subscription",
|
107
|
+
response_status: 401,
|
108
|
+
**options,
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
def stub_account_api_forbidden_get_email_subscription(needed_level_of_authentication: "level1", **options)
|
113
|
+
stub_account_api_request(
|
114
|
+
:get,
|
115
|
+
"/api/transition-checker-email-subscription",
|
116
|
+
response_status: 403,
|
117
|
+
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
118
|
+
**options,
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
def stub_account_api_set_email_subscription(slug: nil, **options)
|
123
|
+
stub_account_api_request(
|
124
|
+
:post,
|
125
|
+
"/api/transition-checker-email-subscription",
|
126
|
+
with: { body: hash_including({ slug: slug }.compact) },
|
127
|
+
**options,
|
128
|
+
)
|
73
129
|
end
|
74
130
|
|
75
|
-
def
|
131
|
+
def stub_account_api_unauthorized_set_email_subscription(slug: nil, **options)
|
132
|
+
stub_account_api_request(
|
133
|
+
:post,
|
134
|
+
"/api/transition-checker-email-subscription",
|
135
|
+
with: { body: hash_including({ slug: slug }.compact) },
|
136
|
+
response_status: 401,
|
137
|
+
**options,
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
def stub_account_api_forbidden_set_email_subscription(slug: nil, needed_level_of_authentication: "level1", **options)
|
142
|
+
stub_account_api_request(
|
143
|
+
:post,
|
144
|
+
"/api/transition-checker-email-subscription",
|
145
|
+
with: { body: hash_including({ slug: slug }.compact) },
|
146
|
+
response_status: 403,
|
147
|
+
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
148
|
+
**options,
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
def stub_account_api_has_attributes(attributes: [], values: {}, **options)
|
76
153
|
querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
154
|
+
stub_account_api_request(
|
155
|
+
:get,
|
156
|
+
"/api/attributes?#{querystring}",
|
157
|
+
response_body: { values: values },
|
158
|
+
**options,
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
def stub_account_api_unauthorized_has_attributes(attributes: [], **options)
|
163
|
+
querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
|
164
|
+
stub_account_api_request(
|
165
|
+
:get,
|
166
|
+
"/api/attributes?#{querystring}",
|
167
|
+
response_status: 401,
|
168
|
+
**options,
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
def stub_account_api_forbidden_has_attributes(attributes: [], needed_level_of_authentication: "level1", **options)
|
173
|
+
querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
|
174
|
+
stub_account_api_request(
|
175
|
+
:get,
|
176
|
+
"/api/attributes?#{querystring}",
|
177
|
+
response_status: 403,
|
178
|
+
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
179
|
+
**options,
|
180
|
+
)
|
181
|
+
end
|
182
|
+
|
183
|
+
def stub_account_api_set_attributes(attributes: nil, **options)
|
184
|
+
stub_account_api_request(
|
185
|
+
:patch,
|
186
|
+
"/api/attributes",
|
187
|
+
with: { body: hash_including({ attributes: attributes }.compact) },
|
188
|
+
**options,
|
189
|
+
)
|
190
|
+
end
|
191
|
+
|
192
|
+
def stub_account_api_unauthorized_set_attributes(attributes: nil, **options)
|
193
|
+
stub_account_api_request(
|
194
|
+
:patch,
|
195
|
+
"/api/attributes",
|
196
|
+
with: { body: hash_including({ attributes: attributes }.compact) },
|
197
|
+
response_status: 401,
|
198
|
+
**options,
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
def stub_account_api_forbidden_set_attributes(attributes: nil, needed_level_of_authentication: "level1", **options)
|
203
|
+
stub_account_api_request(
|
204
|
+
:patch,
|
205
|
+
"/api/attributes",
|
206
|
+
with: { body: hash_including({ attributes: attributes }.compact) },
|
207
|
+
response_status: 403,
|
208
|
+
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
209
|
+
**options,
|
210
|
+
)
|
85
211
|
end
|
86
212
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
213
|
+
def stub_account_api_get_attributes_names(attributes: [], **options)
|
214
|
+
querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
|
215
|
+
stub_account_api_request(
|
216
|
+
:get,
|
217
|
+
"/api/attributes/names?#{querystring}",
|
218
|
+
response_body: { values: attributes },
|
219
|
+
**options,
|
220
|
+
)
|
221
|
+
end
|
222
|
+
|
223
|
+
def stub_account_api_unauthorized_get_attributes_names(attributes: [], **options)
|
224
|
+
querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
|
225
|
+
stub_account_api_request(
|
226
|
+
:get,
|
227
|
+
"/api/attributes/names?#{querystring}",
|
228
|
+
response_status: 401,
|
229
|
+
**options,
|
230
|
+
)
|
231
|
+
end
|
232
|
+
|
233
|
+
def stub_account_api_forbidden_get_attributes_names(attributes: [], needed_level_of_authentication: "level1", **options)
|
234
|
+
querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact)
|
235
|
+
stub_account_api_request(
|
236
|
+
:get,
|
237
|
+
"/api/attributes/names?#{querystring}",
|
238
|
+
response_status: 403,
|
239
|
+
response_body: { needed_level_of_authentication: needed_level_of_authentication },
|
240
|
+
**options,
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
def stub_account_api_request(method, path, with: {}, response_status: 200, response_body: {}, govuk_account_session: nil, new_govuk_account_session: nil)
|
245
|
+
with.merge!(headers: { GdsApi::AccountApi::AUTH_HEADER_NAME => govuk_account_session }) if govuk_account_session
|
246
|
+
new_govuk_account_session = nil if response_status >= 400
|
247
|
+
to_return = { status: response_status, body: response_body.merge(govuk_account_session: new_govuk_account_session).compact.to_json }
|
248
|
+
if with.empty?
|
249
|
+
stub_request(method, "#{ACCOUNT_API_ENDPOINT}#{path}").to_return(**to_return)
|
92
250
|
else
|
93
|
-
stub_request(
|
94
|
-
.with(body: hash_including({ attributes: attributes&.transform_values(&:to_json) }.compact))
|
95
|
-
.to_return(status: 200, body: { govuk_account_session: new_govuk_account_session }.compact.to_json)
|
251
|
+
stub_request(method, "#{ACCOUNT_API_ENDPOINT}#{path}").with(**with).to_return(**to_return)
|
96
252
|
end
|
97
253
|
end
|
254
|
+
|
255
|
+
######################
|
256
|
+
# GET /api/saved-pages
|
257
|
+
######################
|
258
|
+
def stub_account_api_returning_saved_pages(saved_pages: [], **options)
|
259
|
+
stub_account_api_request(
|
260
|
+
:get,
|
261
|
+
"/api/saved-pages",
|
262
|
+
response_body: { saved_pages: saved_pages },
|
263
|
+
**options,
|
264
|
+
)
|
265
|
+
end
|
266
|
+
|
267
|
+
def stub_account_api_unauthorized_get_saved_pages(**options)
|
268
|
+
stub_account_api_request(
|
269
|
+
:get,
|
270
|
+
"/api/saved-pages",
|
271
|
+
response_status: 401,
|
272
|
+
**options,
|
273
|
+
)
|
274
|
+
end
|
275
|
+
|
276
|
+
#################################
|
277
|
+
# GET /api/saved_pages/:page_path
|
278
|
+
#################################
|
279
|
+
def stub_account_api_get_saved_page(page_path:, content_id: "46163ed2-1777-4ee6-bdd4-6a2007e49d8f", title: "Ministry of Magic", **options)
|
280
|
+
stub_account_api_request(
|
281
|
+
:get,
|
282
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
283
|
+
response_body: {
|
284
|
+
saved_page: {
|
285
|
+
page_path: page_path,
|
286
|
+
content_id: content_id,
|
287
|
+
title: title,
|
288
|
+
},
|
289
|
+
},
|
290
|
+
**options,
|
291
|
+
)
|
292
|
+
end
|
293
|
+
|
294
|
+
def stub_account_api_does_not_have_saved_page(page_path:, **options)
|
295
|
+
stub_account_api_request(
|
296
|
+
:get,
|
297
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
298
|
+
response_status: 404,
|
299
|
+
**options,
|
300
|
+
)
|
301
|
+
end
|
302
|
+
|
303
|
+
def stub_account_api_unauthorized_get_saved_page(page_path:, **options)
|
304
|
+
stub_account_api_request(
|
305
|
+
:get,
|
306
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
307
|
+
response_status: 401,
|
308
|
+
**options,
|
309
|
+
)
|
310
|
+
end
|
311
|
+
|
312
|
+
#################################
|
313
|
+
# PUT /api/saved-pages/:page_path
|
314
|
+
#################################
|
315
|
+
def stub_account_api_save_page(page_path:, content_id: "c840bfa2-011a-42cc-ac7a-a6da990aff0b", title: "Ministry of Magic", **options)
|
316
|
+
stub_account_api_request(
|
317
|
+
:put,
|
318
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
319
|
+
response_body: {
|
320
|
+
saved_page: {
|
321
|
+
page_path: page_path,
|
322
|
+
content_id: content_id,
|
323
|
+
title: title,
|
324
|
+
},
|
325
|
+
},
|
326
|
+
**options,
|
327
|
+
)
|
328
|
+
end
|
329
|
+
|
330
|
+
def stub_account_api_save_page_already_exists(page_path:, **options)
|
331
|
+
stub_account_api_save_page(page_path: page_path, **options)
|
332
|
+
end
|
333
|
+
|
334
|
+
def stub_account_api_save_page_cannot_save_page(page_path:, **options)
|
335
|
+
stub_account_api_request(
|
336
|
+
:put,
|
337
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
338
|
+
response_status: 422,
|
339
|
+
response_body: cannot_save_page_problem_detail({ page_path: page_path }),
|
340
|
+
**options,
|
341
|
+
)
|
342
|
+
end
|
343
|
+
|
344
|
+
def stub_account_api_unauthorized_save_page(page_path:, **options)
|
345
|
+
stub_account_api_request(
|
346
|
+
:put,
|
347
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
348
|
+
response_status: 401,
|
349
|
+
**options,
|
350
|
+
)
|
351
|
+
end
|
352
|
+
|
353
|
+
def cannot_save_page_problem_detail(option = {})
|
354
|
+
{
|
355
|
+
title: "Cannot save page",
|
356
|
+
detail: "Cannot save page with path #{option['page_path']}, check it is not blank, and is a well formatted url path.",
|
357
|
+
type: "https://github.com/alphagov/account-api/blob/main/docs/api.md#cannot-save-page",
|
358
|
+
**option,
|
359
|
+
}
|
360
|
+
end
|
361
|
+
|
362
|
+
####################################
|
363
|
+
# DELETE /api/saved-pages/:page_path
|
364
|
+
####################################
|
365
|
+
def stub_account_api_delete_saved_page(page_path:, **options)
|
366
|
+
stub_account_api_request(
|
367
|
+
:delete,
|
368
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
369
|
+
response_status: 204,
|
370
|
+
**options,
|
371
|
+
)
|
372
|
+
end
|
373
|
+
|
374
|
+
def stub_account_api_delete_saved_page_does_not_exist(page_path:, **options)
|
375
|
+
stub_account_api_request(
|
376
|
+
:delete,
|
377
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
378
|
+
response_status: 404,
|
379
|
+
**options,
|
380
|
+
)
|
381
|
+
end
|
382
|
+
|
383
|
+
def stub_account_api_delete_saved_page_unauthorised(page_path:, **options)
|
384
|
+
stub_account_api_request(
|
385
|
+
:delete,
|
386
|
+
"/api/saved-pages/#{CGI.escape(page_path)}",
|
387
|
+
response_status: 401,
|
388
|
+
**options,
|
389
|
+
)
|
390
|
+
end
|
98
391
|
end
|
99
392
|
end
|
100
393
|
end
|
@@ -72,23 +72,6 @@ module GdsApi
|
|
72
72
|
headers: { "Content-Type" => "application/json" },
|
73
73
|
)
|
74
74
|
end
|
75
|
-
|
76
|
-
def stub_link_checker_api_upsert_resource_monitor(app:, reference:, links:)
|
77
|
-
response_body = { id: 1 }.to_json
|
78
|
-
|
79
|
-
request_body = {
|
80
|
-
links: links,
|
81
|
-
app: app,
|
82
|
-
reference: reference,
|
83
|
-
}.to_json
|
84
|
-
|
85
|
-
stub_request(:post, "#{LINK_CHECKER_API_ENDPOINT}/monitor")
|
86
|
-
.with(body: request_body)
|
87
|
-
.to_return(
|
88
|
-
body: response_body,
|
89
|
-
headers: { "Content-Type" => "application/json" },
|
90
|
-
)
|
91
|
-
end
|
92
75
|
end
|
93
76
|
end
|
94
77
|
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:
|
4
|
+
version: 71.4.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-
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -389,8 +389,6 @@ files:
|
|
389
389
|
- lib/gds_api/maslow.rb
|
390
390
|
- lib/gds_api/middleware/govuk_header_sniffer.rb
|
391
391
|
- lib/gds_api/organisations.rb
|
392
|
-
- lib/gds_api/performance_platform/data_in.rb
|
393
|
-
- lib/gds_api/performance_platform/data_out.rb
|
394
392
|
- lib/gds_api/publishing_api.rb
|
395
393
|
- lib/gds_api/publishing_api/special_route_publisher.rb
|
396
394
|
- lib/gds_api/railtie.rb
|
@@ -413,8 +411,6 @@ files:
|
|
413
411
|
- lib/gds_api/test_helpers/local_links_manager.rb
|
414
412
|
- lib/gds_api/test_helpers/mapit.rb
|
415
413
|
- lib/gds_api/test_helpers/organisations.rb
|
416
|
-
- lib/gds_api/test_helpers/performance_platform/data_in.rb
|
417
|
-
- lib/gds_api/test_helpers/performance_platform/data_out.rb
|
418
414
|
- lib/gds_api/test_helpers/publishing_api.rb
|
419
415
|
- lib/gds_api/test_helpers/router.rb
|
420
416
|
- lib/gds_api/test_helpers/search.rb
|
@@ -449,7 +445,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
449
445
|
- !ruby/object:Gem::Version
|
450
446
|
version: '0'
|
451
447
|
requirements: []
|
452
|
-
rubygems_version: 3.
|
448
|
+
rubygems_version: 3.0.3
|
453
449
|
signing_key:
|
454
450
|
specification_version: 4
|
455
451
|
summary: Adapters to work with GDS APIs
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module GdsApi
|
4
|
-
class PerformancePlatformDatasetNotConfigured < BaseError; end
|
5
|
-
|
6
|
-
module PerformancePlatform
|
7
|
-
class DataIn < GdsApi::Base
|
8
|
-
def submit_service_feedback_day_aggregate(slug, request_details)
|
9
|
-
post_json("#{endpoint}/data/#{slug}/customer-satisfaction", request_details)
|
10
|
-
rescue GdsApi::HTTPNotFound
|
11
|
-
raise PerformancePlatformDatasetNotConfigured, "Dataset for slug [#{slug}] not set up"
|
12
|
-
end
|
13
|
-
|
14
|
-
def corporate_content_problem_report_count(entries)
|
15
|
-
post_json("#{endpoint}/data/gov-uk-content/feedback-count", entries)
|
16
|
-
end
|
17
|
-
|
18
|
-
def corporate_content_urls_with_the_most_problem_reports(entries)
|
19
|
-
post_json("#{endpoint}/data/gov-uk-content/top-urls", entries)
|
20
|
-
end
|
21
|
-
|
22
|
-
def submit_problem_report_daily_totals(entries)
|
23
|
-
post_json("#{endpoint}/data/govuk-info/page-contacts", entries)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module GdsApi
|
4
|
-
module PerformancePlatform
|
5
|
-
class DataOut < GdsApi::Base
|
6
|
-
# Fetch all service feedback from the performance platform for a given transaction
|
7
|
-
# page slug.
|
8
|
-
#
|
9
|
-
# Makes a +GET+ request.
|
10
|
-
#
|
11
|
-
# The results are ordered date ascending.
|
12
|
-
#
|
13
|
-
# @param transaction_page_slug [String] The slug for which service feedback is
|
14
|
-
# needed.
|
15
|
-
#
|
16
|
-
# # @example
|
17
|
-
#
|
18
|
-
# performance_platform_data_out.service_feedback('register-to-vote')
|
19
|
-
#
|
20
|
-
# #=> {
|
21
|
-
# "data": [
|
22
|
-
# {
|
23
|
-
# "_day_start_at": "2014-06-10T00:00:00+00:00",
|
24
|
-
# "_hour_start_at": "2014-06-10T00:00:00+00:00",
|
25
|
-
# "_id": "20140610_register-to-vote",
|
26
|
-
# "_month_start_at": "2014-06-01T00:00:00+00:00",
|
27
|
-
# "_quarter_start_at": "2014-04-01T00:00:00+00:00",
|
28
|
-
# "_timestamp": "2014-06-10T00:00:00+00:00",
|
29
|
-
# "_updated_at": "2014-06-11T00:30:50.901000+00:00",
|
30
|
-
# "_week_start_at": "2014-06-09T00:00:00+00:00",
|
31
|
-
# "comments": 217,
|
32
|
-
# "period": "day",
|
33
|
-
# "rating_1": 4,
|
34
|
-
# "rating_2": 6,
|
35
|
-
# "rating_3": 7,
|
36
|
-
# "rating_4": 74,
|
37
|
-
# "rating_5": 574,
|
38
|
-
# "slug": "register-to-vote",
|
39
|
-
# "total": 665
|
40
|
-
# },
|
41
|
-
# ...
|
42
|
-
# }
|
43
|
-
def service_feedback(transaction_page_slug)
|
44
|
-
get_json("#{endpoint}/data/#{transaction_page_slug}/customer-satisfaction")
|
45
|
-
end
|
46
|
-
|
47
|
-
# Fetching statistics data from the performance platform for a given page slug
|
48
|
-
#
|
49
|
-
# Makes a +GET+ request.
|
50
|
-
#
|
51
|
-
# @param slug [String] Points to the page for which we are requesting
|
52
|
-
# statistics.
|
53
|
-
# @param is_multipart [Boolean] Flag that marks whether the slug is multipart
|
54
|
-
# or not:
|
55
|
-
#
|
56
|
-
# - simple: `/european-health-insurance-card`
|
57
|
-
# - multipart: `/european-health-insurance-card/123`
|
58
|
-
#
|
59
|
-
# # @examples
|
60
|
-
#
|
61
|
-
# 1. Without multipart filtering:
|
62
|
-
#
|
63
|
-
# performance_platform_data_out.search_terms('/european-health-insurance-card')
|
64
|
-
#
|
65
|
-
# 2. With multipart filtering:
|
66
|
-
#
|
67
|
-
# performance_platform_data_out.searches('/european-health-insurance-card', true)
|
68
|
-
# performance_platform_data_out.page_views('/european-health-insurance-card', true)
|
69
|
-
# performance_platform_data_out.problem_reports('/european-health-insurance-card', true)
|
70
|
-
|
71
|
-
def search_terms(slug)
|
72
|
-
options = {
|
73
|
-
slug: slug,
|
74
|
-
transaction: "search-terms",
|
75
|
-
group_by: "searchKeyword",
|
76
|
-
collect: "searchUniques:sum",
|
77
|
-
}
|
78
|
-
statistics(options)
|
79
|
-
end
|
80
|
-
|
81
|
-
def searches(slug, is_multipart)
|
82
|
-
options = {
|
83
|
-
slug: slug,
|
84
|
-
transaction: "search-terms",
|
85
|
-
group_by: "pagePath",
|
86
|
-
collect: "searchUniques:sum",
|
87
|
-
}
|
88
|
-
statistics(options, is_multipart)
|
89
|
-
end
|
90
|
-
|
91
|
-
def page_views(slug, is_multipart)
|
92
|
-
options = {
|
93
|
-
slug: slug,
|
94
|
-
transaction: "page-statistics",
|
95
|
-
group_by: "pagePath",
|
96
|
-
collect: "uniquePageviews:sum",
|
97
|
-
}
|
98
|
-
statistics(options, is_multipart)
|
99
|
-
end
|
100
|
-
|
101
|
-
def problem_reports(slug, is_multipart)
|
102
|
-
options = {
|
103
|
-
slug: slug,
|
104
|
-
transaction: "page-contacts",
|
105
|
-
group_by: "pagePath",
|
106
|
-
collect: "total:sum",
|
107
|
-
}
|
108
|
-
statistics(options, is_multipart)
|
109
|
-
end
|
110
|
-
|
111
|
-
# This can be used as a free form call to the performance platform.
|
112
|
-
# The performance platform uses Backdrop and its query language for
|
113
|
-
# storing and querying data.
|
114
|
-
# Backdrop can be found here: https://github.com/alphagov/backdrop
|
115
|
-
def statistics(options, is_multipart = false) # rubocop:disable Style/OptionalBooleanParameter
|
116
|
-
params = {
|
117
|
-
group_by: options[:group_by],
|
118
|
-
collect: options[:collect],
|
119
|
-
duration: 42,
|
120
|
-
period: "day",
|
121
|
-
end_at: Date.today.to_time.getutc.iso8601,
|
122
|
-
}
|
123
|
-
|
124
|
-
filter_param = is_multipart ? :filter_by_prefix : :filter_by
|
125
|
-
params[filter_param] = "pagePath:#{options[:slug]}"
|
126
|
-
|
127
|
-
get_json("#{endpoint}/data/govuk-info/#{options[:transaction]}#{query_string(params)}")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module GdsApi
|
2
|
-
module TestHelpers
|
3
|
-
module PerformancePlatform
|
4
|
-
module DataIn
|
5
|
-
PP_DATA_IN_ENDPOINT = "http://www.performance.dev.gov.uk".freeze
|
6
|
-
|
7
|
-
def stub_service_feedback_day_aggregate_submission(slug, request_body = nil)
|
8
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
9
|
-
post_stub.with(body: request_body) unless request_body.nil?
|
10
|
-
post_stub.to_return(status: 200)
|
11
|
-
end
|
12
|
-
|
13
|
-
def stub_corporate_content_problem_report_count_submission(submissions = nil)
|
14
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/gov-uk-content/feedback-count")
|
15
|
-
post_stub.with(body: submissions.to_json) unless submissions.nil?
|
16
|
-
post_stub.to_return(status: 200)
|
17
|
-
end
|
18
|
-
|
19
|
-
def stub_corporate_content_urls_with_the_most_problem_reports_submission(submissions = nil)
|
20
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/gov-uk-content/top-urls")
|
21
|
-
post_stub.with(body: submissions.to_json) unless submissions.nil?
|
22
|
-
post_stub.to_return(status: 200)
|
23
|
-
end
|
24
|
-
|
25
|
-
def stub_problem_report_daily_totals_submission(submissions = nil)
|
26
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/govuk-info/page-contacts")
|
27
|
-
post_stub.with(body: submissions.to_json) unless submissions.nil?
|
28
|
-
post_stub.to_return(status: 200)
|
29
|
-
end
|
30
|
-
|
31
|
-
def stub_service_feedback_bucket_unavailable_for(slug)
|
32
|
-
stub_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/#{slug}/customer-satisfaction").to_return(status: 404)
|
33
|
-
end
|
34
|
-
|
35
|
-
def stub_pp_isnt_available
|
36
|
-
stub_request(:post, /#{PP_DATA_IN_ENDPOINT}\/.*/).to_return(status: 503)
|
37
|
-
end
|
38
|
-
|
39
|
-
def stub_pp_dataset_unavailable
|
40
|
-
stub_request(:any, /#{PP_DATA_IN_ENDPOINT}/).to_return(status: 404)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module GdsApi
|
2
|
-
module TestHelpers
|
3
|
-
module PerformancePlatform
|
4
|
-
module DataOut
|
5
|
-
PP_DATA_OUT_ENDPOINT = "https://www.performance.service.gov.uk".freeze
|
6
|
-
|
7
|
-
def stub_service_feedback(slug, response_body = {})
|
8
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
9
|
-
.to_return(status: 200, body: response_body.to_json)
|
10
|
-
end
|
11
|
-
|
12
|
-
def stub_data_set_not_available(slug)
|
13
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
14
|
-
.to_return(status: 404)
|
15
|
-
end
|
16
|
-
|
17
|
-
def stub_service_not_available
|
18
|
-
stub_request(:any, /#{PP_DATA_OUT_ENDPOINT}\/.*/).to_return(status: 503)
|
19
|
-
end
|
20
|
-
|
21
|
-
def stub_search_terms(slug, response_body = {})
|
22
|
-
options = {
|
23
|
-
slug: slug,
|
24
|
-
transaction: "search-terms",
|
25
|
-
group_by: "searchKeyword",
|
26
|
-
collect: "searchUniques:sum",
|
27
|
-
}
|
28
|
-
stub_statistics(options, false, response_body)
|
29
|
-
end
|
30
|
-
|
31
|
-
def stub_searches(slug, is_multipart, response_body = {})
|
32
|
-
options = {
|
33
|
-
slug: slug,
|
34
|
-
transaction: "search-terms",
|
35
|
-
group_by: "pagePath",
|
36
|
-
collect: "searchUniques:sum",
|
37
|
-
}
|
38
|
-
stub_statistics(options, is_multipart, response_body)
|
39
|
-
end
|
40
|
-
|
41
|
-
def stub_page_views(slug, is_multipart, response_body = {})
|
42
|
-
options = {
|
43
|
-
slug: slug,
|
44
|
-
transaction: "page-statistics",
|
45
|
-
group_by: "pagePath",
|
46
|
-
collect: "uniquePageviews:sum",
|
47
|
-
}
|
48
|
-
stub_statistics(options, is_multipart, response_body)
|
49
|
-
end
|
50
|
-
|
51
|
-
def stub_problem_reports(slug, is_multipart, response_body = {})
|
52
|
-
options = {
|
53
|
-
slug: slug,
|
54
|
-
transaction: "page-contacts",
|
55
|
-
group_by: "pagePath",
|
56
|
-
collect: "total:sum",
|
57
|
-
}
|
58
|
-
stub_statistics(options, is_multipart, response_body)
|
59
|
-
end
|
60
|
-
|
61
|
-
def stub_statistics(options, is_multipart, response_body = {})
|
62
|
-
params = {
|
63
|
-
group_by: options[:group_by],
|
64
|
-
collect: options[:collect],
|
65
|
-
duration: 42,
|
66
|
-
period: "day",
|
67
|
-
end_at: Date.today.to_time.getutc.iso8601,
|
68
|
-
}
|
69
|
-
|
70
|
-
filter_param = is_multipart ? :filter_by_prefix : :filter_by
|
71
|
-
params[filter_param] = "pagePath:#{options[:slug]}"
|
72
|
-
|
73
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/#{options[:transaction]}")
|
74
|
-
.with(query: params)
|
75
|
-
.to_return(status: 200, body: response_body.to_json)
|
76
|
-
end
|
77
|
-
|
78
|
-
def stub_search_404(slug)
|
79
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms")
|
80
|
-
.with(query: hash_including(filter_by: slug))
|
81
|
-
.to_return(status: 404, headers: { content_type: "application/json" })
|
82
|
-
end
|
83
|
-
|
84
|
-
def stub_page_views_404(slug)
|
85
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics")
|
86
|
-
.with(query: hash_including(filter_by: slug))
|
87
|
-
.to_return(status: 404, headers: { content_type: "application/json" })
|
88
|
-
end
|
89
|
-
|
90
|
-
def stub_problem_reports_404(slug)
|
91
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts")
|
92
|
-
.with(query: hash_including(filter_by: slug))
|
93
|
-
.to_return(status: 404, headers: { content_type: "application/json" })
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|