pact_broker 2.76.0 → 2.78.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +12 -0
  3. data/.github/workflows/test-ruby-3.yml +19 -0
  4. data/.github/workflows/test.yml +19 -4
  5. data/.gitignore +3 -1
  6. data/CHANGELOG.md +47 -0
  7. data/DEVELOPER_SETUP.md +62 -3
  8. data/Dockerfile +1 -0
  9. data/ISSUES.md +12 -4
  10. data/README.md +1 -1
  11. data/config.ru +1 -0
  12. data/db/ddl_statements/head_pact_tags.rb +24 -1
  13. data/db/ddl_statements/latest_tagged_pact_consumer_version_orders.rb +11 -0
  14. data/db/ddl_statements/latest_tagged_pact_publications.rb +6 -0
  15. data/db/ddl_statements/latest_verification_ids_for_consumer_version_tags.rb +13 -0
  16. data/db/migrations/20210117_add_branch_to_version.rb +9 -0
  17. data/db/migrations/20210202_add_created_at_to_head_pact_tags.rb +14 -0
  18. data/db/migrations/20210205_add_pacticipant_id_to_tag.rb +17 -0
  19. data/db/migrations/20210206_add_index_to_tags_and_versions.rb +27 -0
  20. data/db/migrations/20210207_optimise_latest_verification_ids_for_consumer_version_tags.rb +13 -0
  21. data/db/migrations/20210208_optimise_latest_tagged_pact_cv_orders.rb +13 -0
  22. data/db/migrations/20210210_create_environments_table.rb +16 -0
  23. data/docker-compose-issue-repro-with-pact-broker-docker-image.yml +16 -5
  24. data/lib/pact_broker/api.rb +7 -2
  25. data/lib/pact_broker/api/contracts/dry_validation_predicates.rb +8 -0
  26. data/lib/pact_broker/api/contracts/environment_schema.rb +49 -0
  27. data/lib/pact_broker/api/decorators/base_decorator.rb +11 -0
  28. data/lib/pact_broker/api/decorators/dashboard_decorator.rb +5 -1
  29. data/lib/pact_broker/api/decorators/environment_decorator.rb +30 -0
  30. data/lib/pact_broker/api/decorators/environments_decorator.rb +21 -0
  31. data/lib/pact_broker/api/decorators/matrix_decorator.rb +8 -2
  32. data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -2
  33. data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +2 -0
  34. data/lib/pact_broker/api/decorators/version_decorator.rb +15 -2
  35. data/lib/pact_broker/api/pact_broker_urls.rb +8 -0
  36. data/lib/pact_broker/api/resources/default_base_resource.rb +13 -0
  37. data/lib/pact_broker/api/resources/environment.rb +76 -0
  38. data/lib/pact_broker/api/resources/environments.rb +75 -0
  39. data/lib/pact_broker/api/resources/index.rb +20 -0
  40. data/lib/pact_broker/api/resources/latest_version.rb +27 -0
  41. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +1 -0
  42. data/lib/pact_broker/api/resources/verifications.rb +5 -2
  43. data/lib/pact_broker/api/resources/version.rb +15 -9
  44. data/lib/pact_broker/api/resources/webhook_execution.rb +1 -1
  45. data/lib/pact_broker/app.rb +0 -2
  46. data/lib/pact_broker/certificates/certificate.rb +1 -1
  47. data/lib/pact_broker/config/setting.rb +1 -1
  48. data/lib/pact_broker/config/space_delimited_integer_list.rb +25 -0
  49. data/lib/pact_broker/configuration.rb +18 -1
  50. data/lib/pact_broker/db/data_migrations/helpers.rb +4 -0
  51. data/lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb +29 -0
  52. data/lib/pact_broker/db/migrate_data.rb +1 -0
  53. data/lib/pact_broker/db/seed_example_data.rb +13 -13
  54. data/lib/pact_broker/deployments/environment.rb +15 -0
  55. data/lib/pact_broker/deployments/environment_service.rb +39 -0
  56. data/lib/pact_broker/doc/views/index/environment.markdown +37 -0
  57. data/lib/pact_broker/doc/views/index/environments.markdown +53 -0
  58. data/lib/pact_broker/doc/views/index/latest-pact-versions.markdown +1 -1
  59. data/lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown +1 -0
  60. data/lib/pact_broker/doc/views/index/pacticipant-version.markdown +13 -0
  61. data/lib/pact_broker/domain/index_item.rb +18 -4
  62. data/lib/pact_broker/domain/pacticipant.rb +9 -5
  63. data/lib/pact_broker/domain/tag.rb +131 -71
  64. data/lib/pact_broker/domain/verification.rb +3 -2
  65. data/lib/pact_broker/domain/version.rb +58 -23
  66. data/lib/pact_broker/domain/webhook.rb +12 -9
  67. data/lib/pact_broker/hash_refinements.rb +4 -0
  68. data/lib/pact_broker/index/service.rb +55 -49
  69. data/lib/pact_broker/locale/en.yml +3 -1
  70. data/lib/pact_broker/matrix/quick_row.rb +8 -0
  71. data/lib/pact_broker/metrics/service.rb +1 -1
  72. data/lib/pact_broker/pacts/eager_loaders.rb +52 -0
  73. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +18 -13
  74. data/lib/pact_broker/pacts/lazy_loaders.rb +14 -0
  75. data/lib/pact_broker/pacts/pact_publication.rb +38 -84
  76. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +297 -0
  77. data/lib/pact_broker/pacts/pact_version.rb +1 -2
  78. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +286 -0
  79. data/lib/pact_broker/pacts/repository.rb +5 -231
  80. data/lib/pact_broker/pacts/selected_pact.rb +4 -0
  81. data/lib/pact_broker/pacts/selector.rb +56 -1
  82. data/lib/pact_broker/pacts/selectors.rb +16 -0
  83. data/lib/pact_broker/pacts/service.rb +6 -8
  84. data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +1 -4
  85. data/lib/pact_broker/pacts/verifiable_pact.rb +45 -2
  86. data/lib/pact_broker/pacts/verifiable_pact_messages.rb +56 -16
  87. data/lib/pact_broker/repositories/helpers.rb +4 -0
  88. data/lib/pact_broker/services.rb +9 -0
  89. data/lib/pact_broker/tags/eager_loaders.rb +47 -0
  90. data/lib/pact_broker/tags/repository.rb +3 -1
  91. data/lib/pact_broker/tags/service.rb +0 -3
  92. data/lib/pact_broker/tags/tag_with_latest_flag.rb +1 -0
  93. data/lib/pact_broker/test/http_test_data_builder.rb +92 -26
  94. data/lib/pact_broker/test/test_data_builder.rb +50 -3
  95. data/lib/pact_broker/ui/app.rb +6 -0
  96. data/lib/pact_broker/ui/controllers/base_controller.rb +5 -1
  97. data/lib/pact_broker/ui/controllers/pacts.rb +18 -0
  98. data/lib/pact_broker/ui/view_models/index_item.rb +9 -0
  99. data/lib/pact_broker/ui/view_models/matrix_line.rb +36 -0
  100. data/lib/pact_broker/ui/views/index/show-with-tags.haml +8 -0
  101. data/lib/pact_broker/ui/views/matrix/show.haml +10 -0
  102. data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +7 -5
  103. data/lib/pact_broker/verifications/service.rb +2 -1
  104. data/lib/pact_broker/version.rb +1 -1
  105. data/lib/pact_broker/versions/eager_loaders.rb +71 -0
  106. data/lib/pact_broker/versions/lazy_loaders.rb +13 -0
  107. data/lib/pact_broker/versions/repository.rb +22 -2
  108. data/lib/pact_broker/versions/service.rb +5 -1
  109. data/lib/pact_broker/webhooks/execution.rb +3 -2
  110. data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +2 -0
  111. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +10 -3
  112. data/lib/pact_broker/webhooks/service.rb +8 -7
  113. data/lib/pact_broker/webhooks/trigger_service.rb +56 -23
  114. data/lib/pact_broker/webhooks/triggered_webhook.rb +14 -5
  115. data/lib/pact_broker/webhooks/webhook.rb +1 -1
  116. data/lib/pact_broker/webhooks/webhook_event.rb +1 -1
  117. data/lib/pact_broker/webhooks/webhook_execution_result.rb +6 -1
  118. data/lib/pact_broker/webhooks/webhook_request_logger.rb +7 -1
  119. data/lib/sequel/plugins/upsert.rb +18 -4
  120. data/public/stylesheets/index.css +22 -1
  121. data/public/stylesheets/matrix.css +0 -21
  122. data/regression/can_i_deploy_spec.rb +5 -4
  123. data/regression/index_spec.rb +26 -0
  124. data/regression/regression_helper.rb +29 -3
  125. data/regression/script/clear.sh +3 -0
  126. data/regression/script/run.sh +3 -0
  127. data/script/demonstrate-version-branches.rb +33 -0
  128. data/script/pry.rb +2 -2
  129. data/script/reproduce-issue-starting-up.rb +13 -23
  130. data/script/reproduce-issue.rb +2 -1
  131. data/script/trigger-release.sh +1 -1
  132. data/script/webhook-server.ru +5 -5
  133. data/spec/features/create_environment_spec.rb +47 -0
  134. data/spec/features/create_tag_spec.rb +32 -0
  135. data/spec/features/create_version_spec.rb +70 -0
  136. data/spec/features/delete_environment_spec.rb +16 -0
  137. data/spec/features/end_deployment_spec.rb +29 -0
  138. data/spec/features/get_environment_spec.rb +19 -0
  139. data/spec/features/get_environments_spec.rb +20 -0
  140. data/spec/features/record_deployment_spec.rb +28 -0
  141. data/spec/features/update_environment_spec.rb +44 -0
  142. data/spec/fixtures/approvals/modifiable_resources.approved.json +6 -0
  143. data/spec/fixtures/dashboard.json +4 -2
  144. data/spec/integration/ui/index_spec.rb +4 -4
  145. data/spec/lib/pact_broker/api/contracts/environment_schema_spec.rb +83 -0
  146. data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +4 -2
  147. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +11 -6
  148. data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +6 -6
  149. data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +6 -0
  150. data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +18 -0
  151. data/spec/lib/pact_broker/api/resources/default_base_resource_approval_spec.rb +1 -1
  152. data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +4 -0
  153. data/spec/lib/pact_broker/api/resources/verifications_spec.rb +2 -5
  154. data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +56 -0
  155. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +3 -2
  156. data/spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb +47 -0
  157. data/spec/lib/pact_broker/configuration_spec.rb +12 -0
  158. data/spec/lib/pact_broker/domain/tag_spec.rb +101 -27
  159. data/spec/lib/pact_broker/domain/version_spec.rb +103 -15
  160. data/spec/lib/pact_broker/domain/webhook_spec.rb +7 -7
  161. data/spec/lib/pact_broker/index/service_spec.rb +89 -15
  162. data/spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb +400 -0
  163. data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +434 -14
  164. data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +1 -1
  165. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +1 -1
  166. data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_branch_spec.rb +224 -0
  167. data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +46 -7
  168. data/spec/lib/pact_broker/pacts/selector_spec.rb +3 -2
  169. data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +2 -3
  170. data/spec/lib/pact_broker/pacts/service_spec.rb +9 -7
  171. data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +57 -10
  172. data/spec/lib/pact_broker/tags/repository_spec.rb +2 -0
  173. data/spec/lib/pact_broker/verifications/service_spec.rb +4 -1
  174. data/spec/lib/pact_broker/versions/repository_spec.rb +54 -0
  175. data/spec/lib/pact_broker/webhooks/render_spec.rb +6 -5
  176. data/spec/lib/pact_broker/webhooks/service_spec.rb +13 -9
  177. data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +60 -18
  178. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +8 -0
  179. data/spec/lib/sequel/plugins/upsert_spec.rb +31 -3
  180. data/spec/service_consumers/hal_relation_proxy_app.rb +3 -1
  181. data/spec/service_consumers/provider_states_for_pact_broker_client.rb +16 -0
  182. data/spec/spec_helper.rb +17 -5
  183. data/spec/support/approvals.rb +24 -0
  184. data/spec/support/shared_examples_for_responses.rb +11 -0
  185. data/tasks/db.rake +1 -0
  186. data/tasks/rspec.rake +1 -1
  187. metadata +67 -7
  188. data/docker-compose-issue-repro.yml +0 -22
  189. data/lib/rack/pact_broker/hal_browser_redirect.rb +0 -42
  190. data/spec/lib/rack/pact_broker/hal_browser_redirect_spec.rb +0 -27
@@ -1,22 +0,0 @@
1
- version: "3"
2
-
3
- services:
4
- pact-broker:
5
- build: .
6
- ports:
7
- - "9292:9292"
8
- entrypoint: /usr/local/bin/start
9
- environment:
10
- - RACK_ENV=production
11
- volumes:
12
- - $PWD:/home
13
-
14
- repro-issue:
15
- build: .
16
- depends_on:
17
- - pact-broker
18
- command: dockerize -wait http://pact-broker:9292 -timeout 30s /home/script/reproduce-issue.rb
19
- environment:
20
- - PACT_BROKER_BASE_URL=http://pact-broker:9292
21
- volumes:
22
- - $PWD:/home
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'pact_broker/api/paths'
3
- require 'pact_broker/configuration'
4
-
5
- module Rack
6
- module PactBroker
7
- class HalBrowserRedirect
8
- include ::PactBroker::Api::Paths
9
-
10
- def initialize(app, options = {}, &block)
11
- @app = app
12
- end
13
-
14
- def call(env)
15
- if redirect?(env)
16
- return [303, {'Location' => hal_browser_url_from_request(env)}, []]
17
- else
18
- app.call(env)
19
- end
20
- end
21
-
22
- private
23
-
24
- attr_reader :app
25
-
26
- def redirect?(env)
27
- is_get_for_html?(env) && is_verification_results_path?(env["PATH_INFO"])
28
- end
29
-
30
- def is_get_for_html?(env)
31
- env["REQUEST_METHOD"] == "GET" && env["HTTP_ACCEPT"]&.include?("text/html")
32
- end
33
-
34
- # Doesn't support non root URLs currently
35
- def hal_browser_url_from_request(env)
36
- url = URI.parse("#{env["pactbroker.base_url"]}/hal-browser/browser.html")
37
- url.fragment = "#{env["pactbroker.base_url"]}#{env["PATH_INFO"]}"
38
- url.to_s
39
- end
40
- end
41
- end
42
- end
@@ -1,27 +0,0 @@
1
- require 'rack/pact_broker/hal_browser_redirect'
2
-
3
- module Rack
4
- module PactBroker
5
- describe HalBrowserRedirect do
6
- let(:target_app) { ->(env){ [200, {}, []] } }
7
- let(:app) { HalBrowserRedirect.new(target_app) }
8
- let(:rack_env) do
9
- {
10
- "pactbroker.base_url" => "http://base/foo",
11
- "HTTP_ACCEPT" => "text/html"
12
- }
13
- end
14
-
15
- subject { get(path, nil, rack_env) }
16
-
17
- context "when requesting verification results" do
18
- let(:path) { "/pacts/provider/Bar/consumer/Foo/pact-version/a2456ade40d0e148e23fb3310ec56831fef6ce8e/verification-results/106" }
19
-
20
- it "redirects to the HAL browser" do
21
- expect(subject.status).to eq 303
22
- expect(subject.headers["Location"]).to eq "http://base/foo/hal-browser/browser.html#http://base/foo/pacts/provider/Bar/consumer/Foo/pact-version/a2456ade40d0e148e23fb3310ec56831fef6ce8e/verification-results/106"
23
- end
24
- end
25
- end
26
- end
27
- end