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.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/.optic/.gitignore +2 -0
  4. data/.optic/api/specification.json +1 -0
  5. data/.optic/ignore +14 -0
  6. data/CHANGELOG.md +66 -0
  7. data/DEVELOPER_SETUP.md +9 -0
  8. data/Dockerfile +1 -0
  9. data/ISSUES.md +3 -3
  10. data/README.md +1 -1
  11. data/config/database.yml +1 -1
  12. data/db/migrations/20210115_add_webhook_foreign_key_indexes.rb +49 -0
  13. data/db/migrations/20210116_add_context_to_triggered_webhook.rb +11 -0
  14. data/db/migrations/migration_helper.rb +8 -0
  15. data/docker-compose-issue-repro-with-pact-broker-docker-image.yml +33 -0
  16. data/docker-compose-test.yml +4 -4
  17. data/lib/db.rb +1 -0
  18. data/lib/pact_broker/api.rb +13 -2
  19. data/lib/pact_broker/api/decorators.rb +3 -7
  20. data/lib/pact_broker/api/decorators/configuration.rb +33 -0
  21. data/lib/pact_broker/api/decorators/decorator_context_creator.rb +13 -0
  22. data/lib/pact_broker/api/decorators/extended_pact_decorator.rb +9 -1
  23. data/lib/pact_broker/api/decorators/extended_verification_decorator.rb +8 -0
  24. data/lib/pact_broker/api/decorators/matrix_decorator.rb +9 -4
  25. data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +1 -0
  26. data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +2 -3
  27. data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -0
  28. data/lib/pact_broker/api/decorators/tag_decorator.rb +0 -3
  29. data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +3 -1
  30. data/lib/pact_broker/api/pact_broker_urls.rb +4 -4
  31. data/lib/pact_broker/api/paths.rb +5 -0
  32. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +2 -2
  33. data/lib/pact_broker/api/resources/all_webhooks.rb +3 -3
  34. data/lib/pact_broker/api/resources/can_i_deploy_badge.rb +1 -1
  35. data/lib/pact_broker/api/resources/dashboard.rb +2 -2
  36. data/lib/pact_broker/api/resources/default_base_resource.rb +37 -12
  37. data/lib/pact_broker/api/resources/error_handler.rb +1 -1
  38. data/lib/pact_broker/api/resources/error_response_body_generator.rb +41 -0
  39. data/lib/pact_broker/api/resources/group.rb +1 -1
  40. data/lib/pact_broker/api/resources/integrations.rb +1 -1
  41. data/lib/pact_broker/api/resources/label.rb +1 -1
  42. data/lib/pact_broker/api/resources/latest_pact.rb +2 -2
  43. data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
  44. data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +2 -2
  45. data/lib/pact_broker/api/resources/matrix.rb +2 -2
  46. data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +1 -1
  47. data/lib/pact_broker/api/resources/metadata_resource_methods.rb +2 -1
  48. data/lib/pact_broker/api/resources/pact.rb +2 -2
  49. data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +1 -1
  50. data/lib/pact_broker/api/resources/pact_versions.rb +1 -1
  51. data/lib/pact_broker/api/resources/pact_webhooks.rb +3 -3
  52. data/lib/pact_broker/api/resources/pact_webhooks_status.rb +2 -2
  53. data/lib/pact_broker/api/resources/pacticipant.rb +1 -1
  54. data/lib/pact_broker/api/resources/pacticipants.rb +3 -3
  55. data/lib/pact_broker/api/resources/pacticipants_for_label.rb +1 -1
  56. data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
  57. data/lib/pact_broker/api/resources/provider_pacts.rb +1 -7
  58. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +2 -2
  59. data/lib/pact_broker/api/resources/relationships.rb +1 -1
  60. data/lib/pact_broker/api/resources/tag.rb +1 -1
  61. data/lib/pact_broker/api/resources/tagged_pact_versions.rb +1 -1
  62. data/lib/pact_broker/api/resources/verification.rb +2 -2
  63. data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +1 -1
  64. data/lib/pact_broker/api/resources/verifications.rb +1 -1
  65. data/lib/pact_broker/api/resources/version.rb +1 -1
  66. data/lib/pact_broker/api/resources/versions.rb +1 -1
  67. data/lib/pact_broker/api/resources/webhook.rb +2 -2
  68. data/lib/pact_broker/api/resources/webhook_execution.rb +4 -4
  69. data/lib/pact_broker/api/resources/webhook_execution_methods.rb +1 -3
  70. data/lib/pact_broker/api/resources/webhooks.rb +3 -3
  71. data/lib/pact_broker/app.rb +14 -3
  72. data/lib/pact_broker/application_context.rb +41 -0
  73. data/lib/pact_broker/configuration.rb +12 -4
  74. data/lib/pact_broker/doc/controllers/app.rb +3 -2
  75. data/lib/pact_broker/domain/version.rb +13 -6
  76. data/lib/pact_broker/domain/webhook_request.rb +1 -1
  77. data/lib/pact_broker/error.rb +0 -2
  78. data/lib/pact_broker/errors.rb +28 -0
  79. data/lib/pact_broker/errors/error_logger.rb +25 -0
  80. data/lib/pact_broker/metrics/service.rb +12 -1
  81. data/lib/pact_broker/pacts/metadata.rb +53 -8
  82. data/lib/pact_broker/pacts/repository.rb +10 -17
  83. data/lib/pact_broker/pacts/selector.rb +22 -0
  84. data/lib/pact_broker/pacts/selectors.rb +4 -0
  85. data/lib/pact_broker/services.rb +106 -31
  86. data/lib/pact_broker/tags/tag_with_latest_flag.rb +2 -0
  87. data/lib/pact_broker/test/http_test_data_builder.rb +83 -21
  88. data/lib/pact_broker/test/test_data_builder.rb +3 -2
  89. data/lib/pact_broker/ui/views/index/_getting-started.haml +1 -1
  90. data/lib/pact_broker/ui/views/index/show-with-tags.haml +16 -16
  91. data/lib/pact_broker/ui/views/index/show.haml +6 -6
  92. data/lib/pact_broker/ui/views/layouts/main.haml +2 -2
  93. data/lib/pact_broker/ui/views/matrix/show.haml +32 -33
  94. data/lib/pact_broker/version.rb +1 -1
  95. data/lib/pact_broker/webhooks/execution_configuration.rb +4 -0
  96. data/lib/pact_broker/webhooks/execution_configuration_creator.rb +14 -0
  97. data/lib/pact_broker/webhooks/repository.rb +3 -2
  98. data/lib/pact_broker/webhooks/service.rb +2 -1
  99. data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -0
  100. data/lib/rack/pact_broker/hal_browser_redirect.rb +42 -0
  101. data/lib/rack/pact_broker/set_base_url.rb +22 -0
  102. data/lib/sequel/extensions/statement_timeout.rb +22 -0
  103. data/optic.yml +5 -0
  104. data/pact_broker.gemspec +1 -1
  105. data/public/css/bootstrap-grid.css +3719 -0
  106. data/public/css/bootstrap-grid.css.map +1 -0
  107. data/public/css/bootstrap-grid.min.css +7 -0
  108. data/public/css/bootstrap-grid.min.css.map +1 -0
  109. data/public/css/bootstrap-reboot.css +331 -0
  110. data/public/css/bootstrap-reboot.css.map +1 -0
  111. data/public/css/bootstrap-reboot.min.css +8 -0
  112. data/public/css/bootstrap-reboot.min.css.map +1 -0
  113. data/public/css/bootstrap.css +8885 -5604
  114. data/public/css/bootstrap.css.map +1 -1
  115. data/public/css/bootstrap.min.css +4 -3
  116. data/public/css/bootstrap.min.css.map +1 -1
  117. data/public/images/alert.svg +1 -0
  118. data/public/images/arrow-switch.svg +1 -0
  119. data/public/images/check.svg +1 -0
  120. data/public/images/clock.svg +1 -0
  121. data/public/images/copy.svg +1 -0
  122. data/public/images/kebab-horizontal.svg +1 -0
  123. data/public/javascripts/clipboard.js +3 -3
  124. data/public/javascripts/{jquery-3.3.1.js → jquery-3.5.1.js} +1150 -642
  125. data/public/javascripts/jquery-3.5.1.min.js +2 -0
  126. data/public/javascripts/jquery-3.5.1.min.map +1 -0
  127. data/public/javascripts/matrix.js +2 -2
  128. data/public/js/bootstrap.bundle.js +7013 -0
  129. data/public/js/bootstrap.bundle.js.map +1 -0
  130. data/public/js/bootstrap.bundle.min.js +7 -0
  131. data/public/js/bootstrap.bundle.min.js.map +1 -0
  132. data/public/js/bootstrap.js +3862 -1804
  133. data/public/js/bootstrap.js.map +1 -0
  134. data/public/js/bootstrap.min.js +6 -6
  135. data/public/js/bootstrap.min.js.map +1 -0
  136. data/public/stylesheets/index.css +56 -3
  137. data/public/stylesheets/matrix.css +55 -5
  138. data/public/stylesheets/pact.css +14 -0
  139. data/regression/.gitignore +1 -0
  140. data/regression/can_i_deploy_spec.rb +42 -0
  141. data/regression/regression_helper.rb +37 -0
  142. data/regression/script/approval-all.sh +6 -0
  143. data/script/exercise-api-for-optic.sh +3 -0
  144. data/script/reproduce-issue-starting-up.rb +43 -0
  145. data/script/reproduce-issue.rb +9 -21
  146. data/spec/lib/pact_broker/api/decorators/extended_pact_decorator_spec.rb +1 -0
  147. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +20 -8
  148. data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +5 -7
  149. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +10 -6
  150. data/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb +1 -1
  151. data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +59 -10
  152. data/spec/lib/pact_broker/api/resources/error_response_body_generator_spec.rb +69 -0
  153. data/spec/lib/pact_broker/db/log_quietener_spec.rb +1 -1
  154. data/spec/lib/pact_broker/doc/controllers/app_spec.rb +3 -5
  155. data/spec/lib/pact_broker/errors/error_logger_spec.rb +62 -0
  156. data/spec/lib/pact_broker/errors_spec.rb +55 -0
  157. data/spec/lib/pact_broker/pacts/metadata_spec.rb +73 -0
  158. data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +2 -2
  159. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +33 -13
  160. data/spec/lib/pact_broker/pacts/selected_pact_spec.rb +23 -0
  161. data/spec/lib/pact_broker/webhooks/repository_spec.rb +5 -2
  162. data/spec/lib/pact_broker/webhooks/service_spec.rb +2 -1
  163. data/spec/lib/rack/pact_broker/hal_browser_redirect_spec.rb +27 -0
  164. data/tasks/rspec.rake +6 -0
  165. metadata +65 -17
  166. data/public/css/bootstrap-theme.css +0 -587
  167. data/public/css/bootstrap-theme.css.map +0 -1
  168. data/public/css/bootstrap-theme.min.css +0 -6
  169. data/public/css/bootstrap-theme.min.css.map +0 -1
  170. data/public/fonts/glyphicons-halflings-regular.svg +0 -288
  171. data/public/javascripts/jquery-3.3.1.min.js +0 -2
  172. data/public/javascripts/jquery-3.3.1.min.map +0 -1
  173. 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: f848cc7a613de4d084d69d97bf1b835c1d1bb130eec3c4c968800e348daf95bf
4
- data.tar.gz: 1cbbbd2832eb98cd3904bba8aff8d909a95663c70abe7ad710473e46b3fb3e7c
3
+ metadata.gz: d14eafba260b6b71dd75c725768863c0f923e167bdb37084606a0b51d110d363
4
+ data.tar.gz: 545dabeda5ede4c25508e8ca5135d94dacec61f9df1692207787bdc6e3227ec4
5
5
  SHA512:
6
- metadata.gz: 2200189e21700c21b67e1f8abc85574c3ed9367287568ce7dab4f808cd81ae01a80acd60fe3309cb134cd4466d2c243244429073d4e3af53b6b009bc58848782
7
- data.tar.gz: c304534b3125112f4bd2bead0509e7e711face5f0e84ec88594cae1eb6e14a1618a4e61884ffbb0f66dbd813c4e5d4ebd61867ce276120a471a6a77f4c1e6e61
6
+ metadata.gz: c8df83a6bf1588e8a9a96f915b0926d1a164ebd8f246d7ed831d83d43610bcbaf38875800bbd56ab792af3c9b2b6a9b2f415b6e3a581b6d8955e80248b25d67d
7
+ data.tar.gz: f1bb7162afee7913b9ac53fc523aa47d021f760350cca52758af1f626f3c440dd73bd02921254487820b1724b5a4c3e334283f728e7b279d92a69b29995de074
@@ -37,7 +37,7 @@ jobs:
37
37
  - uses: actions/setup-ruby@v1
38
38
  with:
39
39
  ruby-version: ${{ matrix.ruby_version }}
40
- - run: "bundle install"
40
+ - run: "gem install bundler && bundle install"
41
41
  env:
42
42
  INSTALL_PG: "true"
43
43
  - run: "bundle exec rake"
@@ -0,0 +1,2 @@
1
+
2
+ captures/
@@ -0,0 +1 @@
1
+ []
@@ -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
@@ -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
 
@@ -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
@@ -15,6 +15,7 @@ RUN apk update \
15
15
  "sqlite>=3.28" \
16
16
  "tzdata>=2019" \
17
17
  "mariadb-dev>=10.3" \
18
+ "mysql-client>=10.3.25" \
18
19
  && rm -rf /var/cache/apk/*
19
20
 
20
21
  RUN apk add --no-cache openssl less
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 latest development code:
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
- [![Build Status](https://travis-ci.org/pact-foundation/pact_broker.svg?branch=master)](https://travis-ci.org/pact-foundation/pact_broker)
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)
@@ -17,7 +17,7 @@ test:
17
17
  username: postgres
18
18
  password: postgres
19
19
  host: localhost
20
- port: "5433"
20
+ port: "5432"
21
21
  docker_compose_postgres:
22
22
  adapter: postgres
23
23
  database: postgres
@@ -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
@@ -0,0 +1,11 @@
1
+ require_relative 'migration_helper'
2
+
3
+ include PactBroker::MigrationHelper
4
+
5
+ Sequel.migration do
6
+ change do
7
+ alter_table(:triggered_webhooks) do
8
+ add_column(:event_context, String)
9
+ end
10
+ end
11
+ 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
@@ -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
- - "5432:5432"
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
- - "3306:3306"
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?
@@ -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
- require 'pact_broker/api/decorators/pacticipant_decorator'
2
- require 'pact_broker/api/decorators/pacticipant_collection_decorator'
3
- require 'pact_broker/api/decorators/embedded_version_decorator'
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