pact_broker 2.84.0 → 2.87.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/trigger_pact_docs_update.yml +22 -0
  3. data/CHANGELOG.md +63 -0
  4. data/DEVELOPER_DOCUMENTATION.md +0 -2
  5. data/db/migrations/20210913_add_pending_to_verifications.rb +7 -0
  6. data/db/migrations/20210914_add_labels_to_webhooks.rb +14 -0
  7. data/db/migrations/20210915_add_verified_by_to_verification.rb +6 -0
  8. data/db/migrations/20210929_increase_event_context_column_size.rb +14 -0
  9. data/docker-compose-ci-mysql.yml +1 -0
  10. data/docker-compose-test.yml +2 -0
  11. data/docs/CONFIGURATION.md +255 -66
  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 +4 -4
  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/reason_decorator.rb +2 -2
  21. data/lib/pact_broker/api/decorators/verification_decorator.rb +9 -3
  22. data/lib/pact_broker/api/decorators/verification_summary_decorator.rb +1 -2
  23. data/lib/pact_broker/api/decorators/webhook_decorator.rb +27 -4
  24. data/lib/pact_broker/api/middleware/configuration.rb +33 -0
  25. data/lib/pact_broker/api/pact_broker_urls.rb +35 -7
  26. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +15 -11
  27. data/lib/pact_broker/api/resources/all_webhooks.rb +2 -2
  28. data/lib/pact_broker/api/resources/default_base_resource.rb +4 -0
  29. data/lib/pact_broker/api/resources/environment.rb +1 -1
  30. data/lib/pact_broker/api/resources/environments.rb +1 -1
  31. data/lib/pact_broker/api/resources/index.rb +7 -1
  32. data/lib/pact_broker/api/resources/pact_versions_for_branch.rb +40 -0
  33. data/lib/pact_broker/api/resources/publish_contracts.rb +1 -1
  34. data/lib/pact_broker/api/resources/verification.rb +5 -2
  35. data/lib/pact_broker/api/resources/verifications.rb +5 -1
  36. data/lib/pact_broker/api/resources/webhook_execution_methods.rb +23 -17
  37. data/lib/pact_broker/api.rb +2 -0
  38. data/lib/pact_broker/app.rb +2 -0
  39. data/lib/pact_broker/application_context.rb +5 -0
  40. data/lib/pact_broker/badges/service.rb +3 -1
  41. data/lib/pact_broker/config/runtime_configuration.rb +4 -0
  42. data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
  43. data/lib/pact_broker/configuration.rb +33 -29
  44. data/lib/pact_broker/db/clean.rb +1 -2
  45. data/lib/pact_broker/db/delete_overwritten_data.rb +41 -23
  46. data/lib/pact_broker/deployments/deployed_version.rb +1 -0
  47. data/lib/pact_broker/deployments/deployed_version_service.rb +1 -0
  48. data/lib/pact_broker/deployments/environment_service.rb +4 -1
  49. data/lib/pact_broker/deployments/released_version_service.rb +1 -0
  50. data/lib/pact_broker/doc/controllers/app.rb +1 -0
  51. data/lib/pact_broker/doc/views/can-i-deploy.markdown +2 -1
  52. data/lib/pact_broker/doc/views/index/publish-contracts.markdown +38 -9
  53. data/lib/pact_broker/doc/views/pacticipant/label.markdown +12 -0
  54. data/lib/pact_broker/doc/views/webhooks.markdown +17 -0
  55. data/lib/pact_broker/domain/index_item.rb +9 -0
  56. data/lib/pact_broker/domain/pacticipant.rb +4 -0
  57. data/lib/pact_broker/domain/verification.rb +28 -4
  58. data/lib/pact_broker/domain/webhook.rb +27 -15
  59. data/lib/pact_broker/domain/webhook_pacticipant.rb +6 -0
  60. data/lib/pact_broker/domain/webhook_request.rb +2 -2
  61. data/lib/pact_broker/index/service.rb +77 -26
  62. data/lib/pact_broker/locale/en.yml +6 -1
  63. data/lib/pact_broker/matrix/head_row.rb +1 -1
  64. data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +5 -3
  65. data/lib/pact_broker/matrix/quick_row.rb +0 -1
  66. data/lib/pact_broker/matrix/repository.rb +0 -1
  67. data/lib/pact_broker/matrix/row.rb +2 -2
  68. data/lib/pact_broker/pacticipants/repository.rb +1 -1
  69. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +0 -1
  70. data/lib/pact_broker/pacts/metadata.rb +11 -3
  71. data/lib/pact_broker/pacts/pact_publication.rb +44 -0
  72. data/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb +19 -0
  73. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +68 -1
  74. data/lib/pact_broker/pacts/pact_version.rb +24 -1
  75. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +5 -4
  76. data/lib/pact_broker/pacts/repository.rb +52 -48
  77. data/lib/pact_broker/pacts/service.rb +5 -5
  78. data/lib/pact_broker/string_refinements.rb +1 -1
  79. data/lib/pact_broker/test/http_test_data_builder.rb +40 -11
  80. data/lib/pact_broker/test/test_data_builder.rb +27 -6
  81. data/lib/pact_broker/ui/app.rb +7 -1
  82. data/lib/pact_broker/ui/controllers/dashboard.rb +80 -0
  83. data/lib/pact_broker/ui/controllers/groups.rb +23 -8
  84. data/lib/pact_broker/ui/helpers/url_helper.rb +17 -1
  85. data/lib/pact_broker/ui/view_models/index_item.rb +64 -8
  86. data/lib/pact_broker/ui/view_models/index_item_branch_head.rb +39 -0
  87. data/lib/pact_broker/ui/view_models/index_item_provider_branch_head.rb +39 -0
  88. data/lib/pact_broker/ui/view_models/matrix_branch.rb +1 -1
  89. data/lib/pact_broker/ui/view_models/matrix_tag.rb +0 -1
  90. data/lib/pact_broker/ui/views/dashboard/show.haml +202 -0
  91. data/lib/pact_broker/ui/views/groups/show.html.erb +60 -14
  92. data/lib/pact_broker/ui/views/index/_dashboard_navbar.haml +7 -0
  93. data/lib/pact_broker/ui/views/index/_navbar.haml +0 -7
  94. data/lib/pact_broker/ui/views/index/show-with-tags.haml +3 -1
  95. data/lib/pact_broker/ui/views/index/show.haml +35 -13
  96. data/lib/pact_broker/ui/views/matrix/show.haml +7 -3
  97. data/lib/pact_broker/verifications/pseudo_branch_status.rb +2 -0
  98. data/lib/pact_broker/verifications/repository.rb +5 -2
  99. data/lib/pact_broker/verifications/service.rb +8 -4
  100. data/lib/pact_broker/version.rb +1 -1
  101. data/lib/pact_broker/versions/branch_head.rb +0 -2
  102. data/lib/pact_broker/versions/branch_version.rb +1 -0
  103. data/lib/pact_broker/versions/repository.rb +0 -1
  104. data/lib/pact_broker/webhooks/event_listener.rb +7 -5
  105. data/lib/pact_broker/webhooks/execution_configuration.rb +16 -0
  106. data/lib/pact_broker/webhooks/execution_configuration_creator.rb +3 -0
  107. data/lib/pact_broker/webhooks/job.rb +1 -1
  108. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +18 -3
  109. data/lib/pact_broker/webhooks/repository.rb +10 -4
  110. data/lib/pact_broker/webhooks/trigger_service.rb +3 -3
  111. data/lib/pact_broker/webhooks/webhook.rb +71 -8
  112. data/lib/pact_broker/webhooks/webhook_execution_result.rb +3 -7
  113. data/lib/pact_broker/webhooks/webhook_request_logger.rb +4 -12
  114. data/lib/pact_broker/webhooks/webhook_request_template.rb +6 -8
  115. data/pact_broker.gemspec +4 -0
  116. data/public/javascripts/index.js +75 -68
  117. data/public/javascripts/pact.js +14 -14
  118. data/public/stylesheets/index.css +6 -2
  119. data/public/stylesheets/pact.css +11 -0
  120. data/script/data/auto-create-things-for-tags.rb +3 -0
  121. data/script/data/branches.rb +2 -2
  122. data/script/data/contract-published-requiring-verification.rb +0 -1
  123. data/script/data/environments.rb +0 -0
  124. data/script/data/pending.rb +26 -0
  125. data/script/data/tags.rb +35 -0
  126. data/script/data/verify-pact-for-multiple-selectors.rb +30 -0
  127. data/script/data/webhook.rb +22 -0
  128. data/script/docs/generate-configuration-docs.rb +24 -3
  129. data/script/generate-erd +55 -0
  130. data/script/seed.rb +50 -89
  131. data/spec/features/create_webhook_spec.rb +55 -10
  132. data/spec/features/delete_pact_versions_for_branch_spec.rb +34 -0
  133. data/spec/features/get_pact_spec.rb +2 -3
  134. data/spec/fixtures/approvals/modifiable_resources.approved.json +4 -0
  135. data/spec/fixtures/invalid-publish-contract-body.json +38 -0
  136. data/spec/fixtures/verification.json +4 -0
  137. data/spec/integration/app_spec.rb +6 -6
  138. data/spec/integration/webhooks/contract_publication_spec.rb +68 -0
  139. data/spec/integration/webhooks/contract_requiring_verification_published_spec.rb +67 -0
  140. data/spec/integration/webhooks/pact_publication_spec.rb +51 -0
  141. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +2 -2
  142. data/spec/lib/pact_broker/api/contracts/publish_contracts_schema_spec.rb +13 -0
  143. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +50 -0
  144. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +1 -1
  145. data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +2 -2
  146. data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +15 -7
  147. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +6 -2
  148. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +4 -4
  149. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +1 -1
  150. data/spec/lib/pact_broker/api/middleware/configuration_spec.rb +43 -0
  151. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +18 -0
  152. data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +6 -5
  153. data/spec/lib/pact_broker/api/resources/verifications_spec.rb +2 -3
  154. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +1 -1
  155. data/spec/lib/pact_broker/badges/service_spec.rb +22 -0
  156. data/spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb +30 -0
  157. data/spec/lib/pact_broker/deployments/environment_service_spec.rb +1 -1
  158. data/spec/lib/pact_broker/domain/webhook_request_spec.rb +2 -1
  159. data/spec/lib/pact_broker/domain/webhook_spec.rb +15 -5
  160. data/spec/lib/pact_broker/index/service_spec.rb +1 -5
  161. data/spec/lib/pact_broker/index/service_view_spec.rb +144 -0
  162. data/spec/lib/pact_broker/matrix/head_row_spec.rb +9 -5
  163. data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +13 -0
  164. data/spec/lib/pact_broker/pacts/metadata_spec.rb +11 -2
  165. data/spec/lib/pact_broker/pacts/{latest_tagged_pact_publications_spec.rb → pact_publication_clean_selector_dataset_module_spec.rb} +7 -9
  166. data/spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb +29 -0
  167. data/spec/lib/pact_broker/pacts/pact_version_spec.rb +32 -0
  168. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +4 -5
  169. data/spec/lib/pact_broker/pacts/repository_spec.rb +48 -2
  170. data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +12 -9
  171. data/spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb +9 -1
  172. data/spec/lib/pact_broker/verifications/service_spec.rb +24 -8
  173. data/spec/lib/pact_broker/webhooks/job_spec.rb +4 -4
  174. data/spec/lib/pact_broker/webhooks/render_spec.rb +3 -2
  175. data/spec/lib/pact_broker/webhooks/repository_spec.rb +158 -15
  176. data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +9 -5
  177. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +6 -12
  178. data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +3 -2
  179. data/spec/lib/pact_broker/webhooks/webhook_spec.rb +8 -5
  180. data/spec/support/generated_markdown.md +3 -3
  181. data/tasks/db.rake +4 -1
  182. metadata +72 -14
  183. data/lib/pact_broker/pacts/all_pact_publications.rb +0 -158
  184. data/lib/pact_broker/pacts/latest_pact_publications.rb +0 -48
  185. data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +0 -26
  186. data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +0 -45
  187. data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +0 -39
  188. data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +0 -56
  189. data/spec/lib/pact_broker/verifications/latest_verification_for_pact_version_spec.rb +0 -18
@@ -1,56 +0,0 @@
1
- module PactBroker
2
- module Webhooks
3
- describe WebhookExecutionResult do
4
- subject { WebhookExecutionResult::new(request, response, nil) }
5
- let(:request) do
6
- Net::HTTP::Get.new("http://example.org?foo=bar")
7
- end
8
-
9
- context "When 'webhook_http_code_success' has [200, 201]" do
10
- before do
11
- allow(PactBroker.configuration).to receive(:webhook_http_code_success).and_return([200, 201])
12
- end
13
-
14
- context "and response is '200'" do
15
- let(:response) { double(code: "200") }
16
-
17
- it "then it should be success" do
18
- expect(subject.success?).to be_truthy
19
- end
20
- end
21
-
22
- context "and response is '400'" do
23
- let(:response) { double(code: "400") }
24
-
25
- it "then it should fail" do
26
- expect(subject.success?).to be_falsey
27
- end
28
- end
29
- end
30
-
31
-
32
- context "When 'webhook_http_code_success' has [400, 401]" do
33
- before do
34
- allow(PactBroker.configuration).to receive(:webhook_http_code_success).and_return([400, 401])
35
- end
36
-
37
- context "and response is '200'" do
38
- let(:response) { double(code: "200") }
39
-
40
- it "then it should fail" do
41
- expect(subject.success?).to be_falsey
42
- end
43
- end
44
-
45
- context "and response is '400'" do
46
- let(:response) { double(code: "400") }
47
-
48
- it "then it should be success" do
49
- expect(subject.success?).to be_truthy
50
- end
51
- end
52
- end
53
-
54
- end
55
- end
56
- end
@@ -1,18 +0,0 @@
1
- require "pact_broker/verifications/latest_verification_for_pact_version"
2
-
3
- module PactBroker
4
- module Verifications
5
- describe LatestVerificationForPactVersion do
6
- before do
7
- td.create_pact_with_hierarchy("Foo", "1", "Bar")
8
- .create_verification(provider_version: "2")
9
- end
10
-
11
- subject { LatestVerificationForPactVersion.first }
12
-
13
- its(:"consumer.name") { is_expected.to eq "Foo" }
14
- its(:"provider.name") { is_expected.to eq "Bar" }
15
- its(:"provider_version.number") { is_expected.to eq "2" }
16
- end
17
- end
18
- end