gds-api-adapters 80.0.1 → 81.0.2
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 +4 -4
- data/README.md +28 -0
- data/lib/gds_api/local_links_manager.rb +10 -0
- data/lib/gds_api/test_helpers/email_alert_api.rb +6 -0
- data/lib/gds_api/test_helpers/local_links_manager.rb +73 -21
- data/lib/gds_api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a24005bab2921edb7aa53883b108f6e41d924fad73427f83a36e8533e7812d04
|
4
|
+
data.tar.gz: f31d0c3901757454cc2cb2bc9a25f37bf75478d49f1897df0f49d7b9618d0100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab28218b95c40c9220630b17aef48d0a97d9c6d20a436a2006114e23269cf3932f152becd2735f539a812cfa698b39b54da9ba707ccb475014164a12a16f6e7
|
7
|
+
data.tar.gz: 5df20ac4342d9ba55ef43c8e83731d78f24205a96c48f05803d84cc8ea7d04c33886c67547d5f8dd06804f4c55665f3192cb30be367063d9af77c851c2898e54
|
data/README.md
CHANGED
@@ -82,6 +82,34 @@ There are also test helpers for stubbing various requests in other apps.
|
|
82
82
|
|
83
83
|
See [all the test helpers in lib/gds_api/test_helpers](/lib/gds_api/test_helpers).
|
84
84
|
|
85
|
+
|
86
|
+
## Pact Verification During CI
|
87
|
+
|
88
|
+
During the CI test suite, Jenkins downloads and runs the pact:verify tasks for
|
89
|
+
each provider app. It's run directly on the Jenkins machine rather than in
|
90
|
+
docker containers for each app. For this reason the email-alert-api app
|
91
|
+
requires a specific setup on the CI machine - on db creation it copies the
|
92
|
+
database from the template1 db (this is the usual PG behaviour, but for some
|
93
|
+
reason rails needs to be told to do this explicitly). This template1 db has
|
94
|
+
to have the uuid-ossp extension installed by superuser, because the jenkins
|
95
|
+
user that CI runs under cannot create this extension. If this test stops
|
96
|
+
working with errors like:
|
97
|
+
|
98
|
+
```
|
99
|
+
Caused by:
|
100
|
+
PG::InsufficientPrivilege: ERROR: permission denied to create extension "uuid-ossp"
|
101
|
+
HINT: Must be superuser to create this extension.
|
102
|
+
```
|
103
|
+
|
104
|
+
...the template may have been deleted or changed. Log in to the relevant CI
|
105
|
+
agent and run:
|
106
|
+
|
107
|
+
`> sudo -u postgres psql -d template1`
|
108
|
+
|
109
|
+
Then at the PSQL command line:
|
110
|
+
|
111
|
+
`template1=# CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`
|
112
|
+
|
85
113
|
## Licence
|
86
114
|
|
87
115
|
Released under the MIT Licence, a copy of which can be found in the file
|
@@ -6,8 +6,18 @@ class GdsApi::LocalLinksManager < GdsApi::Base
|
|
6
6
|
get_json(url)
|
7
7
|
end
|
8
8
|
|
9
|
+
def local_link_by_custodian_code(local_custodian_code, lgsl, lgil)
|
10
|
+
url = "#{endpoint}/api/link?local_custodian_code=#{local_custodian_code}&lgsl=#{lgsl}&lgil=#{lgil}"
|
11
|
+
get_json(url)
|
12
|
+
end
|
13
|
+
|
9
14
|
def local_authority(authority_slug)
|
10
15
|
url = "#{endpoint}/api/local-authority?authority_slug=#{authority_slug}"
|
11
16
|
get_json(url)
|
12
17
|
end
|
18
|
+
|
19
|
+
def local_authority_by_custodian_code(local_custodian_code)
|
20
|
+
url = "#{endpoint}/api/local-authority?local_custodian_code=#{local_custodian_code}"
|
21
|
+
get_json(url)
|
22
|
+
end
|
13
23
|
end
|
@@ -595,6 +595,12 @@ module GdsApi
|
|
595
595
|
url = "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists"
|
596
596
|
query ? "#{url}?#{query}" : url
|
597
597
|
end
|
598
|
+
|
599
|
+
# Find and return the subscriber list for a topic if one exists.
|
600
|
+
def email_alert_api_has_subscriber_list_for_topic(content_id:, list: {})
|
601
|
+
url = "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists?links%5Btopics%5D%5B0%5D=#{content_id}"
|
602
|
+
stub_request(:get, url).to_return(status: 200, body: { "subscriber_list" => list }.to_json)
|
603
|
+
end
|
598
604
|
end
|
599
605
|
end
|
600
606
|
end
|
@@ -5,7 +5,7 @@ module GdsApi
|
|
5
5
|
module LocalLinksManager
|
6
6
|
LOCAL_LINKS_MANAGER_ENDPOINT = Plek.current.find("local-links-manager")
|
7
7
|
|
8
|
-
def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, country_name: "England", status: "ok")
|
8
|
+
def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, country_name: "England", status: "ok", local_custodian_code: nil)
|
9
9
|
response = {
|
10
10
|
"local_authority" => {
|
11
11
|
"name" => authority_slug.capitalize,
|
@@ -13,6 +13,7 @@ module GdsApi
|
|
13
13
|
"tier" => "unitary",
|
14
14
|
"homepage_url" => "http://#{authority_slug}.example.com",
|
15
15
|
"country_name" => country_name,
|
16
|
+
"slug" => authority_slug,
|
16
17
|
},
|
17
18
|
"local_interaction" => {
|
18
19
|
"lgsl_code" => lgsl,
|
@@ -25,9 +26,15 @@ module GdsApi
|
|
25
26
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
26
27
|
.with(query: { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil })
|
27
28
|
.to_return(body: response.to_json, status: 200)
|
29
|
+
|
30
|
+
unless local_custodian_code.nil?
|
31
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
32
|
+
.with(query: { local_custodian_code: local_custodian_code, lgsl: lgsl, lgil: lgil })
|
33
|
+
.to_return(body: response.to_json, status: 200)
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
|
-
def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England")
|
37
|
+
def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England", local_custodian_code: nil)
|
31
38
|
response = {
|
32
39
|
"local_authority" => {
|
33
40
|
"name" => authority_slug.capitalize,
|
@@ -35,15 +42,22 @@ module GdsApi
|
|
35
42
|
"tier" => "unitary",
|
36
43
|
"homepage_url" => "http://#{authority_slug}.example.com",
|
37
44
|
"country_name" => country_name,
|
45
|
+
"slug" => authority_slug,
|
38
46
|
},
|
39
47
|
}
|
40
48
|
|
41
49
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
42
50
|
.with(query: { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil })
|
43
51
|
.to_return(body: response.to_json, status: 200)
|
52
|
+
|
53
|
+
unless local_custodian_code.nil?
|
54
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
55
|
+
.with(query: { local_custodian_code: local_custodian_code, lgsl: lgsl, lgil: lgil })
|
56
|
+
.to_return(body: response.to_json, status: 200)
|
57
|
+
end
|
44
58
|
end
|
45
59
|
|
46
|
-
def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England")
|
60
|
+
def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England", local_custodian_code: nil)
|
47
61
|
response = {
|
48
62
|
"local_authority" => {
|
49
63
|
"name" => authority_slug.capitalize,
|
@@ -51,43 +65,48 @@ module GdsApi
|
|
51
65
|
"tier" => "unitary",
|
52
66
|
"homepage_url" => nil,
|
53
67
|
"country_name" => country_name,
|
68
|
+
"slug" => authority_slug,
|
54
69
|
},
|
55
70
|
}
|
56
71
|
|
57
72
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
58
73
|
.with(query: { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil })
|
59
74
|
.to_return(body: response.to_json, status: 200)
|
60
|
-
end
|
61
75
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
76
|
+
unless local_custodian_code.nil?
|
77
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
78
|
+
.with(query: { local_custodian_code: local_custodian_code, lgsl: lgsl, lgil: lgil })
|
79
|
+
.to_return(body: response.to_json, status: 200)
|
80
|
+
end
|
81
|
+
end
|
69
82
|
|
83
|
+
def stub_local_links_manager_request_with_missing_parameters(**parameters)
|
70
84
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
71
|
-
.with(query:
|
85
|
+
.with(query: convert_to_query_string_params(parameters))
|
72
86
|
.to_return(body: {}.to_json, status: 400)
|
73
87
|
end
|
74
88
|
|
75
|
-
def
|
76
|
-
params = { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil }
|
77
|
-
|
89
|
+
def stub_local_links_manager_request_with_invalid_parameters(**parameters)
|
78
90
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
79
|
-
.with(query:
|
91
|
+
.with(query: convert_to_query_string_params(parameters))
|
80
92
|
.to_return(body: {}.to_json, status: 404)
|
81
93
|
end
|
82
94
|
|
83
|
-
def
|
95
|
+
def convert_to_query_string_params(parameters)
|
96
|
+
# convert nil to an empty string, otherwise query param is not expressed correctly
|
97
|
+
parameters.each { |key, _value| parameters[key] = "" if parameters[key].nil? }
|
98
|
+
parameters
|
99
|
+
end
|
100
|
+
|
101
|
+
def stub_local_links_manager_has_a_local_authority(authority_slug, country_name: "England", local_custodian_code: nil)
|
84
102
|
response = {
|
85
103
|
"local_authorities" => [
|
86
104
|
{
|
87
105
|
"name" => authority_slug.capitalize,
|
88
106
|
"homepage_url" => "http://#{authority_slug}.example.com",
|
89
|
-
"country_name" =>
|
107
|
+
"country_name" => country_name,
|
90
108
|
"tier" => "unitary",
|
109
|
+
"slug" => authority_slug,
|
91
110
|
},
|
92
111
|
],
|
93
112
|
}
|
@@ -95,9 +114,15 @@ module GdsApi
|
|
95
114
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
96
115
|
.with(query: { authority_slug: authority_slug })
|
97
116
|
.to_return(body: response.to_json, status: 200)
|
117
|
+
|
118
|
+
unless local_custodian_code.nil?
|
119
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
120
|
+
.with(query: { local_custodian_code: local_custodian_code })
|
121
|
+
.to_return(body: response.to_json, status: 200)
|
122
|
+
end
|
98
123
|
end
|
99
124
|
|
100
|
-
def stub_local_links_manager_has_a_district_and_county_local_authority(district_slug, county_slug)
|
125
|
+
def stub_local_links_manager_has_a_district_and_county_local_authority(district_slug, county_slug, local_custodian_code: nil)
|
101
126
|
response = {
|
102
127
|
"local_authorities" => [
|
103
128
|
{
|
@@ -105,12 +130,14 @@ module GdsApi
|
|
105
130
|
"homepage_url" => "http://#{district_slug}.example.com",
|
106
131
|
"country_name" => "England",
|
107
132
|
"tier" => "district",
|
133
|
+
"slug" => district_slug,
|
108
134
|
},
|
109
135
|
{
|
110
136
|
"name" => county_slug.capitalize,
|
111
137
|
"homepage_url" => "http://#{county_slug}.example.com",
|
112
138
|
"country_name" => "England",
|
113
139
|
"tier" => "county",
|
140
|
+
"slug" => county_slug,
|
114
141
|
},
|
115
142
|
],
|
116
143
|
}
|
@@ -118,6 +145,12 @@ module GdsApi
|
|
118
145
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
119
146
|
.with(query: { authority_slug: district_slug })
|
120
147
|
.to_return(body: response.to_json, status: 200)
|
148
|
+
|
149
|
+
unless local_custodian_code.nil?
|
150
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
151
|
+
.with(query: { local_custodian_code: local_custodian_code })
|
152
|
+
.to_return(body: response.to_json, status: 200)
|
153
|
+
end
|
121
154
|
end
|
122
155
|
|
123
156
|
def stub_local_links_manager_request_without_local_authority_slug
|
@@ -126,20 +159,33 @@ module GdsApi
|
|
126
159
|
.to_return(body: {}.to_json, status: 400)
|
127
160
|
end
|
128
161
|
|
162
|
+
def stub_local_links_manager_request_without_local_custodian_code
|
163
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
164
|
+
.with(query: { local_custodian_code: "" })
|
165
|
+
.to_return(body: {}.to_json, status: 400)
|
166
|
+
end
|
167
|
+
|
129
168
|
def stub_local_links_manager_does_not_have_an_authority(authority_slug)
|
130
169
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
131
170
|
.with(query: { authority_slug: authority_slug })
|
132
171
|
.to_return(body: {}.to_json, status: 404)
|
133
172
|
end
|
134
173
|
|
135
|
-
def
|
174
|
+
def stub_local_links_manager_does_not_have_a_custodian_code(local_custodian_code)
|
175
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
176
|
+
.with(query: { local_custodian_code: local_custodian_code })
|
177
|
+
.to_return(body: {}.to_json, status: 404)
|
178
|
+
end
|
179
|
+
|
180
|
+
def stub_local_links_manager_has_a_local_authority_without_homepage(authority_slug, country_name: "England", local_custodian_code: nil)
|
136
181
|
response = {
|
137
182
|
"local_authorities" => [
|
138
183
|
{
|
139
184
|
"name" => authority_slug.capitalize,
|
140
185
|
"homepage_url" => "",
|
141
|
-
"country_name" =>
|
186
|
+
"country_name" => country_name,
|
142
187
|
"tier" => "unitary",
|
188
|
+
"slug" => authority_slug,
|
143
189
|
},
|
144
190
|
],
|
145
191
|
}
|
@@ -147,6 +193,12 @@ module GdsApi
|
|
147
193
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
148
194
|
.with(query: { authority_slug: authority_slug })
|
149
195
|
.to_return(body: response.to_json, status: 200)
|
196
|
+
|
197
|
+
unless local_custodian_code.nil?
|
198
|
+
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
199
|
+
.with(query: { local_custodian_code: local_custodian_code })
|
200
|
+
.to_return(body: response.to_json, status: 200)
|
201
|
+
end
|
150
202
|
end
|
151
203
|
end
|
152
204
|
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: 81.0.2
|
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: 2022-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -440,14 +440,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
440
440
|
requirements:
|
441
441
|
- - ">="
|
442
442
|
- !ruby/object:Gem::Version
|
443
|
-
version: 2.
|
443
|
+
version: 2.7.0
|
444
444
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
445
445
|
requirements:
|
446
446
|
- - ">="
|
447
447
|
- !ruby/object:Gem::Version
|
448
448
|
version: '0'
|
449
449
|
requirements: []
|
450
|
-
rubygems_version: 3.
|
450
|
+
rubygems_version: 3.1.6
|
451
451
|
signing_key:
|
452
452
|
specification_version: 4
|
453
453
|
summary: Adapters to work with GDS APIs
|