pact_broker 2.72.0 → 2.76.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/.optic/.gitignore +2 -0
- data/.optic/api/specification.json +1 -0
- data/.optic/ignore +14 -0
- data/CHANGELOG.md +66 -0
- data/DEVELOPER_SETUP.md +9 -0
- data/Dockerfile +1 -0
- data/ISSUES.md +3 -3
- data/README.md +1 -1
- data/config/database.yml +1 -1
- data/db/migrations/20210115_add_webhook_foreign_key_indexes.rb +49 -0
- data/db/migrations/20210116_add_context_to_triggered_webhook.rb +11 -0
- data/db/migrations/migration_helper.rb +8 -0
- data/docker-compose-issue-repro-with-pact-broker-docker-image.yml +33 -0
- data/docker-compose-test.yml +4 -4
- data/lib/db.rb +1 -0
- data/lib/pact_broker/api.rb +13 -2
- data/lib/pact_broker/api/decorators.rb +3 -7
- data/lib/pact_broker/api/decorators/configuration.rb +33 -0
- data/lib/pact_broker/api/decorators/decorator_context_creator.rb +13 -0
- data/lib/pact_broker/api/decorators/extended_pact_decorator.rb +9 -1
- data/lib/pact_broker/api/decorators/extended_verification_decorator.rb +8 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +9 -4
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +1 -0
- data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +2 -3
- data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -0
- data/lib/pact_broker/api/decorators/tag_decorator.rb +0 -3
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +3 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +4 -4
- data/lib/pact_broker/api/paths.rb +5 -0
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +2 -2
- data/lib/pact_broker/api/resources/all_webhooks.rb +3 -3
- data/lib/pact_broker/api/resources/can_i_deploy_badge.rb +1 -1
- data/lib/pact_broker/api/resources/dashboard.rb +2 -2
- data/lib/pact_broker/api/resources/default_base_resource.rb +37 -12
- data/lib/pact_broker/api/resources/error_handler.rb +1 -1
- data/lib/pact_broker/api/resources/error_response_body_generator.rb +41 -0
- data/lib/pact_broker/api/resources/group.rb +1 -1
- data/lib/pact_broker/api/resources/integrations.rb +1 -1
- data/lib/pact_broker/api/resources/label.rb +1 -1
- data/lib/pact_broker/api/resources/latest_pact.rb +2 -2
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +2 -2
- data/lib/pact_broker/api/resources/matrix.rb +2 -2
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +1 -1
- data/lib/pact_broker/api/resources/metadata_resource_methods.rb +2 -1
- data/lib/pact_broker/api/resources/pact.rb +2 -2
- data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +1 -1
- data/lib/pact_broker/api/resources/pact_versions.rb +1 -1
- data/lib/pact_broker/api/resources/pact_webhooks.rb +3 -3
- data/lib/pact_broker/api/resources/pact_webhooks_status.rb +2 -2
- data/lib/pact_broker/api/resources/pacticipant.rb +1 -1
- data/lib/pact_broker/api/resources/pacticipants.rb +3 -3
- data/lib/pact_broker/api/resources/pacticipants_for_label.rb +1 -1
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
- data/lib/pact_broker/api/resources/provider_pacts.rb +1 -7
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +2 -2
- data/lib/pact_broker/api/resources/relationships.rb +1 -1
- data/lib/pact_broker/api/resources/tag.rb +1 -1
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +1 -1
- data/lib/pact_broker/api/resources/verification.rb +2 -2
- data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +1 -1
- data/lib/pact_broker/api/resources/verifications.rb +1 -1
- data/lib/pact_broker/api/resources/version.rb +1 -1
- data/lib/pact_broker/api/resources/versions.rb +1 -1
- data/lib/pact_broker/api/resources/webhook.rb +2 -2
- data/lib/pact_broker/api/resources/webhook_execution.rb +4 -4
- data/lib/pact_broker/api/resources/webhook_execution_methods.rb +1 -3
- data/lib/pact_broker/api/resources/webhooks.rb +3 -3
- data/lib/pact_broker/app.rb +14 -3
- data/lib/pact_broker/application_context.rb +41 -0
- data/lib/pact_broker/configuration.rb +12 -4
- data/lib/pact_broker/doc/controllers/app.rb +3 -2
- data/lib/pact_broker/domain/version.rb +13 -6
- data/lib/pact_broker/domain/webhook_request.rb +1 -1
- data/lib/pact_broker/error.rb +0 -2
- data/lib/pact_broker/errors.rb +28 -0
- data/lib/pact_broker/errors/error_logger.rb +25 -0
- data/lib/pact_broker/metrics/service.rb +12 -1
- data/lib/pact_broker/pacts/metadata.rb +53 -8
- data/lib/pact_broker/pacts/repository.rb +10 -17
- data/lib/pact_broker/pacts/selector.rb +22 -0
- data/lib/pact_broker/pacts/selectors.rb +4 -0
- data/lib/pact_broker/services.rb +106 -31
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +2 -0
- data/lib/pact_broker/test/http_test_data_builder.rb +83 -21
- data/lib/pact_broker/test/test_data_builder.rb +3 -2
- data/lib/pact_broker/ui/views/index/_getting-started.haml +1 -1
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +16 -16
- data/lib/pact_broker/ui/views/index/show.haml +6 -6
- data/lib/pact_broker/ui/views/layouts/main.haml +2 -2
- data/lib/pact_broker/ui/views/matrix/show.haml +32 -33
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/execution_configuration.rb +4 -0
- data/lib/pact_broker/webhooks/execution_configuration_creator.rb +14 -0
- data/lib/pact_broker/webhooks/repository.rb +3 -2
- data/lib/pact_broker/webhooks/service.rb +2 -1
- data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -0
- data/lib/rack/pact_broker/hal_browser_redirect.rb +42 -0
- data/lib/rack/pact_broker/set_base_url.rb +22 -0
- data/lib/sequel/extensions/statement_timeout.rb +22 -0
- data/optic.yml +5 -0
- data/pact_broker.gemspec +1 -1
- data/public/css/bootstrap-grid.css +3719 -0
- data/public/css/bootstrap-grid.css.map +1 -0
- data/public/css/bootstrap-grid.min.css +7 -0
- data/public/css/bootstrap-grid.min.css.map +1 -0
- data/public/css/bootstrap-reboot.css +331 -0
- data/public/css/bootstrap-reboot.css.map +1 -0
- data/public/css/bootstrap-reboot.min.css +8 -0
- data/public/css/bootstrap-reboot.min.css.map +1 -0
- data/public/css/bootstrap.css +8885 -5604
- data/public/css/bootstrap.css.map +1 -1
- data/public/css/bootstrap.min.css +4 -3
- data/public/css/bootstrap.min.css.map +1 -1
- data/public/images/alert.svg +1 -0
- data/public/images/arrow-switch.svg +1 -0
- data/public/images/check.svg +1 -0
- data/public/images/clock.svg +1 -0
- data/public/images/copy.svg +1 -0
- data/public/images/kebab-horizontal.svg +1 -0
- data/public/javascripts/clipboard.js +3 -3
- data/public/javascripts/{jquery-3.3.1.js → jquery-3.5.1.js} +1150 -642
- data/public/javascripts/jquery-3.5.1.min.js +2 -0
- data/public/javascripts/jquery-3.5.1.min.map +1 -0
- data/public/javascripts/matrix.js +2 -2
- data/public/js/bootstrap.bundle.js +7013 -0
- data/public/js/bootstrap.bundle.js.map +1 -0
- data/public/js/bootstrap.bundle.min.js +7 -0
- data/public/js/bootstrap.bundle.min.js.map +1 -0
- data/public/js/bootstrap.js +3862 -1804
- data/public/js/bootstrap.js.map +1 -0
- data/public/js/bootstrap.min.js +6 -6
- data/public/js/bootstrap.min.js.map +1 -0
- data/public/stylesheets/index.css +56 -3
- data/public/stylesheets/matrix.css +55 -5
- data/public/stylesheets/pact.css +14 -0
- data/regression/.gitignore +1 -0
- data/regression/can_i_deploy_spec.rb +42 -0
- data/regression/regression_helper.rb +37 -0
- data/regression/script/approval-all.sh +6 -0
- data/script/exercise-api-for-optic.sh +3 -0
- data/script/reproduce-issue-starting-up.rb +43 -0
- data/script/reproduce-issue.rb +9 -21
- data/spec/lib/pact_broker/api/decorators/extended_pact_decorator_spec.rb +1 -0
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +20 -8
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +5 -7
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +10 -6
- data/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +59 -10
- data/spec/lib/pact_broker/api/resources/error_response_body_generator_spec.rb +69 -0
- data/spec/lib/pact_broker/db/log_quietener_spec.rb +1 -1
- data/spec/lib/pact_broker/doc/controllers/app_spec.rb +3 -5
- data/spec/lib/pact_broker/errors/error_logger_spec.rb +62 -0
- data/spec/lib/pact_broker/errors_spec.rb +55 -0
- data/spec/lib/pact_broker/pacts/metadata_spec.rb +73 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +2 -2
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +33 -13
- data/spec/lib/pact_broker/pacts/selected_pact_spec.rb +23 -0
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +5 -2
- data/spec/lib/pact_broker/webhooks/service_spec.rb +2 -1
- data/spec/lib/rack/pact_broker/hal_browser_redirect_spec.rb +27 -0
- data/tasks/rspec.rake +6 -0
- metadata +65 -17
- data/public/css/bootstrap-theme.css +0 -587
- data/public/css/bootstrap-theme.css.map +0 -1
- data/public/css/bootstrap-theme.min.css +0 -6
- data/public/css/bootstrap-theme.min.css.map +0 -1
- data/public/fonts/glyphicons-halflings-regular.svg +0 -288
- data/public/javascripts/jquery-3.3.1.min.js +0 -2
- data/public/javascripts/jquery-3.3.1.min.map +0 -1
- data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +0 -195
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14eafba260b6b71dd75c725768863c0f923e167bdb37084606a0b51d110d363
|
4
|
+
data.tar.gz: 545dabeda5ede4c25508e8ca5135d94dacec61f9df1692207787bdc6e3227ec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8df83a6bf1588e8a9a96f915b0926d1a164ebd8f246d7ed831d83d43610bcbaf38875800bbd56ab792af3c9b2b6a9b2f415b6e3a581b6d8955e80248b25d67d
|
7
|
+
data.tar.gz: f1bb7162afee7913b9ac53fc523aa47d021f760350cca52758af1f626f3c440dd73bd02921254487820b1724b5a4c3e334283f728e7b279d92a69b29995de074
|
data/.github/workflows/test.yml
CHANGED
data/.optic/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
[]
|
data/.optic/ignore
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Default Ignore Rules
|
2
|
+
# Learn to configure your own at https://useoptic.com/docs
|
3
|
+
OPTIONS *
|
4
|
+
HEAD *
|
5
|
+
GET (.*).htm
|
6
|
+
GET (.*).html
|
7
|
+
GET (.*).css
|
8
|
+
GET (.*).js
|
9
|
+
GET (.*).woff
|
10
|
+
GET (.*).png
|
11
|
+
GET (.*).jpg
|
12
|
+
GET (.*).jpeg
|
13
|
+
GET (.*).svg
|
14
|
+
GET (.*).gif
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,69 @@
|
|
1
|
+
<a name="v2.76.0"></a>
|
2
|
+
### v2.76.0 (2021-01-21)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* **verification results**
|
7
|
+
* redirect requests for verification results to the HAL browser if requested in a web browser ([0f948de5](/../../commit/0f948de5))
|
8
|
+
|
9
|
+
<a name="v2.75.0"></a>
|
10
|
+
### v2.75.0 (2021-01-18)
|
11
|
+
|
12
|
+
#### Features
|
13
|
+
|
14
|
+
* upgrade bootstrap (#370) ([a457c337](/../../commit/a457c337))
|
15
|
+
* add indexes to webhook_executions and triggered_webhooks tables ([b05e7dbe](/../../commit/b05e7dbe))
|
16
|
+
|
17
|
+
* **webhook**
|
18
|
+
* set read and open timeouts ([8b502c44](/../../commit/8b502c44))
|
19
|
+
|
20
|
+
#### Bug Fixes
|
21
|
+
|
22
|
+
* **ui**
|
23
|
+
* upgrade to jquery-3.5.1 to address vulnerabilities in jquery-3.3.1 ([de41b231](/../../commit/de41b231))
|
24
|
+
|
25
|
+
* **deps**
|
26
|
+
* upgrade redcarpet for CVE-2020-26298 ([b57aad32](/../../commit/b57aad32))
|
27
|
+
|
28
|
+
<a name="v2.74.1"></a>
|
29
|
+
### v2.74.1 (2021-01-05)
|
30
|
+
|
31
|
+
#### Bug Fixes
|
32
|
+
|
33
|
+
* **deps**
|
34
|
+
* remove manual specification for nokogiri now the fix for CVE-2020-26247 has been released in 1.11 ([771378a9](/../../commit/771378a9))
|
35
|
+
|
36
|
+
<a name="v2.74.0"></a>
|
37
|
+
### v2.74.0 (2021-01-04)
|
38
|
+
|
39
|
+
#### Features
|
40
|
+
|
41
|
+
* include the consumer version selectors in the metadata of the 'pact for verification' URL ([32bbe1c3](/../../commit/32bbe1c3))
|
42
|
+
|
43
|
+
#### Bug Fixes
|
44
|
+
|
45
|
+
* **deps**
|
46
|
+
* update nokogiri for CVE-2020-26247 ([336ec897](/../../commit/336ec897))
|
47
|
+
|
48
|
+
<a name="v2.73.0"></a>
|
49
|
+
### v2.73.0 (2020-12-16)
|
50
|
+
|
51
|
+
#### Features
|
52
|
+
|
53
|
+
* **wip**
|
54
|
+
* permenently enable feature that keeps pacts as WIP when verified via the URL from a webhook triggered by pact publication ([70071373](/../../commit/70071373))
|
55
|
+
|
56
|
+
* allow error causes to be configured to log at warning level ([3a7bf5ea](/../../commit/3a7bf5ea))
|
57
|
+
* add self relations for tags in matrix resource ([727cee99](/../../commit/727cee99))
|
58
|
+
* add self relation to tags in extended pact and verification resources ([a560ce6d](/../../commit/a560ce6d))
|
59
|
+
|
60
|
+
* **metrics**
|
61
|
+
* timeout matrix count ([43091b57](/../../commit/43091b57))
|
62
|
+
|
63
|
+
#### Bug Fixes
|
64
|
+
|
65
|
+
* url encode tag name in tag URL ([80df832d](/../../commit/80df832d))
|
66
|
+
|
1
67
|
<a name="v2.72.0"></a>
|
2
68
|
### v2.72.0 (2020-12-02)
|
3
69
|
|
data/DEVELOPER_SETUP.md
CHANGED
@@ -68,6 +68,13 @@ bundle exec rake
|
|
68
68
|
# if you don't want to run the whole rake test suite, init the db first
|
69
69
|
/home/init-db.sh
|
70
70
|
```
|
71
|
+
|
72
|
+
Running a mysql client in the mysql-tests container:
|
73
|
+
|
74
|
+
```
|
75
|
+
mysql -hmysql -upact_broker -ppact_broker
|
76
|
+
```
|
77
|
+
|
71
78
|
## Running the tests
|
72
79
|
|
73
80
|
* To run everything (specs, pact verifications, vulnerability scan...):
|
@@ -87,5 +94,7 @@ bundle exec rake
|
|
87
94
|
bundle exec rspec path_to_your_spec.rb
|
88
95
|
```
|
89
96
|
|
97
|
+
NOTE: the spec tasks requires the `db:prepare:test` task to be executed at least once prior to running.
|
98
|
+
|
90
99
|
[chruby]: https://github.com/postmodern/chruby
|
91
100
|
[ruby-install]: https://github.com/postmodern/ruby-install
|
data/Dockerfile
CHANGED
data/ISSUES.md
CHANGED
@@ -8,16 +8,16 @@ You can use it to easily reproduce issues.
|
|
8
8
|
|
9
9
|
To use it:
|
10
10
|
|
11
|
-
* Run the Pact Broker using the
|
11
|
+
* Run the Pact Broker using a specific Pact Broker Docker image by setting the required tag for the pact-broker service in the docker-compose-issue-repro-with-pact-broker-docker-image.yml file.
|
12
12
|
|
13
13
|
```
|
14
|
-
docker-compose -f docker-compose-issue-repro.yml up --build pact-broker
|
14
|
+
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up --build pact-broker
|
15
15
|
```
|
16
16
|
|
17
17
|
* Run the reproduction script.
|
18
18
|
|
19
19
|
```
|
20
|
-
docker-compose -f docker-compose-issue-repro.yml up repro-issue
|
20
|
+
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up repro-issue
|
21
21
|
```
|
22
22
|
|
23
23
|
You can modify `script/reproduce-issue.rb` and then re-run it with the change applied.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Pact Broker
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/pact_broker.svg)](http://badge.fury.io/rb/pact_broker)
|
3
|
-
|
3
|
+
![Build status](https://github.com/pact-foundation/pact_broker/workflows/Test/badge.svg)
|
4
4
|
[![Join the chat at https://pact-foundation.slack.com/](https://img.shields.io/badge/chat-on%20slack-blue.svg?logo=slack)](https://slack.pact.io)
|
5
5
|
[![security](https://hakiri.io/github/pact-foundation/pact_broker/master.svg)](https://hakiri.io/github/pact-foundation/pact_broker/master)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/pact-foundation/pact_broker/badges/gpa.svg)](https://codeclimate.com/github/pact-foundation/pact_broker)
|
data/config/database.yml
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'migration_helper'
|
2
|
+
|
3
|
+
include PactBroker::MigrationHelper
|
4
|
+
|
5
|
+
Sequel.migration do
|
6
|
+
up do
|
7
|
+
if !mysql?
|
8
|
+
alter_table(:webhook_executions) do
|
9
|
+
add_index([:triggered_webhook_id], name: "webhook_executions_triggered_webhook_id_index")
|
10
|
+
end
|
11
|
+
# MySQL automatically creates indexes for foreign keys then complains if you
|
12
|
+
# re-create it with a different name and try to drop it.
|
13
|
+
|
14
|
+
# https://stackoverflow.com/a/52274628/832671 - "When there is only one index that can be used
|
15
|
+
# for the foreign key, it can't be dropped. If you really wan't to drop it, you either have to drop
|
16
|
+
# the foreign key constraint or to create another index for it first."
|
17
|
+
|
18
|
+
alter_table(:triggered_webhooks) do
|
19
|
+
add_index([:webhook_id], name: "triggered_webhooks_webhook_id_index")
|
20
|
+
add_index([:consumer_id], name: "triggered_webhooks_consumer_id_index")
|
21
|
+
add_index([:provider_id], name: "triggered_webhooks_provider_id_index")
|
22
|
+
add_index([:verification_id], name: "triggered_webhooks_verification_id_index")
|
23
|
+
add_index([:pact_publication_id], name: "triggered_webhooks_pact_publication_id_index")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
down do
|
29
|
+
if !mysql?
|
30
|
+
alter_table(:webhook_executions) do
|
31
|
+
drop_index([:triggered_webhook_id], name: "webhook_executions_triggered_webhook_id_index")
|
32
|
+
end
|
33
|
+
# MySQL automatically creates indexes for foreign keys then complains if you
|
34
|
+
# re-create it with a different name and try to drop it.
|
35
|
+
|
36
|
+
# https://stackoverflow.com/a/52274628/832671 - "When there is only one index that can be used
|
37
|
+
# for the foreign key, it can't be dropped. If you really wan't to drop it, you either have to drop
|
38
|
+
# the foreign key constraint or to create another index for it first."
|
39
|
+
|
40
|
+
alter_table(:triggered_webhooks) do
|
41
|
+
drop_index([:webhook_id], name: "triggered_webhooks_webhook_id_index")
|
42
|
+
drop_index([:consumer_id], name: "triggered_webhooks_consumer_id_index")
|
43
|
+
drop_index([:provider_id], name: "triggered_webhooks_provider_id_index")
|
44
|
+
drop_index([:verification_id], name: "triggered_webhooks_verification_id_index")
|
45
|
+
drop_index([:pact_publication_id], name: "triggered_webhooks_pact_publication_id_index")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -30,6 +30,14 @@ module PactBroker
|
|
30
30
|
Sequel::Model.db.adapter_scheme.to_s
|
31
31
|
end
|
32
32
|
|
33
|
+
def with_type_hash_if_postgres(options)
|
34
|
+
if postgres?
|
35
|
+
options.merge(type: "hash")
|
36
|
+
else
|
37
|
+
options
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
33
41
|
def sqlite_safe string
|
34
42
|
if adapter == 'sqlite'
|
35
43
|
string.gsub(/(?:\b|")order(?:"|\b)/, '`order`')
|
@@ -0,0 +1,33 @@
|
|
1
|
+
version: "3"
|
2
|
+
|
3
|
+
services:
|
4
|
+
postgres:
|
5
|
+
image: postgres
|
6
|
+
healthcheck:
|
7
|
+
test: psql postgres --command "select 1" -U postgres
|
8
|
+
environment:
|
9
|
+
POSTGRES_USER: postgres
|
10
|
+
POSTGRES_PASSWORD: password
|
11
|
+
POSTGRES_DB: postgres
|
12
|
+
|
13
|
+
pact-broker:
|
14
|
+
image: pactfoundation/pact-broker:2.73.0.0
|
15
|
+
ports:
|
16
|
+
- "9292:9292"
|
17
|
+
depends_on:
|
18
|
+
- postgres
|
19
|
+
environment:
|
20
|
+
PACT_BROKER_PORT: '9292'
|
21
|
+
PACT_BROKER_DATABASE_URL: "postgres://postgres:password@postgres/postgres"
|
22
|
+
PACT_BROKER_LOG_LEVEL: INFO
|
23
|
+
PACT_BROKER_SQL_LOG_LEVEL: DEBUG
|
24
|
+
|
25
|
+
repro-issue:
|
26
|
+
build: .
|
27
|
+
depends_on:
|
28
|
+
- pact-broker
|
29
|
+
command: dockerize -wait http://pact-broker:9292 -timeout 30s /home/script/reproduce-issue.rb
|
30
|
+
environment:
|
31
|
+
- PACT_BROKER_BASE_URL=http://pact-broker:9292
|
32
|
+
volumes:
|
33
|
+
- $PWD:/home
|
data/docker-compose-test.yml
CHANGED
@@ -6,8 +6,8 @@ services:
|
|
6
6
|
image: postgres
|
7
7
|
healthcheck:
|
8
8
|
test: psql postgres --command "select 1" -U postgres
|
9
|
-
ports:
|
10
|
-
|
9
|
+
# ports:
|
10
|
+
# - "5432:5432"
|
11
11
|
environment:
|
12
12
|
POSTGRES_USER: postgres
|
13
13
|
POSTGRES_PASSWORD: postgres
|
@@ -58,8 +58,8 @@ services:
|
|
58
58
|
MYSQL_DATABASE: pact_broker
|
59
59
|
MYSQL_USER: pact_broker
|
60
60
|
MYSQL_PASSWORD: pact_broker
|
61
|
-
ports:
|
62
|
-
|
61
|
+
# ports:
|
62
|
+
# - "3306:3306"
|
63
63
|
|
64
64
|
init-mysql:
|
65
65
|
build: .
|
data/lib/db.rb
CHANGED
@@ -33,6 +33,7 @@ module DB
|
|
33
33
|
con = Sequel.connect(db_credentials.merge(:logger => logger, :pool_class => Sequel::ThreadedConnectionPool, :encoding => 'utf8'))
|
34
34
|
con.extension(:connection_validator)
|
35
35
|
con.extension(:pagination)
|
36
|
+
con.extension(:statement_timeout)
|
36
37
|
con.extend_datasets do
|
37
38
|
def any?
|
38
39
|
!empty?
|
data/lib/pact_broker/api.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'webmachine/adapters/rack_mapped'
|
2
2
|
require 'webmachine/rack_adapter_monkey_patch'
|
3
3
|
require 'pact_broker/api/resources'
|
4
|
+
require 'pact_broker/api/decorators'
|
5
|
+
require 'pact_broker/application_context'
|
4
6
|
require 'pact_broker/feature_toggle'
|
5
7
|
|
6
8
|
module Webmachine
|
@@ -12,8 +14,7 @@ module Webmachine
|
|
12
14
|
end
|
13
15
|
|
14
16
|
module PactBroker
|
15
|
-
|
16
|
-
API ||= begin
|
17
|
+
def self.build_api(application_context = PactBroker::ApplicationContext.default_application_context)
|
17
18
|
pact_api = Webmachine::Application.new do |app|
|
18
19
|
app.routes do
|
19
20
|
add(['trace', :*], Webmachine::Trace::TraceResource) unless ENV['RACK_ENV'] == 'production'
|
@@ -111,10 +112,20 @@ module PactBroker
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
115
|
+
# naughty, but better than setting each route manually
|
116
|
+
pact_api.routes.each do | route |
|
117
|
+
route.instance_variable_get(:@bindings)[:application_context] = application_context
|
118
|
+
end
|
119
|
+
|
114
120
|
pact_api.configure do |config|
|
115
121
|
config.adapter = :RackMapped
|
116
122
|
end
|
117
123
|
|
118
124
|
pact_api.adapter
|
119
125
|
end
|
126
|
+
|
127
|
+
|
128
|
+
API ||= begin
|
129
|
+
build_api
|
130
|
+
end
|
120
131
|
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
require 'pact_broker/api/decorators/pact_collection_decorator'
|
5
|
-
require 'pact_broker/api/decorators/pact_pacticipant_decorator'
|
6
|
-
require 'pact_broker/api/decorators/pact_details_decorator'
|
7
|
-
require 'pact_broker/api/decorators/tag_decorator'
|
1
|
+
Dir.glob(File.expand_path(File.join(__FILE__, "..", "decorators", "*.rb"))).sort.each do | path |
|
2
|
+
require path
|
3
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pact_broker/string_refinements'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Api
|
5
|
+
module Decorators
|
6
|
+
class Configuration
|
7
|
+
using PactBroker::StringRefinements
|
8
|
+
|
9
|
+
def initialize(overrides = {})
|
10
|
+
@overrides = overrides
|
11
|
+
end
|
12
|
+
|
13
|
+
def class_for(name)
|
14
|
+
if overrides[name].is_a?(String)
|
15
|
+
Object.const_get(overrides[name])
|
16
|
+
elsif overrides[name].is_a?(Class)
|
17
|
+
overrides[name]
|
18
|
+
else
|
19
|
+
Object.const_get("PactBroker::Api::Decorators::#{name.to_s.camelcase(true)}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.default_configuration
|
24
|
+
Configuration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :overrides
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'pact_broker/api/decorators/decorator_context'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Api
|
5
|
+
module Decorators
|
6
|
+
class DecoratorContextCreator
|
7
|
+
def self.call(resource, options)
|
8
|
+
Decorators::DecoratorContext.new(resource.base_url, resource.resource_url, resource.request.env, options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -11,6 +11,14 @@ module PactBroker
|
|
11
11
|
property :name
|
12
12
|
property :latest, getter: ->(_) { true }
|
13
13
|
|
14
|
+
link :self do | options |
|
15
|
+
{
|
16
|
+
title: 'Tag',
|
17
|
+
name: represented.name,
|
18
|
+
href: tag_url(options[:base_url], represented)
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
14
22
|
link "pb:latest-pact" do | opts |
|
15
23
|
{
|
16
24
|
name: "The latest pact with the tag #{represented.name}",
|
@@ -33,7 +41,7 @@ module PactBroker
|
|
33
41
|
|
34
42
|
def head_tags
|
35
43
|
represented.head_tag_names.collect do | tag_name |
|
36
|
-
OpenStruct.new(name: tag_name, pact: represented)
|
44
|
+
OpenStruct.new(name: tag_name, pact: represented, version: represented.consumer_version)
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|