gds-api-adapters 63.5.1 → 67.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -23
- data/Rakefile +7 -8
- data/lib/gds_api.rb +2 -14
- data/lib/gds_api/asset_manager.rb +1 -1
- data/lib/gds_api/base.rb +8 -3
- data/lib/gds_api/email_alert_api.rb +10 -12
- data/lib/gds_api/exceptions.rb +3 -4
- data/lib/gds_api/imminence.rb +3 -3
- data/lib/gds_api/json_client.rb +8 -8
- data/lib/gds_api/list_response.rb +6 -6
- data/lib/gds_api/performance_platform/data_out.rb +21 -21
- data/lib/gds_api/publishing_api.rb +2 -2
- data/lib/gds_api/response.rb +80 -6
- data/lib/gds_api/test_helpers/asset_manager.rb +0 -17
- data/lib/gds_api/test_helpers/calendars.rb +0 -9
- data/lib/gds_api/test_helpers/content_store.rb +0 -9
- data/lib/gds_api/test_helpers/email_alert_api.rb +11 -35
- data/lib/gds_api/test_helpers/imminence.rb +11 -14
- data/lib/gds_api/test_helpers/licence_application.rb +8 -16
- data/lib/gds_api/test_helpers/link_checker_api.rb +0 -8
- data/lib/gds_api/test_helpers/local_links_manager.rb +0 -13
- data/lib/gds_api/test_helpers/mapit.rb +15 -26
- data/lib/gds_api/test_helpers/organisations.rb +13 -18
- data/lib/gds_api/test_helpers/performance_platform/data_out.rb +34 -34
- data/lib/gds_api/test_helpers/publishing_api.rb +42 -61
- data/lib/gds_api/test_helpers/search.rb +5 -5
- data/lib/gds_api/test_helpers/support.rb +0 -5
- data/lib/gds_api/test_helpers/support_api.rb +16 -20
- data/lib/gds_api/test_helpers/worldwide.rb +51 -31
- data/lib/gds_api/version.rb +1 -1
- metadata +15 -32
- data/lib/gds_api/publishing_api_v2.rb +0 -14
- data/lib/gds_api/test_helpers/alias_deprecated.rb +0 -13
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +0 -13
@@ -381,7 +381,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
381
381
|
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2linkables
|
382
382
|
def get_linkables(document_type: nil)
|
383
383
|
if document_type.nil?
|
384
|
-
raise ArgumentError
|
384
|
+
raise ArgumentError, "Please provide a `document_type`"
|
385
385
|
end
|
386
386
|
|
387
387
|
get_json("#{endpoint}/v2/linkables?document_type=#{document_type}")
|
@@ -486,7 +486,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
486
486
|
# publishing_app: 'content-publisher',
|
487
487
|
# rendering_app: 'government-frontend',
|
488
488
|
# }
|
489
|
-
#)
|
489
|
+
# )
|
490
490
|
#
|
491
491
|
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#put-publish-intentbase_path
|
492
492
|
def put_intent(base_path, payload)
|
data/lib/gds_api/response.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "json"
|
2
2
|
require "forwardable"
|
3
|
-
require "rack/cache"
|
4
3
|
|
5
4
|
module GdsApi
|
6
5
|
# This wraps an HTTP response with a JSON body.
|
@@ -21,6 +20,77 @@ module GdsApi
|
|
21
20
|
extend Forwardable
|
22
21
|
include Enumerable
|
23
22
|
|
23
|
+
class CacheControl < Hash
|
24
|
+
PATTERN = /([-a-z]+)(?:\s*=\s*([^,\s]+))?,?+/i.freeze
|
25
|
+
|
26
|
+
def initialize(value = nil)
|
27
|
+
parse(value)
|
28
|
+
end
|
29
|
+
|
30
|
+
def public?
|
31
|
+
self["public"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def private?
|
35
|
+
self["private"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def no_cache?
|
39
|
+
self["no-cache"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def no_store?
|
43
|
+
self["no-store"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def must_revalidate?
|
47
|
+
self["must-revalidate"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def proxy_revalidate?
|
51
|
+
self["proxy-revalidate"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def max_age
|
55
|
+
self["max-age"].to_i if key?("max-age")
|
56
|
+
end
|
57
|
+
|
58
|
+
def reverse_max_age
|
59
|
+
self["r-maxage"].to_i if key?("r-maxage")
|
60
|
+
end
|
61
|
+
alias_method :r_maxage, :reverse_max_age
|
62
|
+
|
63
|
+
def shared_max_age
|
64
|
+
self["s-maxage"].to_i if key?("r-maxage")
|
65
|
+
end
|
66
|
+
alias_method :s_maxage, :shared_max_age
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
directives = []
|
70
|
+
values = []
|
71
|
+
|
72
|
+
each do |key, value|
|
73
|
+
if value == true
|
74
|
+
directives << key
|
75
|
+
elsif value
|
76
|
+
values << "#{key}=#{value}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
(directives.sort + values.sort).join(", ")
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def parse(header)
|
86
|
+
return if header.nil? || header.empty?
|
87
|
+
|
88
|
+
header.scan(PATTERN).each do |name, value|
|
89
|
+
self[name.downcase] = value || true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
24
94
|
def_delegators :to_hash, :[], :"<=>", :each, :dig
|
25
95
|
|
26
96
|
def initialize(http_response, options = {})
|
@@ -63,7 +133,7 @@ module GdsApi
|
|
63
133
|
end
|
64
134
|
|
65
135
|
def cache_control
|
66
|
-
@cache_control ||=
|
136
|
+
@cache_control ||= CacheControl.new(headers[:cache_control])
|
67
137
|
end
|
68
138
|
|
69
139
|
def to_hash
|
@@ -74,9 +144,13 @@ module GdsApi
|
|
74
144
|
@parsed_content ||= transform_parsed(JSON.parse(@http_response.body))
|
75
145
|
end
|
76
146
|
|
77
|
-
def present
|
147
|
+
def present?
|
148
|
+
true
|
149
|
+
end
|
78
150
|
|
79
|
-
def blank
|
151
|
+
def blank?
|
152
|
+
false
|
153
|
+
end
|
80
154
|
|
81
155
|
private
|
82
156
|
|
@@ -85,7 +159,7 @@ module GdsApi
|
|
85
159
|
|
86
160
|
case value
|
87
161
|
when Hash
|
88
|
-
Hash[value.map
|
162
|
+
Hash[value.map do |k, v|
|
89
163
|
# NOTE: Don't bother transforming if the value is nil
|
90
164
|
if k == "web_url" && v
|
91
165
|
# Use relative URLs to route when the web_url value is on the
|
@@ -98,7 +172,7 @@ module GdsApi
|
|
98
172
|
else
|
99
173
|
[k, transform_parsed(v)]
|
100
174
|
end
|
101
|
-
|
175
|
+
end]
|
102
176
|
when Array
|
103
177
|
value.map { |v| transform_parsed(v) }
|
104
178
|
else
|
@@ -1,10 +1,6 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
|
-
|
3
1
|
module GdsApi
|
4
2
|
module TestHelpers
|
5
3
|
module AssetManager
|
6
|
-
extend AliasDeprecated
|
7
|
-
|
8
4
|
ASSET_MANAGER_ENDPOINT = Plek.current.find("asset-manager")
|
9
5
|
|
10
6
|
def stub_any_asset_manager_call
|
@@ -107,19 +103,6 @@ module GdsApi
|
|
107
103
|
def stub_asset_manager_delete_asset_failure(asset_id)
|
108
104
|
stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 500)
|
109
105
|
end
|
110
|
-
|
111
|
-
alias_deprecated :asset_manager_updates_any_asset, :stub_asset_manager_updates_any_asset
|
112
|
-
alias_deprecated :asset_manager_deletes_any_asset, :stub_asset_manager_deletes_any_asset
|
113
|
-
alias_deprecated :asset_manager_has_an_asset, :stub_asset_manager_has_an_asset
|
114
|
-
alias_deprecated :asset_manager_has_a_whitehall_asset, :stub_asset_manager_has_a_whitehall_asset
|
115
|
-
alias_deprecated :asset_manager_does_not_have_an_asset, :stub_asset_manager_does_not_have_an_asset
|
116
|
-
alias_deprecated :asset_manager_does_not_have_a_whitehall_asset, :stub_asset_manager_does_not_have_a_whitehall_asset
|
117
|
-
alias_deprecated :asset_manager_receives_an_asset, :stub_asset_manager_receives_an_asset
|
118
|
-
alias_deprecated :asset_manager_upload_failure, :stub_asset_manager_upload_failure
|
119
|
-
alias_deprecated :asset_manager_update_asset, :stub_asset_manager_update_asset
|
120
|
-
alias_deprecated :asset_manager_update_failure, :stub_asset_manager_update_asset_failure
|
121
|
-
alias_deprecated :asset_manager_delete_asset, :stub_asset_manager_delete_asset
|
122
|
-
alias_deprecated :asset_manager_delete_failure, :stub_asset_manager_delete_asset_failure
|
123
106
|
end
|
124
107
|
end
|
125
108
|
end
|
@@ -1,10 +1,6 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
|
-
|
3
1
|
module GdsApi
|
4
2
|
module TestHelpers
|
5
3
|
module Calendars
|
6
|
-
extend AliasDeprecated
|
7
|
-
|
8
4
|
def calendars_endpoint(in_division: nil)
|
9
5
|
endpoint = "#{Plek.new.website_root}/bank-holidays"
|
10
6
|
endpoint += "/#{in_division}" unless in_division.nil?
|
@@ -55,11 +51,6 @@ module GdsApi
|
|
55
51
|
def stub_calendars_has_a_bank_holiday_on(date, in_division: nil)
|
56
52
|
stub_calendars_has_bank_holidays_on([date], in_division: in_division)
|
57
53
|
end
|
58
|
-
|
59
|
-
# Aliases for DEPRECATED methods
|
60
|
-
alias_deprecated :calendars_has_no_bank_holidays, :stub_calendars_has_no_bank_holidays
|
61
|
-
alias_deprecated :calendars_has_bank_holidays_on, :stub_calendars_has_bank_holidays_on
|
62
|
-
alias_deprecated :calendars_has_a_bank_holiday_on, :stub_calendars_has_a_bank_holiday_on
|
63
54
|
end
|
64
55
|
end
|
65
56
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
require "gds_api/test_helpers/content_item_helpers"
|
4
3
|
require "json"
|
@@ -6,7 +5,6 @@ require "json"
|
|
6
5
|
module GdsApi
|
7
6
|
module TestHelpers
|
8
7
|
module ContentStore
|
9
|
-
extend AliasDeprecated
|
10
8
|
include ContentItemHelpers
|
11
9
|
|
12
10
|
def content_store_endpoint(draft = false)
|
@@ -93,13 +91,6 @@ module GdsApi
|
|
93
91
|
|
94
92
|
stub_request(:get, url).to_return(body: body)
|
95
93
|
end
|
96
|
-
|
97
|
-
# Aliases for DEPRECATED methods
|
98
|
-
alias_deprecated :content_store_has_item, :stub_content_store_has_item
|
99
|
-
alias_deprecated :content_store_does_not_have_item, :stub_content_store_does_not_have_item
|
100
|
-
alias_deprecated :content_store_has_gone_item, :stub_content_store_has_gone_item
|
101
|
-
alias_deprecated :content_store_isnt_available, :stub_content_store_isnt_available
|
102
|
-
alias_deprecated :content_store_has_incoming_links, :stub_content_store_has_incoming_links
|
103
94
|
end
|
104
95
|
end
|
105
96
|
end
|
@@ -83,12 +83,12 @@ module GdsApi
|
|
83
83
|
# stub_email_alert_api_has_subscriptions([
|
84
84
|
# {
|
85
85
|
# id: 'id-of-my-subscriber-list',
|
86
|
-
#
|
86
|
+
# frequency: 'weekly',
|
87
87
|
# ended: true,
|
88
88
|
# },
|
89
89
|
# {
|
90
90
|
# id: 'id-of-my-subscriber-list',
|
91
|
-
#
|
91
|
+
# frequency: 'daily',
|
92
92
|
# },
|
93
93
|
# ])
|
94
94
|
#
|
@@ -98,9 +98,9 @@ module GdsApi
|
|
98
98
|
subscriptions.each do |id, params|
|
99
99
|
latest_id, latest_params = get_latest_matching(params, subscriptions)
|
100
100
|
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}")
|
101
|
-
.to_return(status: 200, body: get_subscription_response(id, params).to_json)
|
101
|
+
.to_return(status: 200, body: get_subscription_response(id, **params).to_json)
|
102
102
|
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}/latest")
|
103
|
-
.to_return(status: 200, body: get_subscription_response(latest_id, latest_params).to_json)
|
103
|
+
.to_return(status: 200, body: get_subscription_response(latest_id, **latest_params).to_json)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -176,7 +176,7 @@ module GdsApi
|
|
176
176
|
|
177
177
|
def assert_email_alert_api_content_change_created(attributes = nil)
|
178
178
|
if attributes
|
179
|
-
matcher =
|
179
|
+
matcher = lambda do |request|
|
180
180
|
payload = JSON.parse(request.body)
|
181
181
|
payload.select { |k, _| attributes.key?(k) } == attributes
|
182
182
|
end
|
@@ -187,7 +187,7 @@ module GdsApi
|
|
187
187
|
|
188
188
|
def assert_email_alert_api_message_created(attributes = nil)
|
189
189
|
if attributes
|
190
|
-
matcher =
|
190
|
+
matcher = lambda do |request|
|
191
191
|
payload = JSON.parse(request.body)
|
192
192
|
payload.select { |k, _| attributes.key?(k) } == attributes
|
193
193
|
end
|
@@ -222,21 +222,21 @@ module GdsApi
|
|
222
222
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
223
223
|
.with(
|
224
224
|
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
|
225
|
-
|
225
|
+
).to_return(status: 201, body: { id: returned_subscription_id }.to_json)
|
226
226
|
end
|
227
227
|
|
228
228
|
def stub_email_alert_api_creates_an_existing_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
|
229
229
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
230
230
|
.with(
|
231
231
|
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
|
232
|
-
|
232
|
+
).to_return(status: 200, body: { id: returned_subscription_id }.to_json)
|
233
233
|
end
|
234
234
|
|
235
235
|
def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, address, frequency)
|
236
236
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
237
237
|
.with(
|
238
238
|
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
|
239
|
-
|
239
|
+
).to_return(status: 422)
|
240
240
|
end
|
241
241
|
|
242
242
|
def stub_email_alert_api_sends_subscription_verification_email(address, frequency, topic_id)
|
@@ -292,7 +292,7 @@ module GdsApi
|
|
292
292
|
body: {
|
293
293
|
subscriber_list: returned_attributes,
|
294
294
|
}.to_json,
|
295
|
-
|
295
|
+
)
|
296
296
|
end
|
297
297
|
|
298
298
|
def stub_email_alert_api_does_not_have_subscriber_list_by_slug(slug:)
|
@@ -300,30 +300,6 @@ module GdsApi
|
|
300
300
|
.to_return(status: 404)
|
301
301
|
end
|
302
302
|
|
303
|
-
# Aliases for DEPRECATED methods
|
304
|
-
alias_method :email_alert_api_has_updated_subscriber, :stub_email_alert_api_has_updated_subscriber
|
305
|
-
alias_method :email_alert_api_does_not_have_updated_subscriber, :stub_email_alert_api_does_not_have_updated_subscriber
|
306
|
-
alias_method :email_alert_api_has_updated_subscription, :stub_email_alert_api_has_updated_subscription
|
307
|
-
alias_method :email_alert_api_does_not_have_updated_subscription, :stub_email_alert_api_does_not_have_updated_subscription
|
308
|
-
alias_method :email_alert_api_has_subscriber_subscriptions, :stub_email_alert_api_has_subscriber_subscriptions
|
309
|
-
alias_method :email_alert_api_does_not_have_subscriber_subscriptions, :stub_email_alert_api_does_not_have_subscriber_subscriptions
|
310
|
-
alias_method :email_alert_api_has_subscription, :stub_email_alert_api_has_subscription
|
311
|
-
alias_method :email_alert_api_has_subscriptions, :stub_email_alert_api_has_subscriptions
|
312
|
-
alias_method :email_alert_api_has_subscriber_list, :stub_email_alert_api_has_subscriber_list
|
313
|
-
alias_method :email_alert_api_does_not_have_subscriber_list, :stub_email_alert_api_does_not_have_subscriber_list
|
314
|
-
alias_method :email_alert_api_creates_subscriber_list, :stub_email_alert_api_creates_subscriber_list
|
315
|
-
alias_method :email_alert_api_refuses_to_create_subscriber_list, :stub_email_alert_api_refuses_to_create_subscriber_list
|
316
|
-
alias_method :email_alert_api_accepts_unpublishing_message, :stub_email_alert_api_accepts_unpublishing_message
|
317
|
-
alias_method :email_alert_api_unsubscribes_a_subscription, :stub_email_alert_api_unsubscribes_a_subscription
|
318
|
-
alias_method :email_alert_api_has_no_subscription_for_uuid, :stub_email_alert_api_has_no_subscription_for_uuid
|
319
|
-
alias_method :email_alert_api_unsubscribes_a_subscriber, :stub_email_alert_api_unsubscribes_a_subscriber
|
320
|
-
alias_method :email_alert_api_has_no_subscriber, :stub_email_alert_api_has_no_subscriber
|
321
|
-
alias_method :email_alert_api_creates_a_subscription, :stub_email_alert_api_creates_a_subscription
|
322
|
-
alias_method :email_alert_api_creates_an_existing_subscription, :stub_email_alert_api_creates_an_existing_subscription
|
323
|
-
alias_method :email_alert_api_refuses_to_create_subscription, :stub_email_alert_api_refuses_to_create_subscription
|
324
|
-
alias_method :email_alert_api_has_subscriber_list_by_slug, :stub_email_alert_api_has_subscriber_list_by_slug
|
325
|
-
alias_method :email_alert_api_does_not_have_subscriber_list_by_slug, :stub_email_alert_api_does_not_have_subscriber_list_by_slug
|
326
|
-
|
327
303
|
private
|
328
304
|
|
329
305
|
def get_subscriber_response(id, address)
|
@@ -348,7 +324,7 @@ module GdsApi
|
|
348
324
|
"id" => id,
|
349
325
|
"frequency" => frequency,
|
350
326
|
"source" => "user_signed_up",
|
351
|
-
"ended_at" => ended ? Time.now.
|
327
|
+
"ended_at" => ended ? Time.now.iso8601 : nil,
|
352
328
|
"ended_reason" => ended ? "unsubscribed" : nil,
|
353
329
|
"subscriber" => {
|
354
330
|
"id" => subscriber_id,
|
@@ -1,11 +1,8 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module Imminence
|
7
|
-
extend AliasDeprecated
|
8
|
-
|
9
6
|
# Generally true. If you are initializing the client differently,
|
10
7
|
# you could redefine/override the constant or stub directly.
|
11
8
|
IMMINENCE_API_ENDPOINT = Plek.current.find("imminence")
|
@@ -18,12 +15,16 @@ module GdsApi
|
|
18
15
|
def stub_imminence_has_areas_for_postcode(postcode, areas)
|
19
16
|
results = {
|
20
17
|
"_response_info" => { "status" => "ok" },
|
21
|
-
"total" => areas.size,
|
22
|
-
"
|
18
|
+
"total" => areas.size,
|
19
|
+
"startIndex" => 1,
|
20
|
+
"pageSize" => areas.size,
|
21
|
+
"currentPage" => 1,
|
22
|
+
"pages" => 1,
|
23
|
+
"results" => areas,
|
23
24
|
}
|
24
25
|
|
25
|
-
stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json})
|
26
|
-
to_return(body: results.to_json)
|
26
|
+
stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json})
|
27
|
+
.to_return(body: results.to_json)
|
27
28
|
end
|
28
29
|
|
29
30
|
def stub_imminence_has_places_for_postcode(places, slug, postcode, limit)
|
@@ -32,14 +33,10 @@ module GdsApi
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
|
35
|
-
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
|
36
|
-
with(query: query_hash)
|
37
|
-
to_return(status: status_code, body: return_data.to_json, headers: {})
|
36
|
+
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
|
37
|
+
.with(query: query_hash)
|
38
|
+
.to_return(status: status_code, body: return_data.to_json, headers: {})
|
38
39
|
end
|
39
|
-
|
40
|
-
alias_deprecated :imminence_has_places, :stub_imminence_has_places
|
41
|
-
alias_deprecated :imminence_has_areas_for_postcode, :stub_imminence_has_areas_for_postcode
|
42
|
-
alias_deprecated :imminence_has_places_for_postcode, :stub_imminence_has_places_for_postcode
|
43
40
|
end
|
44
41
|
end
|
45
42
|
end
|
@@ -1,28 +1,25 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module LicenceApplication
|
7
|
-
extend AliasDeprecated
|
8
|
-
|
9
6
|
# Generally true. If you are initializing the client differently,
|
10
7
|
# you could redefine/override the constant or stub directly.
|
11
8
|
LICENCE_APPLICATION_ENDPOINT = Plek.current.find("licensify")
|
12
9
|
|
13
10
|
def stub_licence_exists(identifier, licence)
|
14
11
|
licence = licence.to_json unless licence.is_a?(String)
|
15
|
-
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
16
|
-
with(headers: GdsApi::JsonClient.default_request_headers)
|
17
|
-
to_return(status: 200,
|
18
|
-
|
12
|
+
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
13
|
+
.with(headers: GdsApi::JsonClient.default_request_headers)
|
14
|
+
.to_return(status: 200,
|
15
|
+
body: licence)
|
19
16
|
end
|
20
17
|
|
21
18
|
def stub_licence_does_not_exist(identifier)
|
22
|
-
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
23
|
-
with(headers: GdsApi::JsonClient.default_request_headers)
|
24
|
-
to_return(status: 404,
|
25
|
-
|
19
|
+
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
20
|
+
.with(headers: GdsApi::JsonClient.default_request_headers)
|
21
|
+
.to_return(status: 404,
|
22
|
+
body: "{\"error\": [\"Unrecognised Licence Id: #{identifier}\"]}")
|
26
23
|
end
|
27
24
|
|
28
25
|
def stub_licence_times_out(identifier)
|
@@ -32,11 +29,6 @@ module GdsApi
|
|
32
29
|
def stub_licence_returns_error(identifier)
|
33
30
|
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500)
|
34
31
|
end
|
35
|
-
|
36
|
-
alias_deprecated :licence_exists, :stub_licence_exists
|
37
|
-
alias_deprecated :licence_does_not_exist, :stub_licence_does_not_exist
|
38
|
-
alias_deprecated :licence_times_out, :stub_licence_times_out
|
39
|
-
alias_deprecated :licence_returns_error, :stub_licence_returns_error
|
40
32
|
end
|
41
33
|
end
|
42
34
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module LinkCheckerApi
|
7
|
-
extend AliasDeprecated
|
8
6
|
LINK_CHECKER_API_ENDPOINT = Plek.current.find("link-checker-api")
|
9
7
|
|
10
8
|
def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
|
@@ -91,12 +89,6 @@ module GdsApi
|
|
91
89
|
headers: { "Content-Type" => "application/json" },
|
92
90
|
)
|
93
91
|
end
|
94
|
-
|
95
|
-
# Aliases for DEPRECATED methods
|
96
|
-
alias_deprecated :link_checker_api_check, :stub_link_checker_api_check
|
97
|
-
alias_deprecated :link_checker_api_get_batch, :stub_link_checker_api_get_batch
|
98
|
-
alias_deprecated :link_checker_api_create_batch, :stub_link_checker_api_create_batch
|
99
|
-
alias_deprecated :link_checker_api_upsert_resource_monitor, :stub_link_checker_api_upsert_resource_monitor
|
100
92
|
end
|
101
93
|
end
|
102
94
|
end
|