gds-api-adapters 38.1.0 → 39.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gds_api/test_helpers/need_api.rb +0 -15
  3. data/lib/gds_api/test_helpers/organisations.rb +5 -0
  4. data/lib/gds_api/version.rb +1 -1
  5. metadata +3 -103
  6. data/test/asset_manager_test.rb +0 -94
  7. data/test/business_support_api_test.rb +0 -45
  8. data/test/content_api_test.rb +0 -712
  9. data/test/content_store_test.rb +0 -55
  10. data/test/email_alert_api_test.rb +0 -189
  11. data/test/fixtures/finder_api/cma-case-schema.json +0 -103
  12. data/test/fixtures/hello.txt +0 -1
  13. data/test/fixtures/new_policies_for_dwp.json +0 -298
  14. data/test/fixtures/no_services_and_info_data_found_fixture.json +0 -14
  15. data/test/fixtures/old_policies_for_dwp.json +0 -413
  16. data/test/fixtures/services_and_info_fixture.json +0 -73
  17. data/test/fixtures/sub_sector_organisations.json +0 -57
  18. data/test/fixtures/world_organisations_australia.json +0 -490
  19. data/test/gds_api_base_test.rb +0 -110
  20. data/test/gov_uk_delivery_test.rb +0 -67
  21. data/test/govuk_headers_test.rb +0 -30
  22. data/test/helpers_test.rb +0 -23
  23. data/test/imminence_api_test.rb +0 -196
  24. data/test/json_client_test.rb +0 -879
  25. data/test/licence_application_api_test.rb +0 -196
  26. data/test/list_response_test.rb +0 -189
  27. data/test/local_links_manager_api_test.rb +0 -236
  28. data/test/mapit_test.rb +0 -117
  29. data/test/maslow_test.rb +0 -12
  30. data/test/middleware/govuk_header_sniffer_test.rb +0 -18
  31. data/test/need_api_test.rb +0 -345
  32. data/test/organisations_api_test.rb +0 -58
  33. data/test/panopticon_registerer_test.rb +0 -118
  34. data/test/panopticon_test.rb +0 -190
  35. data/test/pp_data_in_test.rb +0 -52
  36. data/test/pp_data_out_test.rb +0 -24
  37. data/test/publishing_api/special_route_publisher_test.rb +0 -104
  38. data/test/publishing_api_test.rb +0 -186
  39. data/test/publishing_api_v2/get_expanded_links_test.rb +0 -85
  40. data/test/publishing_api_v2/get_links_test.rb +0 -89
  41. data/test/publishing_api_v2/lookup_test.rb +0 -70
  42. data/test/publishing_api_v2_test.rb +0 -1649
  43. data/test/response_test.rb +0 -245
  44. data/test/router_test.rb +0 -456
  45. data/test/rummager_helpers_test.rb +0 -20
  46. data/test/rummager_test.rb +0 -150
  47. data/test/support_api_test.rb +0 -189
  48. data/test/support_test.rb +0 -95
  49. data/test/test_helper.rb +0 -55
  50. data/test/test_helpers/email_alert_api_test.rb +0 -24
  51. data/test/test_helpers/pact_helper.rb +0 -13
  52. data/test/test_helpers/panopticon_test.rb +0 -44
  53. data/test/test_helpers/publishing_api_test.rb +0 -129
  54. data/test/test_helpers/publishing_api_v2_test.rb +0 -170
  55. data/test/worldwide_api_test.rb +0 -82
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
- require 'gds_api/rummager'
3
- require 'gds_api/test_helpers/rummager'
4
-
5
- class RummagerHelpersTest < Minitest::Test
6
- include GdsApi::TestHelpers::Rummager
7
-
8
- def test_services_and_info_data_returns_an_adequate_response_object
9
- response = rummager_has_services_and_info_data_for_organisation
10
-
11
- assert_instance_of GdsApi::Response, response
12
- end
13
-
14
- def test_no_services_and_info_data_found_for_organisation
15
- response = rummager_has_no_services_and_info_data_for_organisation
16
-
17
- assert_instance_of GdsApi::Response, response
18
- assert_equal 0, response['facets']['specialist_sectors']['total_options']
19
- end
20
- end
@@ -1,150 +0,0 @@
1
- require "test_helper"
2
- require "gds_api/rummager"
3
-
4
- describe GdsApi::Rummager do
5
- before(:each) do
6
- stub_request(:get, /example.com\/advanced_search/).to_return(body: "[]")
7
- stub_request(:get, /example.com\/search/).to_return(body: "[]")
8
- end
9
-
10
- # tests for #advanced_search
11
-
12
- it "#advanced_search should raise an exception if the service at the search URI returns a 500" do
13
- stub_request(:get, /example.com\/advanced_search/).to_return(status: [500, "Internal Server Error"])
14
- assert_raises(GdsApi::HTTPServerError) do
15
- GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
16
- end
17
- end
18
-
19
- it "#advanced_search should raise an exception if the service at the search URI returns a 404" do
20
- stub_request(:get, /example.com\/advanced_search/).to_return(status: [404, "Not Found"])
21
- assert_raises(GdsApi::HTTPNotFound) do
22
- GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
23
- end
24
- end
25
-
26
- it "#advanced_search should raise an exception if the service at the search URI times out" do
27
- stub_request(:get, /example.com\/advanced_search/).to_timeout
28
- assert_raises(GdsApi::TimedOutException) do
29
- GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
30
- end
31
- end
32
-
33
- it "#advanced_search should return the search deserialized from json" do
34
- search_results = [{ "title" => "document-title" }]
35
- stub_request(:get, /example.com\/advanced_search/).to_return(body: search_results.to_json)
36
- results = GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
37
-
38
- assert_equal search_results, results.to_hash
39
- end
40
-
41
- it "#advanced_search should return an empty set of results without making request if arguments are empty" do
42
- assert_raises(ArgumentError) do
43
- GdsApi::Rummager.new("http://example.com").advanced_search({})
44
- end
45
- end
46
-
47
- it "#advanced_search should return an empty set of results without making request if arguments is nil" do
48
- assert_raises(ArgumentError) do
49
- GdsApi::Rummager.new("http://example.com").advanced_search(nil)
50
- end
51
- end
52
-
53
- it "#advanced_search should request the search results in JSON format" do
54
- GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
55
-
56
- assert_requested :get, /.*/, headers: { "Accept" => "application/json" }
57
- end
58
-
59
- it "#advanced_search should issue a request for all the params supplied" do
60
- GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query & stuff", topics: %w(1 2), order: { public_timestamp: "desc" })
61
-
62
- assert_requested :get, /keywords=query%20%26%20stuff/
63
- assert_requested :get, /topics\[\]=1&topics\[\]=2/
64
- assert_requested :get, /order\[public_timestamp\]=desc/
65
- end
66
-
67
- # tests for search
68
-
69
- it "#search should raise an exception if the service at the search URI returns a 500" do
70
- stub_request(:get, /example.com\/search.json/).to_return(status: [500, "Internal Server Error"])
71
- assert_raises(GdsApi::HTTPServerError) do
72
- GdsApi::Rummager.new("http://example.com").search(q: "query")
73
- end
74
- end
75
-
76
- it "#search should raise an exception if the service at the search URI returns a 404" do
77
- stub_request(:get, /example.com\/search/).to_return(status: [404, "Not Found"])
78
- assert_raises(GdsApi::HTTPNotFound) do
79
- GdsApi::Rummager.new("http://example.com").search(q: "query")
80
- end
81
- end
82
-
83
- it "#search should raise an exception if the service at the search URI returns a 400" do
84
- stub_request(:get, /example.com\/search/).to_return(
85
- status: [400, "Bad Request"],
86
- body: '"error":"Filtering by \"coffee\" is not allowed"',
87
- )
88
- assert_raises(GdsApi::HTTPClientError) do
89
- GdsApi::Rummager.new("http://example.com").search(q: "query", filter_coffee: "tea")
90
- end
91
- end
92
-
93
- it "#search should raise an exception if the service at the search URI returns a 422" do
94
- stub_request(:get, /example.com\/search/).to_return(
95
- status: [422, "Bad Request"],
96
- body: '"error":"Filtering by \"coffee\" is not allowed"',
97
- )
98
- assert_raises(GdsApi::HTTPClientError) do
99
- GdsApi::Rummager.new("http://example.com").search(q: "query", filter_coffee: "tea")
100
- end
101
- end
102
-
103
- it "#search should raise an exception if the service at the search URI times out" do
104
- stub_request(:get, /example.com\/search/).to_timeout
105
- assert_raises(GdsApi::TimedOutException) do
106
- GdsApi::Rummager.new("http://example.com").search(q: "query")
107
- end
108
- end
109
-
110
- it "#search should return the search deserialized from json" do
111
- search_results = [{ "title" => "document-title" }]
112
- stub_request(:get, /example.com\/search/).to_return(body: search_results.to_json)
113
- results = GdsApi::Rummager.new("http://example.com").search(q: "query")
114
- assert_equal search_results, results.to_hash
115
- end
116
-
117
- it "#search should request the search results in JSON format" do
118
- GdsApi::Rummager.new("http://example.com").search(q: "query")
119
-
120
- assert_requested :get, /.*/, headers: { "Accept" => "application/json" }
121
- end
122
-
123
- it "#search should issue a request for all the params supplied" do
124
- GdsApi::Rummager.new("http://example.com").search(
125
- q: "query & stuff",
126
- filter_topics: %w(1 2),
127
- order: "-public_timestamp",
128
- )
129
-
130
- assert_requested :get, /q=query%20%26%20stuff/
131
- assert_requested :get, /filter_topics\[\]=1&filter_topics\[\]=2/
132
- assert_requested :get, /order=-public_timestamp/
133
- end
134
-
135
- it "#delete_content removes a document" do
136
- request = stub_request(:delete, "http://example.com/content?link=/foo/bar")
137
-
138
- GdsApi::Rummager.new("http://example.com").delete_content("/foo/bar")
139
-
140
- assert_requested(request)
141
- end
142
-
143
- it "#get_content Retrieves a document" do
144
- request = stub_request(:get, "http://example.com/content?link=/foo/bar")
145
-
146
- GdsApi::Rummager.new("http://example.com").get_content("/foo/bar")
147
-
148
- assert_requested(request)
149
- end
150
- end
@@ -1,189 +0,0 @@
1
- require 'test_helper'
2
- require 'gds_api/support_api'
3
- require 'gds_api/test_helpers/support_api'
4
-
5
- describe GdsApi::SupportApi do
6
- include GdsApi::TestHelpers::SupportApi
7
-
8
- before do
9
- @base_api_url = Plek.current.find("support-api")
10
- @api = GdsApi::SupportApi.new(@base_api_url)
11
- end
12
-
13
- it "can report a problem" do
14
- request_details = { certain: "details" }
15
-
16
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/problem-reports").
17
- with(body: { "problem_report" => request_details }.to_json).
18
- to_return(status: 201)
19
-
20
- @api.create_problem_report(request_details)
21
-
22
- assert_requested(stub_post)
23
- end
24
-
25
- it "can pass service feedback" do
26
- request_details = { "transaction-completed-values" => "1", "details" => "abc" }
27
-
28
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/service-feedback").
29
- with(body: { "service_feedback" => request_details }.to_json).
30
- to_return(status: 201)
31
-
32
- @api.create_service_feedback(request_details)
33
-
34
- assert_requested(stub_post)
35
- end
36
-
37
- it "can submit long-form anonymous feedback" do
38
- request_details = { certain: "details" }
39
-
40
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/long-form-contacts").
41
- with(body: { "long_form_contact" => request_details }.to_json).
42
- to_return(status: 201)
43
-
44
- @api.create_anonymous_long_form_contact(request_details)
45
-
46
- assert_requested(stub_post)
47
- end
48
-
49
- it "fetches problem report daily totals" do
50
- response_body = { "data" => ["results"] }
51
-
52
- stub_get = stub_request(:get, "#{@base_api_url}/anonymous-feedback/problem-reports/2014-07-12/totals").
53
- to_return(status: 200, body: response_body.to_json)
54
-
55
- result = @api.problem_report_daily_totals_for(Date.new(2014, 7, 12))
56
-
57
- assert_requested(stub_get)
58
- assert_equal response_body, result.to_hash
59
- end
60
-
61
- it "throws an exception when the support app isn't available" do
62
- support_api_isnt_available
63
-
64
- assert_raises(GdsApi::HTTPServerError) { @api.create_service_feedback({}) }
65
- end
66
-
67
- describe "GET /anonymous-feedback" do
68
- it "fetches anonymous feedback" do
69
- stub_get = stub_anonymous_feedback(
70
- path_prefix: "/vat-rates",
71
- page: 55,
72
- )
73
-
74
- @api.anonymous_feedback(
75
- path_prefix: "/vat-rates",
76
- page: 55,
77
- )
78
-
79
- assert_requested(stub_get)
80
- end
81
- end
82
-
83
- describe "GET /anonymous-feedback/organisations/:organisation_slug" do
84
- it "fetches organisation summary" do
85
- slug = "hm-revenue-customs"
86
-
87
- stub_get = stub_anonymous_feedback_organisation_summary(slug)
88
-
89
- @api.organisation_summary(slug)
90
-
91
- assert_requested(stub_get)
92
- end
93
-
94
- it "accepts an ordering parameter" do
95
- slug = "hm-revenue-customs"
96
- ordering = "last_30_days"
97
-
98
- stub_get = stub_anonymous_feedback_organisation_summary(slug, ordering)
99
-
100
- @api.organisation_summary(slug, ordering: ordering)
101
-
102
- assert_requested(stub_get)
103
- end
104
- end
105
-
106
- describe "POST /anonymous-feedback/export-requests" do
107
- it "makes a POST request to the support api" do
108
- stub_post = stub_support_feedback_export_request_creation(notification_email: "foo@example.com")
109
-
110
- @api.create_feedback_export_request(notification_email: "foo@example.com")
111
-
112
- assert_requested(stub_post)
113
- end
114
- end
115
-
116
- describe "POST /anonymous-feedback/global-export-requests" do
117
- it "makes a POST request to the support API" do
118
- params = { from_date: "1 June 2016", to_date: "8 June 2016", notification_email: "foo@example.com" }
119
- stub_post = stub_support_global_export_request_creation(params)
120
-
121
- @api.create_global_export_request(params)
122
- assert_requested(stub_post)
123
- end
124
- end
125
-
126
- describe "POST /page-improvements" do
127
- it "makes a POST request to the support API" do
128
- params = { description: "The title could be better." }
129
- stub_post = stub_create_page_improvement(params)
130
-
131
- @api.create_page_improvement(params)
132
-
133
- assert_requested(stub_post)
134
- end
135
- end
136
-
137
- describe "GET /anonymous-feedback/export-requests/:id" do
138
- it "fetches the export request details from the API" do
139
- stub_get = stub_support_feedback_export_request(123)
140
-
141
- @api.feedback_export_request(123)
142
-
143
- assert_requested(stub_get)
144
- end
145
- end
146
-
147
- describe "GET /organisations" do
148
- it "fetches a list of organisations" do
149
- stub_get = stub_organisations_list
150
-
151
- @api.organisations_list
152
-
153
- assert_requested(stub_get)
154
- end
155
- end
156
-
157
- describe "GET /organisations/:slug" do
158
- it "fetches a list of organisations" do
159
- stub_get = stub_organisation("foo")
160
-
161
- @api.organisation("foo")
162
-
163
- assert_requested(stub_get)
164
- end
165
- end
166
-
167
- describe "GET /anonymous-feedback/problem-reports" do
168
- it "fetches a list of problem reports" do
169
- params = { from_date: '2016-12-12', to_date: '2016-12-13', page: 1, exclude_reviewed: true }
170
- stub_get = stub_support_problem_reports(params)
171
-
172
- @api.problem_reports(params)
173
-
174
- assert_requested(stub_get)
175
- end
176
- end
177
-
178
- describe "POST /anonymous-feedback/problem-reports/mark-reviewed-for-spam" do
179
- it "makes a PUT request to the support API" do
180
- params = { "1" => true, "2" => true }
181
-
182
- stub_post = stub_support_mark_reviewed_for_spam(params)
183
-
184
- @api.mark_reviewed_for_spam(params)
185
-
186
- assert_requested(stub_post)
187
- end
188
- end
189
- end
@@ -1,95 +0,0 @@
1
- require 'test_helper'
2
- require 'gds_api/support'
3
- require 'gds_api/test_helpers/support'
4
-
5
- describe GdsApi::Support do
6
- include GdsApi::TestHelpers::Support
7
-
8
- before do
9
- @base_api_url = Plek.current.find("support")
10
- @api = GdsApi::Support.new(@base_api_url)
11
- end
12
-
13
- it "can create an FOI request" do
14
- request_details = { "foi_request" => { "requester" => { "name" => "A", "email" => "a@b.com" }, "details" => "abc" } }
15
-
16
- stub_post = stub_request(:post, "#{@base_api_url}/foi_requests").
17
- with(body: { "foi_request" => request_details }.to_json).
18
- to_return(status: 201)
19
-
20
- @api.create_foi_request(request_details)
21
-
22
- assert_requested(stub_post)
23
- end
24
-
25
- it "throws an exception when the support app isn't available" do
26
- support_isnt_available
27
-
28
- assert_raises(GdsApi::HTTPServerError) { @api.create_foi_request({}) }
29
- end
30
-
31
- it "can report a problem" do
32
- request_details = { certain: "details" }
33
-
34
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/problem_reports").
35
- with(body: { "problem_report" => request_details }.to_json).
36
- to_return(status: 201)
37
-
38
- @api.create_problem_report(request_details)
39
-
40
- assert_requested(stub_post)
41
- end
42
-
43
- it "can submit long-form anonymous feedback" do
44
- request_details = { certain: "details" }
45
-
46
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/long_form_contacts").
47
- with(body: { "long_form_contact" => request_details }.to_json).
48
- to_return(status: 201)
49
-
50
- @api.create_anonymous_long_form_contact(request_details)
51
-
52
- assert_requested(stub_post)
53
- end
54
-
55
- it "can create a named contact" do
56
- request_details = { certain: "details" }
57
-
58
- stub_post = stub_request(:post, "#{@base_api_url}/named_contacts").
59
- with(body: { "named_contact" => request_details }.to_json).
60
- to_return(status: 201)
61
-
62
- @api.create_named_contact(request_details)
63
-
64
- assert_requested(stub_post)
65
- end
66
-
67
- it "throws an exception when the support app isn't available" do
68
- support_isnt_available
69
-
70
- assert_raises(GdsApi::HTTPServerError) { @api.create_problem_report({}) }
71
- end
72
-
73
- it "can pass service feedback" do
74
- request_details = { "transaction-completed-values" => "1", "details" => "abc" }
75
-
76
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/service_feedback").
77
- with(body: { "service_feedback" => request_details }.to_json).
78
- to_return(status: 201)
79
-
80
- @api.create_service_feedback(request_details)
81
-
82
- assert_requested(stub_post)
83
- end
84
-
85
- it "throws an exception when the support app isn't available" do
86
- support_isnt_available
87
-
88
- assert_raises(GdsApi::HTTPServerError) { @api.create_service_feedback({}) }
89
- end
90
-
91
- it "gets the correct feedback URL" do
92
- assert_equal("#{@base_api_url}/anonymous_feedback?path=foo",
93
- @api.feedback_url('foo'))
94
- end
95
- end