pact_broker 2.4.2 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +4 -2
- data/CHANGELOG.md +54 -0
- data/DEVELOPER_DOCUMENTATION.md +11 -7
- data/README.md +5 -1
- data/UPGRADING.md +18 -0
- data/db/migrations/19_make_pact_version_content_sha_not_nullable.rb +9 -1
- data/db/migrations/25_make_pv_pacticipants_mandatory.rb +8 -0
- data/db/migrations/38_create_triggered_webhooks_table.rb +19 -0
- data/db/migrations/39_add_triggered_webhooks_fk_to_execution.rb +24 -0
- data/db/migrations/40_create_latest_triggered_webhooks_view.rb +24 -0
- data/db/migrations/41_migrate_execution_data.rb +47 -0
- data/db/test/backwards_compatibility/.rspec +3 -0
- data/db/test/backwards_compatibility/Appraisals +49 -0
- data/db/test/backwards_compatibility/Gemfile +11 -0
- data/db/test/backwards_compatibility/Rakefile +55 -0
- data/db/test/backwards_compatibility/config.ru +18 -0
- data/db/test/backwards_compatibility/gemfiles/1.18.0.gemfile +14 -0
- data/db/test/backwards_compatibility/gemfiles/1.18.0.gemfile.lock +210 -0
- data/db/test/backwards_compatibility/gemfiles/2.0.0.gemfile +14 -0
- data/db/test/backwards_compatibility/gemfiles/2.0.0.gemfile.lock +208 -0
- data/db/test/backwards_compatibility/gemfiles/2.1.0.gemfile +14 -0
- data/db/test/backwards_compatibility/gemfiles/2.1.0.gemfile.lock +209 -0
- data/db/test/backwards_compatibility/gemfiles/2.2.0.gemfile +14 -0
- data/db/test/backwards_compatibility/gemfiles/2.2.0.gemfile.lock +197 -0
- data/db/test/backwards_compatibility/gemfiles/2.3.0.gemfile +13 -0
- data/db/test/backwards_compatibility/gemfiles/2.3.0.gemfile.lock +196 -0
- data/db/test/backwards_compatibility/gemfiles/2.4.2.gemfile +13 -0
- data/db/test/backwards_compatibility/gemfiles/2.4.2.gemfile.lock +196 -0
- data/db/test/backwards_compatibility/gemfiles/head.gemfile +13 -0
- data/db/test/backwards_compatibility/gemfiles/head.gemfile.lock +200 -0
- data/db/test/backwards_compatibility/spec/fixtures/foo-bar.json +22 -0
- data/db/test/backwards_compatibility/spec/publish_pact_spec.rb +72 -0
- data/db/test/backwards_compatibility/spec/spec_helper.rb +20 -0
- data/db/test/backwards_compatibility/spec/support/fixture_helpers.rb +12 -0
- data/db/test/backwards_compatibility/spec/support/request_helpers.rb +20 -0
- data/example/Gemfile +2 -2
- data/example/pact_broker_database.sqlite3 +0 -0
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +1 -2
- data/lib/pact_broker/api/decorators/pact_decorator.rb +12 -10
- data/lib/pact_broker/api/decorators/pact_versions_decorator.rb +1 -2
- data/lib/pact_broker/api/decorators/pact_webhooks_status_decorator.rb +123 -0
- data/lib/pact_broker/api/decorators/versions_decorator.rb +17 -6
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +8 -10
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +0 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +13 -1
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +47 -3
- data/lib/pact_broker/api/resources/badge.rb +3 -3
- data/lib/pact_broker/api/resources/base_resource.rb +1 -1
- data/lib/pact_broker/api/resources/latest_pact.rb +5 -1
- data/lib/pact_broker/api/resources/pact.rb +5 -1
- data/lib/pact_broker/api/resources/pact_webhooks_status.rb +61 -0
- data/lib/pact_broker/api/resources/triggered_webhook_logs.rb +36 -0
- data/lib/pact_broker/api/resources/webhook.rb +31 -3
- data/lib/pact_broker/api/resources/webhook_execution.rb +12 -2
- data/lib/pact_broker/api.rb +3 -0
- data/lib/pact_broker/app.rb +11 -3
- data/lib/pact_broker/badges/service.rb +26 -5
- data/lib/pact_broker/configuration.rb +12 -5
- data/lib/pact_broker/constants.rb +1 -1
- data/lib/pact_broker/diagnostic/resources/heartbeat.rb +1 -2
- data/lib/pact_broker/doc/views/pact-webhooks.markdown +1 -1
- data/lib/pact_broker/doc/views/webhooks-webhooks.markdown +1 -1
- data/lib/pact_broker/doc/views/webhooks.markdown +1 -1
- data/lib/pact_broker/domain/relationship.rb +13 -4
- data/lib/pact_broker/domain/verification.rb +0 -4
- data/lib/pact_broker/domain/webhook.rb +2 -6
- data/lib/pact_broker/domain/webhook_execution_result.rb +1 -2
- data/lib/pact_broker/domain/webhook_request.rb +59 -40
- data/lib/pact_broker/pacticipants/service.rb +4 -3
- data/lib/pact_broker/pacts/repository.rb +8 -0
- data/lib/pact_broker/pacts/service.rb +2 -0
- data/lib/pact_broker/services.rb +1 -1
- data/lib/pact_broker/ui/view_models/relationship.rb +29 -2
- data/lib/pact_broker/ui/views/relationships/show.haml +7 -10
- data/lib/pact_broker/verifications/repository.rb +8 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/execution.rb +25 -4
- data/lib/pact_broker/webhooks/job.rb +55 -13
- data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +9 -0
- data/lib/pact_broker/webhooks/redact_logs.rb +10 -0
- data/lib/pact_broker/webhooks/repository.rb +76 -8
- data/lib/pact_broker/webhooks/service.rb +48 -8
- data/lib/pact_broker/webhooks/status.rb +29 -0
- data/lib/pact_broker/webhooks/triggered_webhook.rb +96 -0
- data/lib/pact_broker/webhooks/webhook.rb +19 -8
- data/lib/rack/pact_broker/database_transaction.rb +9 -3
- data/pact_broker.gemspec +3 -3
- data/public/javascripts/pact.js +5 -0
- data/public/stylesheets/pact.css +14 -1
- data/public/stylesheets/relationships.css +0 -1
- data/script/db-spec.sh +7 -0
- data/script/seed.rb +13 -8
- data/spec/features/create_webhook_spec.rb +1 -1
- data/spec/features/delete_pact_spec.rb +5 -1
- data/spec/features/delete_webhook_spec.rb +2 -1
- data/spec/features/edit_webhook_spec.rb +61 -0
- data/spec/features/execute_webhook_spec.rb +73 -0
- data/spec/features/get_latest_pact_badge_spec.rb +1 -1
- data/spec/features/get_latest_tagged_pact_badge_spec.rb +1 -1
- data/spec/features/get_latest_untagged_pact_badge_spec.rb +1 -1
- data/spec/features/get_pact_spec.rb +1 -1
- data/spec/features/merge_pact_spec.rb +1 -1
- data/spec/features/publish_pact_spec.rb +1 -1
- data/spec/integration/app_spec.rb +1 -1
- data/spec/integration/endpoints/group.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb +2 -1
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +8 -6
- data/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb +134 -0
- data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/representable_pact_spec.rb +1 -1
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +27 -1
- data/spec/lib/pact_broker/api/resources/badge_spec.rb +32 -15
- data/spec/lib/pact_broker/api/resources/base_resource_spec.rb +17 -0
- data/spec/lib/pact_broker/api/resources/latest_pact_spec.rb +5 -3
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +9 -2
- data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +28 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +15 -5
- data/spec/lib/pact_broker/api/resources/webhook_spec.rb +43 -31
- data/spec/lib/pact_broker/app_spec.rb +12 -8
- data/spec/lib/pact_broker/badges/service_spec.rb +15 -1
- data/spec/lib/pact_broker/configuration_spec.rb +3 -2
- data/spec/lib/pact_broker/domain/relationship_spec.rb +24 -0
- data/spec/lib/pact_broker/domain/webhook_request_spec.rb +47 -31
- data/spec/lib/pact_broker/domain/webhook_spec.rb +4 -6
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +16 -1
- data/spec/lib/pact_broker/pacts/repository_spec.rb +22 -1
- data/spec/lib/pact_broker/pacts/service_spec.rb +32 -1
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +44 -0
- data/spec/lib/pact_broker/verifications/repository_spec.rb +19 -0
- data/spec/lib/pact_broker/verifications/service_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/job_spec.rb +80 -19
- data/spec/lib/pact_broker/webhooks/redact_logs_spec.rb +49 -0
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +271 -21
- data/spec/lib/pact_broker/webhooks/service_spec.rb +70 -3
- data/spec/lib/pact_broker/webhooks/status_spec.rb +48 -0
- data/spec/lib/pact_broker/webhooks/triggered_webhook_spec.rb +40 -0
- data/spec/lib/rack/pact_broker/database_transaction_spec.rb +14 -4
- data/spec/migrations/23_pact_versions_spec.rb +8 -30
- data/spec/migrations/24_populate_pact_contents_spec.rb +3 -21
- data/spec/migrations/34_latest_tagged_pacts_spec.rb +1 -17
- data/spec/migrations/34_pact_revisions_spec.rb +7 -23
- data/spec/migrations/41_migrate_execution_data_spec.rb +109 -0
- data/spec/service_consumers/pact_helper.rb +5 -1
- data/spec/spec_helper.rb +15 -7
- data/spec/support/database_cleaner.rb +15 -2
- data/spec/support/migration_helpers.rb +16 -0
- data/spec/support/test_data_builder.rb +41 -9
- data/tasks/database.rb +7 -2
- data/tasks/db.rake +10 -0
- data/tasks/rspec.rake +1 -1
- data/vendor/hal-browser/browser.html +3 -2
- data/vendor/hal-browser/js/hal/resource.js +16 -2
- metadata +72 -13
- data/script/record_verification.sh +0 -4
@@ -0,0 +1,200 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../../..
|
3
|
+
specs:
|
4
|
+
pact_broker (2.4.2)
|
5
|
+
dry-types (~> 0.10.3)
|
6
|
+
dry-validation (~> 0.10.5)
|
7
|
+
haml (~> 4.0)
|
8
|
+
httparty (~> 0.14)
|
9
|
+
json (> 1.8, < 3.0)
|
10
|
+
pact (~> 1.14)
|
11
|
+
padrino-core (~> 0.14.1)
|
12
|
+
rack (~> 2.0)
|
13
|
+
rack-protection (~> 2.0)
|
14
|
+
redcarpet (~> 3.3, >= 3.3.2)
|
15
|
+
reform (~> 2.2)
|
16
|
+
roar (~> 1.1)
|
17
|
+
semver2 (~> 3.4.2)
|
18
|
+
sequel (~> 4.23)
|
19
|
+
sucker_punch (~> 2.0)
|
20
|
+
webmachine (= 1.5.0)
|
21
|
+
|
22
|
+
GEM
|
23
|
+
remote: https://rubygems.org/
|
24
|
+
specs:
|
25
|
+
appraisal (2.2.0)
|
26
|
+
bundler
|
27
|
+
rake
|
28
|
+
thor (>= 0.14.0)
|
29
|
+
as-notifications (1.0.1)
|
30
|
+
awesome_print (1.8.0)
|
31
|
+
concurrent-ruby (1.0.5)
|
32
|
+
daemons (1.2.4)
|
33
|
+
declarative (0.0.9)
|
34
|
+
declarative-builder (0.1.0)
|
35
|
+
declarative-option (< 0.2.0)
|
36
|
+
declarative-option (0.1.0)
|
37
|
+
diff-lcs (1.3)
|
38
|
+
disposable (0.4.3)
|
39
|
+
declarative (>= 0.0.9, < 1.0.0)
|
40
|
+
declarative-builder (< 0.2.0)
|
41
|
+
declarative-option (< 0.2.0)
|
42
|
+
representable (>= 2.4.0, <= 3.1.0)
|
43
|
+
uber (< 0.2.0)
|
44
|
+
dry-configurable (0.7.0)
|
45
|
+
concurrent-ruby (~> 1.0)
|
46
|
+
dry-container (0.6.0)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
49
|
+
dry-core (0.3.3)
|
50
|
+
concurrent-ruby (~> 1.0)
|
51
|
+
dry-equalizer (0.2.0)
|
52
|
+
dry-logic (0.4.1)
|
53
|
+
dry-container (~> 0.2, >= 0.2.6)
|
54
|
+
dry-core (~> 0.2)
|
55
|
+
dry-equalizer (~> 0.2)
|
56
|
+
dry-types (0.10.3)
|
57
|
+
concurrent-ruby (~> 1.0)
|
58
|
+
dry-configurable (~> 0.1)
|
59
|
+
dry-container (~> 0.3)
|
60
|
+
dry-core (~> 0.2, >= 0.2.1)
|
61
|
+
dry-equalizer (~> 0.2)
|
62
|
+
dry-logic (~> 0.4, >= 0.4.0)
|
63
|
+
inflecto (~> 0.0.0, >= 0.0.2)
|
64
|
+
dry-validation (0.10.7)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
67
|
+
dry-core (~> 0.2, >= 0.2.1)
|
68
|
+
dry-equalizer (~> 0.2)
|
69
|
+
dry-logic (~> 0.4, >= 0.4.0)
|
70
|
+
dry-types (~> 0.9, >= 0.9.0)
|
71
|
+
enumerable-lazy (0.0.2)
|
72
|
+
eventmachine (1.2.5)
|
73
|
+
find_a_port (1.0.1)
|
74
|
+
haml (4.0.7)
|
75
|
+
tilt
|
76
|
+
httparty (0.15.6)
|
77
|
+
multi_xml (>= 0.5.2)
|
78
|
+
i18n (0.8.6)
|
79
|
+
inflecto (0.0.2)
|
80
|
+
json (2.1.0)
|
81
|
+
multi_json (1.12.2)
|
82
|
+
multi_xml (0.6.0)
|
83
|
+
mustermann (1.0.1)
|
84
|
+
mustermann19 (0.4.4)
|
85
|
+
enumerable-lazy
|
86
|
+
mysql2 (0.3.21)
|
87
|
+
pact (1.15.0)
|
88
|
+
json (> 1.8.5)
|
89
|
+
pact-mock_service (~> 2.0)
|
90
|
+
pact-support (~> 1.1)
|
91
|
+
rack-test (~> 0.6.2)
|
92
|
+
randexp (~> 0.1.7)
|
93
|
+
rspec (>= 2.14)
|
94
|
+
term-ansicolor (~> 1.0)
|
95
|
+
thor
|
96
|
+
webrick
|
97
|
+
pact-mock_service (2.1.0)
|
98
|
+
find_a_port (~> 1.0.1)
|
99
|
+
json
|
100
|
+
pact-support (~> 1.0)
|
101
|
+
rack
|
102
|
+
rack-test (~> 0.6.2)
|
103
|
+
rspec (>= 2.14)
|
104
|
+
term-ansicolor (~> 1.0)
|
105
|
+
thor
|
106
|
+
webrick
|
107
|
+
pact-support (1.1.6)
|
108
|
+
awesome_print (~> 1.1)
|
109
|
+
find_a_port (~> 1.0.1)
|
110
|
+
json
|
111
|
+
rack-test (~> 0.6.2)
|
112
|
+
randexp (~> 0.1.7)
|
113
|
+
rspec (>= 2.14)
|
114
|
+
term-ansicolor (~> 1.0)
|
115
|
+
thor
|
116
|
+
padrino-core (0.14.1.1)
|
117
|
+
mustermann19
|
118
|
+
padrino-support (= 0.14.1.1)
|
119
|
+
rack-protection (>= 1.5.0)
|
120
|
+
sinatra (>= 1.4.6)
|
121
|
+
thor (~> 0.18)
|
122
|
+
padrino-support (0.14.1.1)
|
123
|
+
pg (0.21.0)
|
124
|
+
rack (2.0.3)
|
125
|
+
rack-protection (2.0.0)
|
126
|
+
rack
|
127
|
+
rack-proxy (0.6.2)
|
128
|
+
rack
|
129
|
+
rack-reverse-proxy (0.12.0)
|
130
|
+
rack (>= 1.0.0)
|
131
|
+
rack-proxy (~> 0.6, >= 0.6.1)
|
132
|
+
rack-test (0.6.3)
|
133
|
+
rack (>= 1.0)
|
134
|
+
rake (12.0.0)
|
135
|
+
randexp (0.1.7)
|
136
|
+
redcarpet (3.4.0)
|
137
|
+
reform (2.2.4)
|
138
|
+
disposable (>= 0.4.1)
|
139
|
+
representable (>= 2.4.0, < 3.1.0)
|
140
|
+
representable (3.0.4)
|
141
|
+
declarative (< 0.1.0)
|
142
|
+
declarative-option (< 0.2.0)
|
143
|
+
uber (< 0.2.0)
|
144
|
+
roar (1.1.0)
|
145
|
+
representable (~> 3.0.0)
|
146
|
+
rspec (3.6.0)
|
147
|
+
rspec-core (~> 3.6.0)
|
148
|
+
rspec-expectations (~> 3.6.0)
|
149
|
+
rspec-mocks (~> 3.6.0)
|
150
|
+
rspec-core (3.6.0)
|
151
|
+
rspec-support (~> 3.6.0)
|
152
|
+
rspec-expectations (3.6.0)
|
153
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
154
|
+
rspec-support (~> 3.6.0)
|
155
|
+
rspec-mocks (3.6.0)
|
156
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
157
|
+
rspec-support (~> 3.6.0)
|
158
|
+
rspec-support (3.6.0)
|
159
|
+
semver2 (3.4.2)
|
160
|
+
sequel (4.49.0)
|
161
|
+
sinatra (2.0.0)
|
162
|
+
mustermann (~> 1.0)
|
163
|
+
rack (~> 2.0)
|
164
|
+
rack-protection (= 2.0.0)
|
165
|
+
tilt (~> 2.0)
|
166
|
+
sqlite3 (1.3.13)
|
167
|
+
sucker_punch (2.0.3)
|
168
|
+
concurrent-ruby (~> 1.0.0)
|
169
|
+
term-ansicolor (1.6.0)
|
170
|
+
tins (~> 1.0)
|
171
|
+
thin (1.7.2)
|
172
|
+
daemons (~> 1.0, >= 1.0.9)
|
173
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
174
|
+
rack (>= 1, < 3)
|
175
|
+
thor (0.20.0)
|
176
|
+
tilt (2.0.8)
|
177
|
+
tins (1.15.0)
|
178
|
+
uber (0.1.0)
|
179
|
+
webmachine (1.5.0)
|
180
|
+
as-notifications (~> 1.0)
|
181
|
+
i18n (>= 0.4.0)
|
182
|
+
multi_json
|
183
|
+
webrick (1.3.1)
|
184
|
+
|
185
|
+
PLATFORMS
|
186
|
+
ruby
|
187
|
+
|
188
|
+
DEPENDENCIES
|
189
|
+
appraisal
|
190
|
+
mysql2 (~> 0.3.15)
|
191
|
+
pact_broker!
|
192
|
+
pg (~> 0.21)
|
193
|
+
rack-reverse-proxy (~> 0.12)
|
194
|
+
rake (~> 12.0)
|
195
|
+
rspec
|
196
|
+
sqlite3 (~> 1.3)
|
197
|
+
thin (~> 1.3)
|
198
|
+
|
199
|
+
BUNDLED WITH
|
200
|
+
1.15.4
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"consumer": {
|
3
|
+
"name": "Foo"
|
4
|
+
},
|
5
|
+
"provider": {
|
6
|
+
"name": "Bar"
|
7
|
+
},
|
8
|
+
"interactions": [
|
9
|
+
{
|
10
|
+
"description" : "a request for something",
|
11
|
+
"providerState": null,
|
12
|
+
"request": {
|
13
|
+
"method": "get",
|
14
|
+
"path" : "/something"
|
15
|
+
},
|
16
|
+
"response": {
|
17
|
+
"status": 200,
|
18
|
+
"body" : "something"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rack/reverse_proxy'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
CODE_VERSION = ENV.fetch('PACT_BROKER_CODE_VERSION')
|
5
|
+
DATABASE_VERSION = ENV.fetch('PACT_BROKER_DATABASE_VERSION')
|
6
|
+
CONSUMER_VERSION = CODE_VERSION == 'head' ? '100.100.100' : CODE_VERSION
|
7
|
+
TAG = SecureRandom.hex
|
8
|
+
|
9
|
+
describe "Code version #{CODE_VERSION} running against database version #{DATABASE_VERSION}" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
wait_for_server_to_start
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:path) { "/pacts/provider/Bar/consumer/Foo/version/#{CONSUMER_VERSION}" }
|
16
|
+
let(:response_body_json) { JSON.parse(subject.body) }
|
17
|
+
let(:pact_content) do
|
18
|
+
pact = load_json_fixture('foo-bar.json')
|
19
|
+
pact['interactions'][0]['providerState'] = "the code version is #{CODE_VERSION}"
|
20
|
+
pact.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:app) do
|
24
|
+
Rack::ReverseProxy.new do
|
25
|
+
reverse_proxy_options preserve_host: true
|
26
|
+
reverse_proxy '/', "http://localhost:#{ENV.fetch('PORT')}/"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "tagging a consumer version" do
|
31
|
+
let(:path) { "/pacticipants/Foo/versions/#{CONSUMER_VERSION}/tags/#{TAG}"}
|
32
|
+
subject { put path, nil, {'CONTENT_TYPE' => 'application/json' }; last_response }
|
33
|
+
|
34
|
+
it "returns a success status" do
|
35
|
+
expect(subject.status.to_s).to match /20\d/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "publishing a pact" do
|
40
|
+
subject { put path, pact_content, {'CONTENT_TYPE' => 'application/json' }; last_response }
|
41
|
+
|
42
|
+
it "returns a success status" do
|
43
|
+
expect(subject.status.to_s).to match /20\d/
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "retrieving a pact" do
|
48
|
+
subject { get path; last_response }
|
49
|
+
|
50
|
+
it "returns the pact in the body" do
|
51
|
+
expect(response_body_json).to include JSON.parse(pact_content)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "retrieving the latest tagged pact" do
|
56
|
+
let(:path) { "/pacts/provider/Bar/consumer/Foo/latest" }
|
57
|
+
subject { get path; last_response }
|
58
|
+
|
59
|
+
it "returns the latest pact" do
|
60
|
+
expect(subject.headers['X-Pact-Consumer-Version']).to eq '100.100.100'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "retrieving the latest tagged pact" do
|
65
|
+
let(:path) { "/pacts/provider/Bar/consumer/Foo/latest/#{TAG}" }
|
66
|
+
subject { get path; last_response }
|
67
|
+
|
68
|
+
it "returns the pact in the body" do
|
69
|
+
expect(response_body_json).to include JSON.parse(pact_content)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'support/fixture_helpers'
|
2
|
+
require 'support/request_helpers'
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
RSpec.configure do | config |
|
6
|
+
|
7
|
+
config.include Rack::Test::Methods
|
8
|
+
config.include RequestHelpers
|
9
|
+
config.include FixtureHelpers
|
10
|
+
|
11
|
+
config.mock_with :rspec do |mocks|
|
12
|
+
mocks.verify_partial_doubles = true
|
13
|
+
end
|
14
|
+
|
15
|
+
config.after(:suite) do
|
16
|
+
puts "***************************************************************************"
|
17
|
+
puts "Pact Broker logs are in db/test/backwards_compatibility/log/pact_broker.log"
|
18
|
+
puts "***************************************************************************"
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RequestHelpers
|
2
|
+
|
3
|
+
def wait_for_server_to_start
|
4
|
+
unless ENV['OK']
|
5
|
+
retries = 0
|
6
|
+
begin
|
7
|
+
get "/"
|
8
|
+
ENV['OK'] = 'true'
|
9
|
+
rescue Errno::ECONNREFUSED => error
|
10
|
+
if retries < 10
|
11
|
+
retries += 1
|
12
|
+
sleep 1
|
13
|
+
retry
|
14
|
+
else
|
15
|
+
raise error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/example/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'pact_broker'
|
4
|
-
gem 'sqlite3' # Sqlite is just for testing, replace this with your choice of database driver
|
4
|
+
gem 'sqlite3', '~>1.3' # Sqlite is just for testing, replace this with your choice of database driver
|
5
5
|
# gem 'pg' # Recommended production gem for postgres
|
6
|
-
gem 'thin' # Keep, or replace with your choice of web server
|
6
|
+
gem 'thin', '~>1.7' # Keep, or replace with your choice of web server
|
Binary file
|
@@ -29,8 +29,7 @@ module PactBroker
|
|
29
29
|
represented.collect do | pact |
|
30
30
|
{
|
31
31
|
:href => latest_pact_url(options[:base_url], pact),
|
32
|
-
:
|
33
|
-
:title => "Pact"
|
32
|
+
:title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}",
|
34
33
|
}
|
35
34
|
end
|
36
35
|
end
|
@@ -56,25 +56,29 @@ module PactBroker
|
|
56
56
|
|
57
57
|
link :'pb:latest-pact-version' do | options |
|
58
58
|
{
|
59
|
-
title: "
|
60
|
-
name: "Latest version of this pact",
|
59
|
+
title: "Latest version of this pact",
|
61
60
|
href: latest_pact_url(options.fetch(:base_url), represented)
|
62
61
|
|
63
62
|
}
|
64
63
|
end
|
65
64
|
|
65
|
+
link :'pb:all-pact-versions' do | options |
|
66
|
+
{
|
67
|
+
title: "All versions of this pact",
|
68
|
+
href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
66
72
|
link :'pb:latest-untagged-pact-version' do | options |
|
67
73
|
{
|
68
|
-
title: "
|
69
|
-
name: "Latest untagged version of this pact",
|
74
|
+
title: "Latest untagged version of this pact",
|
70
75
|
href: latest_untagged_pact_url(represented, options.fetch(:base_url))
|
71
76
|
}
|
72
77
|
end
|
73
78
|
|
74
79
|
link :'pb:latest-tagged-pact-version' do | options |
|
75
80
|
{
|
76
|
-
title: "
|
77
|
-
name: "Latest tagged version of this pact",
|
81
|
+
title: "Latest tagged version of this pact",
|
78
82
|
href: "#{latest_pact_url(options.fetch(:base_url), represented)}/{tag}",
|
79
83
|
templated: true
|
80
84
|
}
|
@@ -82,16 +86,14 @@ module PactBroker
|
|
82
86
|
|
83
87
|
link :'pb:previous-distinct' do | options |
|
84
88
|
{
|
85
|
-
title: "
|
86
|
-
name: "Previous distinct version of this pact",
|
89
|
+
title: "Previous distinct version of this pact",
|
87
90
|
href: previous_distinct_pact_version_url(represented, options.fetch(:base_url))
|
88
91
|
}
|
89
92
|
end
|
90
93
|
|
91
94
|
link :'pb:diff-previous-distinct' do | options |
|
92
95
|
{
|
93
|
-
title: "Diff",
|
94
|
-
name: "Diff with previous distinct version of this pact",
|
96
|
+
title: "Diff with previous distinct version of this pact",
|
95
97
|
href: previous_distinct_diff_url(represented, options.fetch(:base_url))
|
96
98
|
|
97
99
|
}
|
@@ -11,8 +11,7 @@ module PactBroker
|
|
11
11
|
link :self do | context |
|
12
12
|
{
|
13
13
|
href: context[:resource_url],
|
14
|
-
title: "
|
15
|
-
name: "All versions of the pact between #{context[:consumer_name]} and #{context[:provider_name]}"
|
14
|
+
title: "All versions of the pact between #{context[:consumer_name]} and #{context[:provider_name]}"
|
16
15
|
}
|
17
16
|
end
|
18
17
|
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require_relative 'base_decorator'
|
2
|
+
require_relative 'timestamps'
|
3
|
+
require_relative 'pact_version_decorator'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
module Api
|
7
|
+
module Decorators
|
8
|
+
|
9
|
+
class TriggeredWebhookDecorator < BaseDecorator
|
10
|
+
property :request_description, as: :name
|
11
|
+
property :status
|
12
|
+
property :number_of_attempts_made, as: :attemptsMade
|
13
|
+
property :number_of_attempts_remaining, as: :attemptsRemaining
|
14
|
+
property :trigger_type, as: :triggerType
|
15
|
+
|
16
|
+
property :created_at, as: :triggeredAt
|
17
|
+
|
18
|
+
link :logs do | context |
|
19
|
+
{
|
20
|
+
href: triggered_webhook_logs_url(represented, context[:base_url]),
|
21
|
+
title: "Webhook execution logs",
|
22
|
+
name: represented.request_description
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
link :'pb:webhook' do | context |
|
27
|
+
{
|
28
|
+
href: webhook_url(represented.webhook_uuid, context[:base_url]),
|
29
|
+
title: "Webhook",
|
30
|
+
name: represented.request_description
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class PactWebhooksStatusDecorator < BaseDecorator
|
36
|
+
|
37
|
+
property :summary, exec_context: :decorator do
|
38
|
+
property :success, as: :successful, default: 0
|
39
|
+
property :failure, as: :failed, default: 0
|
40
|
+
property :retrying
|
41
|
+
property :not_run, as: :notRun
|
42
|
+
end
|
43
|
+
|
44
|
+
collection :entries, as: :triggeredWebhooks, embedded: true, :extend => TriggeredWebhookDecorator
|
45
|
+
|
46
|
+
link :self do | context |
|
47
|
+
{
|
48
|
+
href: context[:resource_url],
|
49
|
+
title: "Webhooks status"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
links :'pb:error-logs' do | context |
|
54
|
+
triggered_webhooks_with_error_logs.collect do | triggered_webhook |
|
55
|
+
{
|
56
|
+
href: triggered_webhook_logs_url(triggered_webhook, context[:base_url]),
|
57
|
+
title: "Error logs",
|
58
|
+
name: triggered_webhook.request_description
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
link :'pb:pact-webhooks' do | context |
|
64
|
+
{
|
65
|
+
title: "Webhooks for the pact between #{context[:consumer_name]} and #{context[:provider_name]}",
|
66
|
+
href: webhooks_for_pact_url(fake_consumer(context), fake_provider(context), context.fetch(:base_url))
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
link :'pb:pact-version' do | context |
|
71
|
+
if pact
|
72
|
+
{
|
73
|
+
href: pact_url(context[:base_url], pact),
|
74
|
+
title: "Pact",
|
75
|
+
name: pact.name
|
76
|
+
}
|
77
|
+
else
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
link :'pb:consumer' do | context |
|
83
|
+
{
|
84
|
+
href: pacticipant_url(context[:base_url], fake_consumer(context)),
|
85
|
+
title: "Consumer",
|
86
|
+
name: context[:consumer_name]
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
link :'pb:provider' do | context |
|
91
|
+
{
|
92
|
+
href: pacticipant_url(context[:base_url], fake_provider(context)),
|
93
|
+
title: "Provider",
|
94
|
+
name: context[:provider_name]
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
def summary
|
99
|
+
counts = represented.group_by(&:status).each_with_object({}) do | (status, triggered_webhooks), counts |
|
100
|
+
counts[status] = triggered_webhooks.count
|
101
|
+
end
|
102
|
+
OpenStruct.new(counts)
|
103
|
+
end
|
104
|
+
|
105
|
+
def triggered_webhooks_with_error_logs
|
106
|
+
represented.select{|w| w.failure? || w.retrying? }
|
107
|
+
end
|
108
|
+
|
109
|
+
def pact
|
110
|
+
represented.any? ? represented.first.pact_publication : nil
|
111
|
+
end
|
112
|
+
|
113
|
+
def fake_consumer context
|
114
|
+
OpenStruct.new(name: context[:consumer_name])
|
115
|
+
end
|
116
|
+
|
117
|
+
def fake_provider context
|
118
|
+
OpenStruct.new(name: context[:provider_name])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -2,12 +2,8 @@ require_relative 'base_decorator'
|
|
2
2
|
require_relative 'version_decorator'
|
3
3
|
|
4
4
|
module PactBroker
|
5
|
-
|
6
5
|
module Api
|
7
|
-
|
8
6
|
module Decorators
|
9
|
-
|
10
|
-
|
11
7
|
class VersionsDecorator < BaseDecorator
|
12
8
|
|
13
9
|
collection :entries, as: :versions, embedded: true, :extend => PactBroker::Api::Decorators::VersionDecorator
|
@@ -19,14 +15,14 @@ module PactBroker
|
|
19
15
|
}
|
20
16
|
end
|
21
17
|
|
22
|
-
link :pacticipant do | context |
|
18
|
+
link :'pb:pacticipant' do | context |
|
23
19
|
{
|
24
20
|
href: pacticipant_url(context[:base_url], OpenStruct.new(name: context[:pacticipant_name])),
|
25
21
|
title: context[:pacticipant_name]
|
26
22
|
}
|
27
23
|
end
|
28
24
|
|
29
|
-
links :'versions' do | context |
|
25
|
+
links :'pb:versions' do | context |
|
30
26
|
represented.collect do | version |
|
31
27
|
{
|
32
28
|
:href => version_url(context[:base_url], version),
|
@@ -35,6 +31,21 @@ module PactBroker
|
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
34
|
+
link :pacticipant do | context |
|
35
|
+
{
|
36
|
+
href: pacticipant_url(context[:base_url], OpenStruct.new(name: context[:pacticipant_name])),
|
37
|
+
title: 'Deprecated - please use pb:pacticipant'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
links :'versions' do | context |
|
42
|
+
represented.collect do | version |
|
43
|
+
{
|
44
|
+
:href => version_url(context[:base_url], version),
|
45
|
+
:title => 'Deprecated - please use pb:versions'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
@@ -24,6 +24,13 @@ module PactBroker
|
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
+
link :'pb:execute' do | options |
|
28
|
+
{
|
29
|
+
title: "Test the execution of the webhook by sending a POST request to this URL",
|
30
|
+
href: webhook_execution_url(represented, options[:base_url])
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
27
34
|
link :'pb:pact-webhooks' do | options |
|
28
35
|
{
|
29
36
|
title: "All webhooks for the pact between #{represented.consumer.name} and #{represented.provider.name}",
|
@@ -37,16 +44,7 @@ module PactBroker
|
|
37
44
|
href: webhooks_url(options[:base_url])
|
38
45
|
}
|
39
46
|
end
|
40
|
-
|
41
|
-
link :'pb:execute' do | options |
|
42
|
-
{
|
43
|
-
title: "Test the execution of the webhook by sending a POST request to this URL",
|
44
|
-
href: webhook_execution_url(represented, options[:base_url])
|
45
|
-
}
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
52
|
-
end
|
50
|
+
end
|
@@ -117,10 +117,22 @@ module PactBroker
|
|
117
117
|
"#{base_url}/webhooks/#{webhook.uuid}/execute"
|
118
118
|
end
|
119
119
|
|
120
|
-
def webhooks_for_pact_url consumer, provider, base_url
|
120
|
+
def webhooks_for_pact_url consumer, provider, base_url = ''
|
121
121
|
"#{base_url}/webhooks/provider/#{url_encode(provider.name)}/consumer/#{url_encode(consumer.name)}"
|
122
122
|
end
|
123
123
|
|
124
|
+
def webhooks_status_url consumer, provider, base_url = ''
|
125
|
+
"#{webhooks_for_pact_url(consumer, provider, base_url)}/status"
|
126
|
+
end
|
127
|
+
|
128
|
+
def triggered_webhook_logs_url triggered_webhook, base_url
|
129
|
+
"#{base_url}/webhooks/#{triggered_webhook.webhook_uuid}/trigger/#{triggered_webhook.trigger_uuid}/logs"
|
130
|
+
end
|
131
|
+
|
132
|
+
def badge_url_for_latest_pact pact, base_url = ''
|
133
|
+
"#{latest_pact_url(base_url, pact)}/badge.svg"
|
134
|
+
end
|
135
|
+
|
124
136
|
def hal_browser_url target_url
|
125
137
|
"/hal-browser/browser.html#" + target_url
|
126
138
|
end
|