gds-api-adapters 30.1.0 → 30.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/gds_api/govuk_headers.rb +5 -3
- data/lib/gds_api/version.rb +1 -1
- data/test/govuk_headers_test.rb +26 -0
- data/test/publishing_api_v2_test.rb +15 -15
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa6bb00e5f2ebd0cf88d785836ca4a034271d60
|
4
|
+
data.tar.gz: 89afbd1e27b272902ef2007022743cda48b8cf25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddb41be6da100058a5f31a3680c6c9fc1773cb26415fa29c40015757ea2dc886d902ce7297e3e8f25eaedd3da95631a95c6804ad2c9ee91d90c1a9ec4c6bee43
|
7
|
+
data.tar.gz: 034d0c128336323787a1246633797370f787f5b20a1d2efbe4bd5f5299062a5066a8680b773390bcd175b2d9e6fefc18ede604a58467dbffaa17c066d7f3e164
|
data/README.md
CHANGED
@@ -33,8 +33,8 @@ something that actually logs:
|
|
33
33
|
|
34
34
|
We set a unique header at the cache level called `Govuk-Request-Id`, and also
|
35
35
|
set a header called `Govuk-Original-Url` to identify the original URL
|
36
|
-
requested. If apps make API requests in order to
|
37
|
-
should pass on these headers, so that
|
36
|
+
requested. If apps make API requests in order to serve a user's request, they
|
37
|
+
should pass on these headers, so that requests can be traced across the entire
|
38
38
|
GOV.UK stack.
|
39
39
|
|
40
40
|
The `GdsApi::GovukHeaderSniffer` middleware takes care of this. This gem
|
@@ -9,13 +9,15 @@ module GdsApi
|
|
9
9
|
header_data.select {|k, v| !(v.nil? || v.empty?) }
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
def clear_headers
|
13
|
+
Thread.current[:headers] = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
13
17
|
|
14
18
|
def header_data
|
15
19
|
Thread.current[:headers] ||= {}
|
16
20
|
end
|
17
|
-
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
21
|
-
|
data/lib/gds_api/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "gds_api/govuk_headers"
|
3
|
+
|
4
|
+
describe GdsApi::GovukHeaders do
|
5
|
+
before :each do
|
6
|
+
Thread.current[:headers] = nil if Thread.current[:headers]
|
7
|
+
end
|
8
|
+
|
9
|
+
it "supports read/write of headers" do
|
10
|
+
GdsApi::GovukHeaders.set_header("GDS-Request-Id", "123-456")
|
11
|
+
GdsApi::GovukHeaders.set_header("Content-Type", "application/pdf")
|
12
|
+
|
13
|
+
assert_equal({
|
14
|
+
"GDS-Request-Id" => "123-456",
|
15
|
+
"Content-Type" => "application/pdf",
|
16
|
+
}, GdsApi::GovukHeaders.headers)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "supports clearing of headers" do
|
20
|
+
GdsApi::GovukHeaders.set_header("GDS-Request-Id", "123-456")
|
21
|
+
|
22
|
+
GdsApi::GovukHeaders.clear_headers
|
23
|
+
|
24
|
+
assert_equal({}, GdsApi::GovukHeaders.headers)
|
25
|
+
end
|
26
|
+
end
|
@@ -927,8 +927,8 @@ describe GdsApi::PublishingApiV2 do
|
|
927
927
|
rel: "self"
|
928
928
|
}],
|
929
929
|
results: [
|
930
|
-
{
|
931
|
-
{
|
930
|
+
{ title: 'Content Item A', base_path: '/a-base-path' },
|
931
|
+
{ title: 'Content Item B', base_path: '/another-base-path' },
|
932
932
|
]
|
933
933
|
}
|
934
934
|
)
|
@@ -945,7 +945,7 @@ describe GdsApi::PublishingApiV2 do
|
|
945
945
|
["pages", 1],
|
946
946
|
["current_page", 1],
|
947
947
|
["links", [{"href"=>"http://example.org/v2/content?content_format=topic&fields[]=title&fields[]=base_path&page=1", "rel"=>"self"}]],
|
948
|
-
["results", [{"
|
948
|
+
["results", [{"title"=>"Content Item A", "base_path"=>"/a-base-path"}, {"title"=>"Content Item B", "base_path"=>"/another-base-path"}]]
|
949
949
|
], response.to_a
|
950
950
|
|
951
951
|
end
|
@@ -973,7 +973,7 @@ describe GdsApi::PublishingApiV2 do
|
|
973
973
|
rel: "self"
|
974
974
|
}],
|
975
975
|
results: [
|
976
|
-
{
|
976
|
+
{ content_id: @content_id, locale: "en" }
|
977
977
|
]
|
978
978
|
}
|
979
979
|
)
|
@@ -990,7 +990,7 @@ describe GdsApi::PublishingApiV2 do
|
|
990
990
|
["pages", 1],
|
991
991
|
["current_page", 1],
|
992
992
|
["links", [{"href"=>"http://example.org/v2/content?content_format=topic&fields[]=content_id&fields[]=locale&page=1", "rel"=>"self"}]],
|
993
|
-
["results", [{"
|
993
|
+
["results", [{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"en"}]]
|
994
994
|
], response.to_a
|
995
995
|
end
|
996
996
|
|
@@ -1017,7 +1017,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1017
1017
|
rel: "self"
|
1018
1018
|
}],
|
1019
1019
|
results: [
|
1020
|
-
{
|
1020
|
+
{ content_id: @content_id, locale: "fr" }
|
1021
1021
|
]
|
1022
1022
|
}
|
1023
1023
|
)
|
@@ -1034,7 +1034,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1034
1034
|
["pages", 1],
|
1035
1035
|
["current_page", 1],
|
1036
1036
|
["links", [{"href"=>"http://example.org/v2/content?content_format=topic&fields[]=content_id&fields[]=locale&locale=fr&page=1", "rel"=>"self"}]],
|
1037
|
-
["results", [{"
|
1037
|
+
["results", [{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"fr"}]]
|
1038
1038
|
], response.to_a
|
1039
1039
|
end
|
1040
1040
|
|
@@ -1061,9 +1061,9 @@ describe GdsApi::PublishingApiV2 do
|
|
1061
1061
|
rel: "self"
|
1062
1062
|
}],
|
1063
1063
|
results: [
|
1064
|
-
{
|
1065
|
-
{
|
1066
|
-
{
|
1064
|
+
{ content_id: @content_id, locale: "en" },
|
1065
|
+
{ content_id: @content_id, locale: "fr" },
|
1066
|
+
{ content_id: @content_id, locale: "ar" },
|
1067
1067
|
]
|
1068
1068
|
}
|
1069
1069
|
)
|
@@ -1081,9 +1081,9 @@ describe GdsApi::PublishingApiV2 do
|
|
1081
1081
|
["links",
|
1082
1082
|
[{"href"=>"http://example.org/v2/content?content_format=topic&fields[]=content_id&fields[]=locale&locale=all&page=1", "rel"=>"self"}]],
|
1083
1083
|
["results",
|
1084
|
-
[{"
|
1085
|
-
{"
|
1086
|
-
{"
|
1084
|
+
[{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"en"},
|
1085
|
+
{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"fr"},
|
1086
|
+
{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"ar"}]]
|
1087
1087
|
], response.to_a
|
1088
1088
|
end
|
1089
1089
|
|
@@ -1110,7 +1110,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1110
1110
|
rel: "self"
|
1111
1111
|
}],
|
1112
1112
|
results: [
|
1113
|
-
{
|
1113
|
+
{ content_id: @content_id, details: {foo: :bar} }
|
1114
1114
|
]
|
1115
1115
|
}
|
1116
1116
|
)
|
@@ -1127,7 +1127,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1127
1127
|
["pages", 1],
|
1128
1128
|
["current_page", 1],
|
1129
1129
|
["links", [{"href"=>"http://example.org/v2/content?content_format=topic&fields[]=content_id&fields[]=details&page=1", "rel"=>"self"}]],
|
1130
|
-
["results", [{"
|
1130
|
+
["results", [{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "details"=>{"foo"=>"bar"}}]]
|
1131
1131
|
], response.to_a
|
1132
1132
|
end
|
1133
1133
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 30.
|
4
|
+
version: 30.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|
@@ -401,6 +401,7 @@ files:
|
|
401
401
|
- test/fixtures/world_organisations_australia.json
|
402
402
|
- test/gds_api_base_test.rb
|
403
403
|
- test/gov_uk_delivery_test.rb
|
404
|
+
- test/govuk_headers_test.rb
|
404
405
|
- test/helpers_test.rb
|
405
406
|
- test/imminence_api_test.rb
|
406
407
|
- test/json_client_test.rb
|
@@ -477,6 +478,7 @@ test_files:
|
|
477
478
|
- test/licence_application_api_test.rb
|
478
479
|
- test/gov_uk_delivery_test.rb
|
479
480
|
- test/maslow_test.rb
|
481
|
+
- test/govuk_headers_test.rb
|
480
482
|
- test/helpers_test.rb
|
481
483
|
- test/panopticon_registerer_test.rb
|
482
484
|
- test/panopticon_test.rb
|