pact_broker 2.85.0 → 2.88.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/trigger_pact_docs_update.yml +22 -0
  3. data/CHANGELOG.md +67 -0
  4. data/DEVELOPER_DOCUMENTATION.md +0 -2
  5. data/db/migrations/20210914_add_labels_to_webhooks.rb +14 -0
  6. data/db/migrations/20210915_add_verified_by_to_verification.rb +6 -0
  7. data/db/migrations/20210929_increase_event_context_column_size.rb +14 -0
  8. data/docker-compose-ci-mysql.yml +1 -0
  9. data/docker-compose-test.yml +2 -0
  10. data/docs/CONFIGURATION.md +255 -66
  11. data/docs/api/WEBHOOKS.md +789 -0
  12. data/docs/configuration.yml +166 -101
  13. data/lib/db.rb +0 -1
  14. data/lib/pact/doc/interaction_view_model.rb +2 -2
  15. data/lib/pact/doc/markdown/consumer_contract_renderer.rb +1 -1
  16. data/lib/pact_broker/api/contracts/configuration.rb +33 -0
  17. data/lib/pact_broker/api/contracts/publish_contracts_schema.rb +35 -16
  18. data/lib/pact_broker/api/contracts/webhook_contract.rb +24 -2
  19. data/lib/pact_broker/api/decorators/matrix_decorator.rb +3 -1
  20. data/lib/pact_broker/api/decorators/pact_decorator.rb +12 -0
  21. data/lib/pact_broker/api/decorators/verification_decorator.rb +9 -3
  22. data/lib/pact_broker/api/decorators/webhook_decorator.rb +27 -4
  23. data/lib/pact_broker/api/pact_broker_urls.rb +30 -6
  24. data/lib/pact_broker/api/resources/all_webhooks.rb +2 -2
  25. data/lib/pact_broker/api/resources/default_base_resource.rb +5 -1
  26. data/lib/pact_broker/api/resources/environment.rb +4 -4
  27. data/lib/pact_broker/api/resources/environments.rb +1 -1
  28. data/lib/pact_broker/api/resources/index.rb +7 -1
  29. data/lib/pact_broker/api/resources/metadata_resource_methods.rb +33 -3
  30. data/lib/pact_broker/api/resources/pact_version.rb +4 -0
  31. data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
  32. data/lib/pact_broker/api/resources/publish_contracts.rb +1 -1
  33. data/lib/pact_broker/api/resources/verification.rb +5 -2
  34. data/lib/pact_broker/api/resources/webhook_execution.rb +7 -3
  35. data/lib/pact_broker/api/resources/webhook_execution_methods.rb +23 -17
  36. data/lib/pact_broker/api.rb +6 -0
  37. data/lib/pact_broker/application_context.rb +5 -0
  38. data/lib/pact_broker/config/runtime_configuration.rb +4 -0
  39. data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
  40. data/lib/pact_broker/db/clean.rb +1 -2
  41. data/lib/pact_broker/db/delete_overwritten_data.rb +41 -23
  42. data/lib/pact_broker/deployments/deployed_version.rb +1 -0
  43. data/lib/pact_broker/deployments/deployed_version_service.rb +1 -0
  44. data/lib/pact_broker/deployments/environment_service.rb +7 -2
  45. data/lib/pact_broker/deployments/released_version_service.rb +1 -0
  46. data/lib/pact_broker/doc/controllers/app.rb +1 -0
  47. data/lib/pact_broker/doc/views/can-i-deploy.markdown +2 -1
  48. data/lib/pact_broker/doc/views/index/publish-contracts.markdown +38 -9
  49. data/lib/pact_broker/doc/views/pacticipant/label.markdown +12 -0
  50. data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +7 -7
  51. data/lib/pact_broker/doc/views/webhooks.markdown +17 -0
  52. data/lib/pact_broker/domain/index_item.rb +9 -0
  53. data/lib/pact_broker/domain/pacticipant.rb +4 -0
  54. data/lib/pact_broker/domain/verification.rb +19 -4
  55. data/lib/pact_broker/domain/webhook.rb +5 -5
  56. data/lib/pact_broker/domain/webhook_pacticipant.rb +6 -0
  57. data/lib/pact_broker/index/service.rb +4 -4
  58. data/lib/pact_broker/locale/en.yml +4 -1
  59. data/lib/pact_broker/matrix/head_row.rb +1 -1
  60. data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +5 -3
  61. data/lib/pact_broker/matrix/quick_row.rb +0 -1
  62. data/lib/pact_broker/matrix/repository.rb +0 -1
  63. data/lib/pact_broker/matrix/row.rb +2 -2
  64. data/lib/pact_broker/pacticipants/repository.rb +1 -1
  65. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +0 -1
  66. data/lib/pact_broker/pacts/metadata.rb +7 -1
  67. data/lib/pact_broker/pacts/pact_publication.rb +7 -0
  68. data/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb +19 -0
  69. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +30 -2
  70. data/lib/pact_broker/pacts/pact_version.rb +24 -1
  71. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +5 -4
  72. data/lib/pact_broker/pacts/repository.rb +50 -47
  73. data/lib/pact_broker/pacts/service.rb +5 -5
  74. data/lib/pact_broker/string_refinements.rb +1 -1
  75. data/lib/pact_broker/test/http_test_data_builder.rb +40 -10
  76. data/lib/pact_broker/test/test_data_builder.rb +28 -5
  77. data/lib/pact_broker/ui/helpers/url_helper.rb +12 -0
  78. data/lib/pact_broker/ui/view_models/index_item.rb +15 -1
  79. data/lib/pact_broker/ui/view_models/index_item_branch_head.rb +39 -0
  80. data/lib/pact_broker/ui/view_models/index_item_provider_branch_head.rb +39 -0
  81. data/lib/pact_broker/ui/views/dashboard/show.haml +14 -7
  82. data/lib/pact_broker/verifications/repository.rb +5 -2
  83. data/lib/pact_broker/verifications/service.rb +7 -4
  84. data/lib/pact_broker/version.rb +1 -1
  85. data/lib/pact_broker/versions/abbreviate_number.rb +8 -4
  86. data/lib/pact_broker/versions/branch_head.rb +0 -2
  87. data/lib/pact_broker/versions/branch_version.rb +1 -0
  88. data/lib/pact_broker/versions/repository.rb +0 -1
  89. data/lib/pact_broker/webhooks/event_listener.rb +4 -2
  90. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +18 -3
  91. data/lib/pact_broker/webhooks/repository.rb +10 -4
  92. data/lib/pact_broker/webhooks/trigger_service.rb +1 -1
  93. data/lib/pact_broker/webhooks/webhook.rb +71 -8
  94. data/lib/webmachine/describe_routes.rb +62 -0
  95. data/public/stylesheets/index.css +5 -0
  96. data/script/data/auto-create-things-for-tags.rb +1 -0
  97. data/script/data/branches.rb +1 -1
  98. data/script/data/contract-published-requiring-verification.rb +0 -1
  99. data/script/data/verify-pact-for-multiple-selectors.rb +30 -0
  100. data/script/docs/generate-api-docs.rb +117 -0
  101. data/script/docs/generate-configuration-docs.rb +24 -3
  102. data/script/docs/regenerate-api-docs.sh +11 -0
  103. data/script/generate-erd +55 -0
  104. data/spec/features/create_webhook_spec.rb +55 -10
  105. data/spec/features/get_pact_spec.rb +2 -3
  106. data/spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_options.approved.json +20 -0
  107. data/spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_post.approved.json +43 -0
  108. data/spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_options.approved.json +20 -0
  109. data/spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_post.approved.json +63 -0
  110. data/spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_get.approved.json +20 -0
  111. data/spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_options.approved.json +20 -0
  112. data/spec/fixtures/approvals/docs_webhooks_pact_webhooks_get.approved.json +45 -0
  113. data/spec/fixtures/approvals/docs_webhooks_pact_webhooks_options.approved.json +20 -0
  114. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_get.approved.json +52 -0
  115. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_options.approved.json +20 -0
  116. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_get.approved.json +32 -0
  117. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_options.approved.json +20 -0
  118. data/spec/fixtures/approvals/docs_webhooks_webhook_get.approved.json +74 -0
  119. data/spec/fixtures/approvals/docs_webhooks_webhook_options.approved.json +20 -0
  120. data/spec/fixtures/approvals/docs_webhooks_webhook_put.approved.json +77 -0
  121. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_get.approved.json +41 -0
  122. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_options.approved.json +20 -0
  123. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_get.approved.json +45 -0
  124. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_options.approved.json +20 -0
  125. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_get.approved.json +41 -0
  126. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_options.approved.json +20 -0
  127. data/spec/fixtures/approvals/docs_webhooks_webhooks_get.approved.json +45 -0
  128. data/spec/fixtures/approvals/docs_webhooks_webhooks_options.approved.json +20 -0
  129. data/spec/fixtures/approvals/docs_webhooks_webhooks_post.approved.json +78 -0
  130. data/spec/fixtures/approvals/docs_webhooks_webhooks_status_get.approved.json +79 -0
  131. data/spec/fixtures/approvals/docs_webhooks_webhooks_status_options.approved.json +20 -0
  132. data/spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json +1 -2
  133. data/spec/fixtures/approvals/publish_contract_no_branch.approved.json +1 -2
  134. data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +1 -2
  135. data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +1 -2
  136. data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +1 -2
  137. data/spec/fixtures/approvals/publish_contract_with_validation_error.approved.json +1 -2
  138. data/spec/fixtures/invalid-publish-contract-body.json +38 -0
  139. data/spec/fixtures/verification.json +4 -0
  140. data/spec/integration/pact_metdata_spec.rb +105 -0
  141. data/spec/integration/webhooks/contract_publication_spec.rb +68 -0
  142. data/spec/integration/webhooks/contract_requiring_verification_published_spec.rb +67 -0
  143. data/spec/integration/webhooks/pact_publication_spec.rb +51 -0
  144. data/spec/integration/webhooks_documentation_spec.rb +348 -0
  145. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +2 -2
  146. data/spec/lib/pact_broker/api/contracts/publish_contracts_schema_spec.rb +13 -0
  147. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +50 -0
  148. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +1 -1
  149. data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +15 -7
  150. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +4 -2
  151. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +4 -4
  152. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +18 -0
  153. data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +6 -5
  154. data/spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb +30 -0
  155. data/spec/lib/pact_broker/deployments/environment_service_spec.rb +22 -1
  156. data/spec/lib/pact_broker/domain/webhook_spec.rb +35 -0
  157. data/spec/lib/pact_broker/matrix/head_row_spec.rb +9 -5
  158. data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +13 -0
  159. data/spec/lib/pact_broker/pacts/{latest_tagged_pact_publications_spec.rb → pact_publication_clean_selector_dataset_module_spec.rb} +7 -9
  160. data/spec/lib/pact_broker/pacts/pact_version_spec.rb +32 -0
  161. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +4 -5
  162. data/spec/lib/pact_broker/pacts/repository_spec.rb +33 -0
  163. data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +1 -1
  164. data/spec/lib/pact_broker/verifications/service_spec.rb +22 -8
  165. data/spec/lib/pact_broker/versions/abbreviate_number_spec.rb +2 -1
  166. data/spec/lib/pact_broker/webhooks/render_spec.rb +3 -2
  167. data/spec/lib/pact_broker/webhooks/repository_spec.rb +158 -15
  168. data/spec/lib/pact_broker/webhooks/webhook_spec.rb +8 -5
  169. data/spec/support/documentation.rb +64 -0
  170. data/spec/support/rack_helpers.rb +1 -1
  171. data/tasks/db.rake +4 -1
  172. data/tasks/development.rake +14 -13
  173. metadata +89 -12
  174. data/lib/pact_broker/pacts/all_pact_publications.rb +0 -158
  175. data/lib/pact_broker/pacts/latest_pact_publications.rb +0 -48
  176. data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +0 -26
  177. data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +0 -45
  178. data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +0 -39
  179. data/spec/lib/pact_broker/verifications/latest_verification_for_pact_version_spec.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78ca6573c59b514f1527988079ebeecc19f3fc33b66c7abe7fc9bf00b099c7a1
4
- data.tar.gz: 742f05a5b5348b22aa1efd10dfe2068d76d1259182cfd533442beec8c06e764f
3
+ metadata.gz: b886a748e8133256c6b1a48f018263b18abe3e907878bd659941529791052b72
4
+ data.tar.gz: a236b15253a54764939b260d80aa77e1c3635448ce486606f6013df9f864029d
5
5
  SHA512:
6
- metadata.gz: af16f324d2022596b678ff7c53e1ab4bcae836e12cf376fd415e581fda38e874fbf33094a21bf04c6c8545c534edd78d181326e34d7865898c52bb1915df4d14
7
- data.tar.gz: 1c33d08f629c7db7f2ef12589c0982a5e78a1896c24d400467e26bca8389912ecc305d67ca6ea174132ff8e7c03b67b0d4f3d14a241e3355e79e612cb8cb04c5
6
+ metadata.gz: cededddf5b3eacacd0bc3347bb3350156d2acb5bd29bfd0f43b2a234470ec7a592f4a0b41c167d47f9ec25815092d5bdde16d688b4ded08cce6c1c57008683b3
7
+ data.tar.gz: 683226ee8e28b2055a0e99623c7b2fbbb0bc959308eee60d00f5f255a23411331818c236082f23f56ac4752bd32b63fbe37a702747ce99300e3980dbaa5d4262
@@ -0,0 +1,22 @@
1
+ name: Trigger update to docs.pact.io
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ paths:
8
+ - '**/*.md'
9
+ repository_dispatch:
10
+ types:
11
+ - gem-released
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Trigger docs.pact.io update workflow
18
+ uses: peter-evans/repository-dispatch@v1
19
+ with:
20
+ token: ${{ secrets.GHTOKENFORTRIGGERINGPACTDOCSUPDATE }}
21
+ repository: pact-foundation/docs.pact.io
22
+ event-type: pact-broker-docs-updated
data/CHANGELOG.md CHANGED
@@ -1,3 +1,70 @@
1
+ <a name="v2.88.0"></a>
2
+ ### v2.88.0 (2021-10-11)
3
+
4
+ #### Features
5
+
6
+ * include relations for each consumer version that a pact version belongs to when retrieved using the URL from the 'pacts for verification' response ([3458c9e5](/../../commit/3458c9e5))
7
+
8
+ #### Bug Fixes
9
+
10
+ * use the decoded path info rather than the encoded one when creating the pact info ([dd30a1a2](/../../commit/dd30a1a2))
11
+ * edge case in webhook description rendering with participants specified by labels (#512) ([7e6a78d8](/../../commit/7e6a78d8))
12
+
13
+ * **matrix**
14
+ * prevent long version names overlfow the table (#511) ([3c279556](/../../commit/3c279556))
15
+
16
+ <a name="v2.87.0"></a>
17
+ ### v2.87.0 (2021-10-05)
18
+
19
+ #### Features
20
+
21
+ * **matrix**
22
+ * preselect the consumer version when clicking through to matrix page from integration dashboard ([b550b470](/../../commit/b550b470))
23
+
24
+ * **dashboard**
25
+ * show tooltip explaining auto created branches ([cdaf7f6e](/../../commit/cdaf7f6e))
26
+
27
+ * **can-i-deploy**
28
+ * support ignoring specific version numbers ([2ac5a946](/../../commit/2ac5a946))
29
+ * make verification results URL reference the appropriate consumer version as the pb:pact-version ([145bb37b](/../../commit/145bb37b))
30
+
31
+ * add pb:can-i-deploy-pacticipant-version-to-environment relation ([67328194](/../../commit/67328194))
32
+
33
+ * **webhooks**
34
+ * support ${pactbroker.providerVersionDescriptions} template parameter ([54a073eb](/../../commit/54a073eb))
35
+ * support ${pactbroker.buildUrl} template parameter ([9b79b33f](/../../commit/9b79b33f))
36
+ * support $pactbroker.consumerVersionBranch template parameter ([b97ba84c](/../../commit/b97ba84c))
37
+
38
+ #### Bug Fixes
39
+
40
+ * **mysql**
41
+ * increase size of event_context column ([c1596419](/../../commit/c1596419))
42
+
43
+ * correctly merge dry validation and custom validation error messages when publishing contracts ([688b1e3f](/../../commit/688b1e3f))
44
+
45
+ * **pacts for verification**
46
+ * correct logic for returning pact for main branch when no consumer version selectors are specified ([8847e442](/../../commit/8847e442))
47
+
48
+ * **db clean**
49
+ * optimise calls to identify overwritten data to delete ([aaef9e6d](/../../commit/aaef9e6d))
50
+
51
+ <a name="v2.86.0"></a>
52
+ ### v2.86.0 (2021-09-17)
53
+
54
+ #### Features
55
+
56
+ * allow webhooks to match pacticipants by label (#501) ([f30a9dcc](/../../commit/f30a9dcc))
57
+ * in the webhook body for contract_published and contract_content_changed, use the latest verification from the main branch if present ([b45398bd](/../../commit/b45398bd))
58
+ * change default database_connection_validation_timeout from -1 (every request) to nil (which Sequel will set to 3600 seconds) ([0c508572](/../../commit/0c508572))
59
+ * add version details of the implementation that verified a Pact (#363) ([021a8692](/../../commit/021a8692))
60
+
61
+ <a name="v2.85.1"></a>
62
+ ### v2.85.1 (2021-09-14)
63
+
64
+ #### Bug Fixes
65
+
66
+ * fix bug identifying latest verification for tagged pact ([43ac4b03](/../../commit/43ac4b03))
67
+
1
68
  <a name="v2.85.0"></a>
2
69
  ### v2.85.0 (2021-09-13)
3
70
 
@@ -85,8 +85,6 @@ pact publication resource will be created with an incremented revision number, b
85
85
 
86
86
  * `latest_pact_publications_by_consumer_versions` - This view has the same columns as `all_pact_publications`, but it only contains the latest revision of the pact for each provider/consumer/version. It maps to what a user would consider the "pact" resource ie. `/pacts/provider/PROVIDER/consumer/CONSUMER/version/VERSION`. Previous revisions are not currently exposed via the API.
87
87
 
88
- The `AllPactPublications` Sequel model in the code is what is used when querying data for displaying in a response, rather than the normalised separate PactPublication and PactVersion models.
89
-
90
88
  * `latest_pact_publications` - This view has the same columns as `all_pact_publications`, but it only contains the latest revision of the pact for the latest consumer version for each consumer/provider pair. It is what a user would consider the "latest pact", and maps to the resource at `/pacts/provider/PROVIDER/consumer/CONSUMER/latest`
91
89
 
92
90
  * `latest_tagged_pact_publications` - This view has the same columns as `all_pact_publications`, plus a `tag_name` column. It is used to return the pact for the latest tagged version of a consumer.
@@ -0,0 +1,14 @@
1
+ Sequel.migration do
2
+ change do
3
+ alter_table(:webhooks) do
4
+ add_column(:consumer_label, String)
5
+ add_column(:provider_label, String)
6
+ end
7
+
8
+ # SQLite workaround - with one `alter_table` block it adds only last constraint.
9
+ alter_table(:webhooks) do
10
+ add_constraint(:consumer_label_exclusion, "consumer_id IS NULL OR (consumer_id IS NOT NULL AND consumer_label IS NULL)")
11
+ add_constraint(:provider_label_exclusion, "provider_id IS NULL OR (provider_id IS NOT NULL AND provider_label IS NULL)")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column(:verifications, :verified_by_implementation, String)
4
+ add_column(:verifications, :verified_by_version, String)
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ require_relative "migration_helper"
2
+ include PactBroker::MigrationHelper
3
+
4
+ Sequel.migration do
5
+ up do
6
+ if mysql?
7
+ run("ALTER TABLE triggered_webhooks CHANGE event_context event_context mediumtext")
8
+ end
9
+ end
10
+
11
+ down do
12
+
13
+ end
14
+ end
@@ -33,5 +33,6 @@ services:
33
33
  - ./.gitignore:/home/.gitignore
34
34
  - ./public:/home/public
35
35
  - ./script/docker-container/test.sh:/usr/local/bin/test
36
+ - ./docs:/home/docs
36
37
  entrypoint: dockerize
37
38
  command: --wait tcp://mysql:3306 -timeout 60s test
@@ -49,6 +49,7 @@ services:
49
49
  - ./.rubocop:/home/.rubocop
50
50
  - ./.gitignore:/home/.gitignore
51
51
  - ./public:/home/public
52
+ - ./docs:/home/docs
52
53
 
53
54
  mysql:
54
55
  image: mysql:5.7.28
@@ -97,4 +98,5 @@ services:
97
98
  - ./.rubocop:/home/.rubocop
98
99
  - ./.gitignore:/home/.gitignore
99
100
  - ./public:/home/public
101
+ - ./docs:/home/docs
100
102