publishing_platform_api_adapters 0.8.1 → 0.8.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71db8ee0d906b1e92fd7592d4c7938d338da0f901adc11c44e96db86f0ea955
|
4
|
+
data.tar.gz: 0e1f95953370551c78a5496ad7abbd7fab542c5dcf10ebf4c608901218381c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f369bad7e927df6175e3b444fae7a35a78dd65edd5a0c3f045ea001dcce007af12ce7745bc2b24249b1f5cf8b8b56bf764a39f3b8f443f8de4f1f659c5a3e54
|
7
|
+
data.tar.gz: '04836b8766c6d12c8ec2280827cc2eb5c4da0be1302353d9d89f4e029a633f6263601219f62c06a62668a4dfcbad9434a1207b67bebd68b2e732f1e247c79358'
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "publishing_platform_api/test_helpers/json_client_helper"
|
2
|
+
|
3
|
+
module PublishingPlatformApi
|
4
|
+
module TestHelpers
|
5
|
+
module Router
|
6
|
+
ROUTER_API_ENDPOINT = PublishingPlatformLocation.find("router-api")
|
7
|
+
|
8
|
+
def stub_router_has_route(path, route, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"])
|
9
|
+
stub_get_route(path, bearer_token).to_return(
|
10
|
+
status: 200,
|
11
|
+
body: route.to_json,
|
12
|
+
headers: { "Content-Type" => "application/json" },
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"])
|
17
|
+
stub_get_route(path, bearer_token).to_return(status: 404)
|
18
|
+
end
|
19
|
+
|
20
|
+
def stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false)
|
21
|
+
stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:)
|
22
|
+
end
|
23
|
+
|
24
|
+
def stub_router_has_redirect_route(path, redirect_to:, route_type: "exact", disabled: false)
|
25
|
+
stub_router_has_route(path, handler: "redirect", redirect_to:, disabled:, route_type:)
|
26
|
+
end
|
27
|
+
|
28
|
+
def stub_router_has_gone_route(path, route_type: "exact", disabled: false)
|
29
|
+
stub_router_has_route(path, handler: "gone", route_type:, disabled:)
|
30
|
+
end
|
31
|
+
|
32
|
+
def stub_all_router_registration
|
33
|
+
stub_request(:put, "#{ROUTER_API_ENDPOINT}/routes")
|
34
|
+
end
|
35
|
+
|
36
|
+
def stub_route_registration(path, type, backend_id)
|
37
|
+
stub_route_put({
|
38
|
+
route: {
|
39
|
+
incoming_path: path,
|
40
|
+
route_type: type,
|
41
|
+
handler: "backend",
|
42
|
+
backend_id:,
|
43
|
+
},
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
47
|
+
def stub_redirect_registration(path, type, destination, segments_mode = nil)
|
48
|
+
stub_route_put({
|
49
|
+
route: {
|
50
|
+
incoming_path: path,
|
51
|
+
route_type: type,
|
52
|
+
handler: "redirect",
|
53
|
+
redirect_to: destination,
|
54
|
+
segments_mode:,
|
55
|
+
},
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
def stub_gone_route_registration(path, type)
|
60
|
+
stub_route_put({
|
61
|
+
route: {
|
62
|
+
incoming_path: path,
|
63
|
+
route_type: type,
|
64
|
+
handler: "gone",
|
65
|
+
},
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def stub_get_route(path, bearer_token)
|
72
|
+
stub_http_request(:get, "#{ROUTER_API_ENDPOINT}/routes")
|
73
|
+
.with(
|
74
|
+
query: { "incoming_path" => path },
|
75
|
+
headers: { "Authorization" => "Bearer #{bearer_token}" },
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def stub_route_put(route)
|
80
|
+
stub_http_request(:put, "#{ROUTER_API_ENDPOINT}/routes")
|
81
|
+
.with(body: route.to_json)
|
82
|
+
.to_return(status: 201)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishing_platform_api_adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Publishing Platform
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/publishing_platform_api/router.rb
|
117
117
|
- lib/publishing_platform_api/test_helpers/content_item_helpers.rb
|
118
118
|
- lib/publishing_platform_api/test_helpers/content_store.rb
|
119
|
+
- lib/publishing_platform_api/test_helpers/router.rb
|
119
120
|
- lib/publishing_platform_api/version.rb
|
120
121
|
- lib/publishing_platform_api_adapters.rb
|
121
122
|
licenses:
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- !ruby/object:Gem::Version
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
|
-
rubygems_version: 3.6.
|
139
|
+
rubygems_version: 3.6.8
|
139
140
|
specification_version: 4
|
140
141
|
summary: Adapters to work with Publishing Platform APIs
|
141
142
|
test_files: []
|