publishing_platform_api_adapters 0.8.1 → 0.8.3

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: 12a639bdc05f05fbcb78557b20924d4d95286b09af685f76f5e2b6989d998bd7
4
- data.tar.gz: '0674539db2157aac06598a56fe898cbcb1ce4baa847f2bef637d62dbe4947501'
3
+ metadata.gz: 33684b80242329f1ddf7d6fd786c86adffa6118b3f9b4e4d81243148d90755c0
4
+ data.tar.gz: 3b3c0d5c7ea79a368629f349b71432e374b19f989d4a176b08b28c829e609f64
5
5
  SHA512:
6
- metadata.gz: 19667cbc60807f1d7c3fe54eb1ab0a8bd5437fe328f011cd5fc8e1bfa13085218c84bd80a146c645a18cc65af8ddef2dceec9b14a46f689508be7abe737b16c3
7
- data.tar.gz: e77e8a1bd9b420c84dfdbf09bcbee8d672eab10f27422a14d6a0568572f0f8286e4a8b11cc25969a70d3e95c67bcde71c46cc55851bdb6c57070c47550e8c6f7
6
+ metadata.gz: 1189194963db42488c2dcd753b9fe0e41c43adcaf002cef403d2ae4b864af4d959398f4fedc34247dce88e2d2d2df3ea41b5800054e4a9ae17242bbea9042d01
7
+ data.tar.gz: e43738770632d4739fe78080e4faf2b1067294e456366e7fa0b7b8218d1d292978485c1ec13f6e2642c1a888bf52e657c1c6741fbb5982dbd0261a160141b0e1
@@ -0,0 +1,84 @@
1
+ module PublishingPlatformApi
2
+ module TestHelpers
3
+ module Router
4
+ ROUTER_API_ENDPOINT = PublishingPlatformLocation.find("router-api")
5
+
6
+ def stub_router_has_route(path, route, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"])
7
+ stub_get_route(path, bearer_token).to_return(
8
+ status: 200,
9
+ body: route.to_json,
10
+ headers: { "Content-Type" => "application/json" },
11
+ )
12
+ end
13
+
14
+ def stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"])
15
+ stub_get_route(path, bearer_token).to_return(status: 404)
16
+ end
17
+
18
+ def stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false)
19
+ stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:)
20
+ end
21
+
22
+ def stub_router_has_redirect_route(path, redirect_to:, route_type: "exact", disabled: false)
23
+ stub_router_has_route(path, handler: "redirect", redirect_to:, disabled:, route_type:)
24
+ end
25
+
26
+ def stub_router_has_gone_route(path, route_type: "exact", disabled: false)
27
+ stub_router_has_route(path, handler: "gone", route_type:, disabled:)
28
+ end
29
+
30
+ def stub_all_router_registration
31
+ stub_request(:put, "#{ROUTER_API_ENDPOINT}/routes")
32
+ end
33
+
34
+ def stub_route_registration(path, type, backend_id)
35
+ stub_route_put({
36
+ route: {
37
+ incoming_path: path,
38
+ route_type: type,
39
+ handler: "backend",
40
+ backend_id:,
41
+ },
42
+ })
43
+ end
44
+
45
+ def stub_redirect_registration(path, type, destination, segments_mode = nil)
46
+ stub_route_put({
47
+ route: {
48
+ incoming_path: path,
49
+ route_type: type,
50
+ handler: "redirect",
51
+ redirect_to: destination,
52
+ segments_mode:,
53
+ },
54
+ })
55
+ end
56
+
57
+ def stub_gone_route_registration(path, type)
58
+ stub_route_put({
59
+ route: {
60
+ incoming_path: path,
61
+ route_type: type,
62
+ handler: "gone",
63
+ },
64
+ })
65
+ end
66
+
67
+ private
68
+
69
+ def stub_get_route(path, bearer_token)
70
+ stub_http_request(:get, "#{ROUTER_API_ENDPOINT}/routes")
71
+ .with(
72
+ query: { "incoming_path" => path },
73
+ headers: { "Authorization" => "Bearer #{bearer_token}" },
74
+ )
75
+ end
76
+
77
+ def stub_route_put(route)
78
+ stub_http_request(:put, "#{ROUTER_API_ENDPOINT}/routes")
79
+ .with(body: route.to_json)
80
+ .to_return(status: 201)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublishingPlatformApi
4
- VERSION = "0.8.1"
4
+ VERSION = "0.8.3"
5
5
  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.1
4
+ version: 0.8.3
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.7
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: []