pact_broker 2.81.0 → 2.82.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/CHANGELOG.md +30 -0
  4. data/DEVELOPER_SETUP.md +1 -1
  5. data/README.md +7 -5
  6. data/config.ru +3 -28
  7. data/db/migrations/20210722_add_index_to_triggered_webhooks_webhook_uuid.rb +7 -0
  8. data/db/migrations/20210810_set_allow_contract_modification.rb +17 -0
  9. data/docs/CONFIGURATION.md +398 -0
  10. data/docs/configuration.yml +320 -0
  11. data/example/Gemfile +4 -4
  12. data/example/README.md +15 -22
  13. data/example/config.ru +1 -24
  14. data/example/config/pact_broker.yml +9 -0
  15. data/example/config/puma.rb +3 -0
  16. data/lib/db.rb +1 -1
  17. data/lib/pact_broker/api/authorization/resource_access_policy.rb +68 -0
  18. data/lib/pact_broker/api/authorization/resource_access_rules.rb +40 -0
  19. data/lib/pact_broker/api/decorators/deployed_version_decorator.rb +2 -0
  20. data/lib/pact_broker/api/decorators/released_version_decorator.rb +2 -0
  21. data/lib/pact_broker/api/middleware/basic_auth.rb +63 -0
  22. data/lib/pact_broker/api/resources/pact.rb +15 -6
  23. data/lib/pact_broker/api/resources/tag.rb +1 -14
  24. data/lib/pact_broker/app.rb +52 -30
  25. data/lib/pact_broker/config/basic_auth_configuration.rb +38 -0
  26. data/lib/pact_broker/config/load.rb +21 -10
  27. data/lib/pact_broker/config/runtime_configuration.rb +188 -0
  28. data/lib/pact_broker/config/runtime_configuration_coercion_methods.rb +41 -0
  29. data/lib/pact_broker/config/runtime_configuration_database_methods.rb +119 -0
  30. data/lib/pact_broker/config/runtime_configuration_logging_methods.rb +61 -0
  31. data/lib/pact_broker/configuration.rb +67 -131
  32. data/lib/pact_broker/contracts/notice.rb +4 -0
  33. data/lib/pact_broker/contracts/service.rb +4 -4
  34. data/lib/pact_broker/db/models.rb +3 -0
  35. data/lib/pact_broker/db/validate_encoding.rb +0 -4
  36. data/lib/pact_broker/deployments/deployed_version.rb +8 -2
  37. data/lib/pact_broker/deployments/deployed_version_service.rb +13 -6
  38. data/lib/pact_broker/deployments/environment.rb +1 -1
  39. data/lib/pact_broker/deployments/released_version.rb +8 -0
  40. data/lib/pact_broker/deployments/released_version_service.rb +12 -0
  41. data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +4 -0
  42. data/lib/pact_broker/domain/pacticipant.rb +17 -13
  43. data/lib/pact_broker/domain/verification.rb +4 -22
  44. data/lib/pact_broker/domain/version.rb +9 -5
  45. data/lib/pact_broker/domain/webhook.rb +4 -0
  46. data/lib/pact_broker/error.rb +1 -0
  47. data/lib/pact_broker/errors.rb +1 -1
  48. data/lib/pact_broker/feature_toggle.rb +3 -5
  49. data/lib/pact_broker/hash_refinements.rb +0 -1
  50. data/lib/pact_broker/index/service.rb +4 -6
  51. data/lib/pact_broker/initializers/database_connection.rb +80 -0
  52. data/lib/pact_broker/integrations/integration.rb +5 -0
  53. data/lib/pact_broker/integrations/service.rb +4 -2
  54. data/lib/pact_broker/locale/en.yml +1 -0
  55. data/lib/pact_broker/logging.rb +2 -1
  56. data/lib/pact_broker/matrix/integration.rb +1 -1
  57. data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +2 -2
  58. data/lib/pact_broker/matrix/quick_row.rb +10 -0
  59. data/lib/pact_broker/matrix/repository.rb +64 -3
  60. data/lib/pact_broker/metrics/service.rb +16 -13
  61. data/lib/pact_broker/pacticipants/repository.rb +4 -0
  62. data/lib/pact_broker/pacticipants/service.rb +9 -1
  63. data/lib/pact_broker/pacts/pact_publication.rb +10 -13
  64. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +6 -1
  65. data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +1 -2
  66. data/lib/pact_broker/pacts/pact_version.rb +25 -11
  67. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +54 -77
  68. data/lib/pact_broker/pacts/selected_pact.rb +1 -1
  69. data/lib/pact_broker/pacts/selector.rb +15 -2
  70. data/lib/pact_broker/pacts/selectors.rb +4 -0
  71. data/lib/pact_broker/pacts/service.rb +4 -0
  72. data/lib/pact_broker/repositories/scopes.rb +12 -1
  73. data/lib/pact_broker/string_refinements.rb +6 -0
  74. data/lib/pact_broker/tags/service.rb +8 -1
  75. data/lib/pact_broker/test/http_test_data_builder.rb +11 -5
  76. data/lib/pact_broker/ui/views/index/_css_and_js.haml +11 -9
  77. data/lib/pact_broker/ui/views/index/_pagination.haml +3 -1
  78. data/lib/pact_broker/ui/views/layouts/main.haml +5 -3
  79. data/lib/pact_broker/ui/views/matrix/show.haml +10 -8
  80. data/lib/pact_broker/verifications/required_verification.rb +28 -0
  81. data/lib/pact_broker/verifications/service.rb +49 -1
  82. data/lib/pact_broker/version.rb +1 -1
  83. data/lib/pact_broker/versions/repository.rb +15 -0
  84. data/lib/pact_broker/versions/service.rb +32 -2
  85. data/lib/pact_broker/webhooks/event_listener.rb +3 -0
  86. data/lib/pact_broker/webhooks/trigger_service.rb +30 -14
  87. data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -0
  88. data/lib/pact_broker/webhooks/webhook.rb +2 -2
  89. data/lib/pact_broker/webhooks/webhook_event.rb +6 -1
  90. data/lib/semantic_logger/formatters/short.rb +29 -0
  91. data/pact_broker.gemspec +1 -0
  92. data/script/data/auto-create-things-for-tags.rb +19 -0
  93. data/script/data/contract-published-requiring-verification.rb +27 -0
  94. data/script/{reproduce-issue-expand-currently-deployed.rb → data/expand-currently-deployed.rb} +0 -0
  95. data/script/docs/generate-configuration-docs.rb +86 -0
  96. data/spec/features/get_latest_pact_badge_spec.rb +1 -0
  97. data/spec/features/get_matrix_badge_spec.rb +1 -0
  98. data/spec/features/publish_pact_spec.rb +21 -7
  99. data/spec/features/wip_pacts_spec.rb +1 -1
  100. data/spec/fixtures/approvals/matrix_integration_environment_spec.approved.json +62 -0
  101. data/spec/fixtures/approvals/matrix_integration_ignore_spec.approved.json +124 -0
  102. data/spec/fixtures/approvals/matrix_integration_spec.approved.json +173 -0
  103. data/spec/fixtures/approvals/publish_contract_no_branch.approved.json +9 -9
  104. data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +7 -7
  105. data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +5 -5
  106. data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +5 -5
  107. data/spec/lib/pact_broker/api/middleware/basic_auth_spec.rb +312 -0
  108. data/spec/lib/pact_broker/api/resources/tag_spec.rb +14 -39
  109. data/spec/lib/pact_broker/app_basic_auth_spec.rb +122 -0
  110. data/spec/lib/pact_broker/config/load_spec.rb +33 -6
  111. data/spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb +22 -0
  112. data/spec/lib/pact_broker/config/runtime_configuration_spec.rb +71 -0
  113. data/spec/lib/pact_broker/configuration_spec.rb +51 -25
  114. data/spec/lib/pact_broker/errors/error_logger_spec.rb +3 -0
  115. data/spec/lib/pact_broker/feature_toggle_spec.rb +18 -19
  116. data/spec/lib/pact_broker/matrix/integration_environment_spec.rb +12 -0
  117. data/spec/lib/pact_broker/matrix/integration_ignore_spec.rb +15 -3
  118. data/spec/lib/pact_broker/matrix/integration_spec.rb +47 -6
  119. data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +16 -1
  120. data/spec/lib/pact_broker/matrix/repository_dependency_spec.rb +0 -2
  121. data/spec/lib/pact_broker/matrix/repository_spec.rb +0 -2
  122. data/spec/lib/pact_broker/metrics/service_spec.rb +44 -0
  123. data/spec/lib/pact_broker/pacticipants/service_spec.rb +28 -5
  124. data/spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb +25 -0
  125. data/spec/lib/pact_broker/pacts/pact_version_spec.rb +30 -1
  126. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +107 -20
  127. data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +1 -1
  128. data/spec/lib/pact_broker/tags/service_spec.rb +24 -8
  129. data/spec/lib/pact_broker/verifications/service_spec.rb +146 -0
  130. data/spec/lib/pact_broker/versions/repository_spec.rb +38 -2
  131. data/spec/lib/pact_broker/versions/service_spec.rb +93 -2
  132. data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +54 -2
  133. data/spec/lib/rack/pact_broker/invalid_uri_protection_spec.rb +3 -3
  134. data/spec/spec_helper.rb +2 -1
  135. data/spec/support/approvals.rb +29 -0
  136. metadata +52 -13
  137. data/example/basic_auth/Gemfile +0 -5
  138. data/example/basic_auth/Procfile +0 -1
  139. data/example/basic_auth/README.md +0 -43
  140. data/example/basic_auth/config.ru +0 -19
  141. data/example/example_data.sql +0 -19
  142. data/spec/lib/pact_broker/config/save_and_load_spec.rb +0 -25
  143. data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +0 -50
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.81.0
4
+ version: 2.82.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-07-17 00:00:00.000000000 Z
13
+ date: 2021-08-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -362,6 +362,20 @@ dependencies:
362
362
  - - "~>"
363
363
  - !ruby/object:Gem::Version
364
364
  version: '2.0'
365
+ - !ruby/object:Gem::Dependency
366
+ name: anyway_config
367
+ requirement: !ruby/object:Gem::Requirement
368
+ requirements:
369
+ - - "~>"
370
+ - !ruby/object:Gem::Version
371
+ version: '2.1'
372
+ type: :runtime
373
+ prerelease: false
374
+ version_requirements: !ruby/object:Gem::Requirement
375
+ requirements:
376
+ - - "~>"
377
+ - !ruby/object:Gem::Version
378
+ version: '2.1'
365
379
  description: A server that stores and returns pact files generated by the pact gem.
366
380
  It enables head/prod cross testing of the consumer and provider projects.
367
381
  email:
@@ -561,6 +575,8 @@ files:
561
575
  - db/migrations/20210702_drop_unused_columns_from_deployed_versions.rb
562
576
  - db/migrations/20210711_add_consumer_version_order_to_pact_publication.rb
563
577
  - db/migrations/20210712_add_interaction_count_to_pact_versions.rb
578
+ - db/migrations/20210722_add_index_to_triggered_webhooks_webhook_uuid.rb
579
+ - db/migrations/20210810_set_allow_contract_modification.rb
564
580
  - db/migrations/migration_helper.rb
565
581
  - db/test/backwards_compatibility/.rspec
566
582
  - db/test/backwards_compatibility/Appraisals
@@ -596,15 +612,14 @@ files:
596
612
  - docker-compose-dev-postgres.yml
597
613
  - docker-compose-issue-repro-with-pact-broker-docker-image.yml
598
614
  - docker-compose-test.yml
615
+ - docs/CONFIGURATION.md
616
+ - docs/configuration.yml
599
617
  - docs/images/Pactflow logo - black small.png
600
618
  - example/Gemfile
601
619
  - example/README.md
602
- - example/basic_auth/Gemfile
603
- - example/basic_auth/Procfile
604
- - example/basic_auth/README.md
605
- - example/basic_auth/config.ru
606
620
  - example/config.ru
607
- - example/example_data.sql
621
+ - example/config/pact_broker.yml
622
+ - example/config/puma.rb
608
623
  - issue-reproduction/Dockerfile-pact-broker
609
624
  - lib/db.rb
610
625
  - lib/pact/doc/README.md
@@ -620,6 +635,8 @@ files:
620
635
  - lib/pact/doc/sort_interactions.rb
621
636
  - lib/pact_broker.rb
622
637
  - lib/pact_broker/api.rb
638
+ - lib/pact_broker/api/authorization/resource_access_policy.rb
639
+ - lib/pact_broker/api/authorization/resource_access_rules.rb
623
640
  - lib/pact_broker/api/contracts/base_contract.rb
624
641
  - lib/pact_broker/api/contracts/dry_validation_predicates.rb
625
642
  - lib/pact_broker/api/contracts/dry_validation_workarounds.rb
@@ -694,6 +711,7 @@ files:
694
711
  - lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb
695
712
  - lib/pact_broker/api/decorators/webhook_request_template_decorator.rb
696
713
  - lib/pact_broker/api/decorators/webhooks_decorator.rb
714
+ - lib/pact_broker/api/middleware/basic_auth.rb
697
715
  - lib/pact_broker/api/pact_broker_urls.rb
698
716
  - lib/pact_broker/api/paths.rb
699
717
  - lib/pact_broker/api/renderers/html_pact_renderer.rb
@@ -775,8 +793,13 @@ files:
775
793
  - lib/pact_broker/build_http_options.rb
776
794
  - lib/pact_broker/certificates/certificate.rb
777
795
  - lib/pact_broker/certificates/service.rb
796
+ - lib/pact_broker/config/basic_auth_configuration.rb
778
797
  - lib/pact_broker/config/load.rb
779
798
  - lib/pact_broker/config/repository.rb
799
+ - lib/pact_broker/config/runtime_configuration.rb
800
+ - lib/pact_broker/config/runtime_configuration_coercion_methods.rb
801
+ - lib/pact_broker/config/runtime_configuration_database_methods.rb
802
+ - lib/pact_broker/config/runtime_configuration_logging_methods.rb
780
803
  - lib/pact_broker/config/save.rb
781
804
  - lib/pact_broker/config/setting.rb
782
805
  - lib/pact_broker/config/space_delimited_integer_list.rb
@@ -896,6 +919,7 @@ files:
896
919
  - lib/pact_broker/hash_refinements.rb
897
920
  - lib/pact_broker/index/page.rb
898
921
  - lib/pact_broker/index/service.rb
922
+ - lib/pact_broker/initializers/database_connection.rb
899
923
  - lib/pact_broker/integrations/integration.rb
900
924
  - lib/pact_broker/integrations/service.rb
901
925
  - lib/pact_broker/json.rb
@@ -1022,6 +1046,7 @@ files:
1022
1046
  - lib/pact_broker/verifications/placeholder_verification.rb
1023
1047
  - lib/pact_broker/verifications/pseudo_branch_status.rb
1024
1048
  - lib/pact_broker/verifications/repository.rb
1049
+ - lib/pact_broker/verifications/required_verification.rb
1025
1050
  - lib/pact_broker/verifications/sequence.rb
1026
1051
  - lib/pact_broker/verifications/service.rb
1027
1052
  - lib/pact_broker/verifications/summary_for_consumer_version.rb
@@ -1072,6 +1097,7 @@ files:
1072
1097
  - lib/rack/pact_broker/ui_authentication.rb
1073
1098
  - lib/rack/pact_broker/ui_request_filter.rb
1074
1099
  - lib/rack/pact_broker/use_when.rb
1100
+ - lib/semantic_logger/formatters/short.rb
1075
1101
  - lib/sequel/extensions/statement_timeout.rb
1076
1102
  - lib/sequel/plugins/insert_ignore.rb
1077
1103
  - lib/sequel/plugins/upsert.rb
@@ -1164,7 +1190,10 @@ files:
1164
1190
  - scaffolding/templates/resource_spec.rb.erb
1165
1191
  - scaffolding/templates/service.rb.erb
1166
1192
  - scaffolding/templates/service_spec.rb.erb
1193
+ - script/data/auto-create-things-for-tags.rb
1194
+ - script/data/contract-published-requiring-verification.rb
1167
1195
  - script/data/environments.rb
1196
+ - script/data/expand-currently-deployed.rb
1168
1197
  - script/db-spec.sh
1169
1198
  - script/demonstrate-version-branches.rb
1170
1199
  - script/dev/rubocop-modified-files.sh
@@ -1177,6 +1206,7 @@ files:
1177
1206
  - script/docker/db-rm.sh
1178
1207
  - script/docker/db-start.sh
1179
1208
  - script/docker/mysql-db-start.sh
1209
+ - script/docs/generate-configuration-docs.rb
1180
1210
  - script/exercise-api-for-optic.sh
1181
1211
  - script/foo-bar-verification.json
1182
1212
  - script/foo-bar.json
@@ -1203,7 +1233,6 @@ files:
1203
1233
  - script/release-via-github-action.sh
1204
1234
  - script/release.sh
1205
1235
  - script/reproduce-issue-can-i-deploy-ignore.rb
1206
- - script/reproduce-issue-expand-currently-deployed.rb
1207
1236
  - script/reproduce-issue-starting-up.rb
1208
1237
  - script/reproduce-issue.rb
1209
1238
  - script/restart.sh
@@ -1303,6 +1332,9 @@ files:
1303
1332
  - spec/fixtures/a_consumer-a_provider.json
1304
1333
  - spec/fixtures/approvals/clean_incremental_dry_run.approved.json
1305
1334
  - spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json
1335
+ - spec/fixtures/approvals/matrix_integration_environment_spec.approved.json
1336
+ - spec/fixtures/approvals/matrix_integration_ignore_spec.approved.json
1337
+ - spec/fixtures/approvals/matrix_integration_spec.approved.json
1306
1338
  - spec/fixtures/approvals/modifiable_resources.approved.json
1307
1339
  - spec/fixtures/approvals/publish_contract_no_branch.approved.json
1308
1340
  - spec/fixtures/approvals/publish_contract_nothing_exists.approved.json
@@ -1380,6 +1412,7 @@ files:
1380
1412
  - spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb
1381
1413
  - spec/lib/pact_broker/api/decorators/webhook_request_template_decorator_spec.rb
1382
1414
  - spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
1415
+ - spec/lib/pact_broker/api/middleware/basic_auth_spec.rb
1383
1416
  - spec/lib/pact_broker/api/pact_broker_urls_spec.rb
1384
1417
  - spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb
1385
1418
  - spec/lib/pact_broker/api/renderers/integrations_dot_renderer_spec.rb
@@ -1415,12 +1448,14 @@ files:
1415
1448
  - spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
1416
1449
  - spec/lib/pact_broker/api/resources/webhook_execution_spec.rb
1417
1450
  - spec/lib/pact_broker/api/resources/webhook_spec.rb
1451
+ - spec/lib/pact_broker/app_basic_auth_spec.rb
1418
1452
  - spec/lib/pact_broker/app_spec.rb
1419
1453
  - spec/lib/pact_broker/badges/service_spec.rb
1420
1454
  - spec/lib/pact_broker/build_http_options_spec.rb
1421
1455
  - spec/lib/pact_broker/certificates/service_spec.rb
1422
1456
  - spec/lib/pact_broker/config/load_spec.rb
1423
- - spec/lib/pact_broker/config/save_and_load_spec.rb
1457
+ - spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb
1458
+ - spec/lib/pact_broker/config/runtime_configuration_spec.rb
1424
1459
  - spec/lib/pact_broker/config/save_spec.rb
1425
1460
  - spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb
1426
1461
  - spec/lib/pact_broker/config/space_delimited_string_list_spec.rb
@@ -1511,7 +1546,6 @@ files:
1511
1546
  - spec/lib/pact_broker/pacts/selected_pact_spec.rb
1512
1547
  - spec/lib/pact_broker/pacts/selector_spec.rb
1513
1548
  - spec/lib/pact_broker/pacts/selectors_spec.rb
1514
- - spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb
1515
1549
  - spec/lib/pact_broker/pacts/service_spec.rb
1516
1550
  - spec/lib/pact_broker/pacts/sort_content_spec.rb
1517
1551
  - spec/lib/pact_broker/pacts/squash_pacts_for_verification_spec.rb
@@ -1677,7 +1711,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1677
1711
  - !ruby/object:Gem::Version
1678
1712
  version: '0'
1679
1713
  requirements: []
1680
- rubygems_version: 3.2.24
1714
+ rubygems_version: 3.2.25
1681
1715
  signing_key:
1682
1716
  specification_version: 4
1683
1717
  summary: See description
@@ -1767,6 +1801,9 @@ test_files:
1767
1801
  - spec/fixtures/a_consumer-a_provider.json
1768
1802
  - spec/fixtures/approvals/clean_incremental_dry_run.approved.json
1769
1803
  - spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json
1804
+ - spec/fixtures/approvals/matrix_integration_environment_spec.approved.json
1805
+ - spec/fixtures/approvals/matrix_integration_ignore_spec.approved.json
1806
+ - spec/fixtures/approvals/matrix_integration_spec.approved.json
1770
1807
  - spec/fixtures/approvals/modifiable_resources.approved.json
1771
1808
  - spec/fixtures/approvals/publish_contract_no_branch.approved.json
1772
1809
  - spec/fixtures/approvals/publish_contract_nothing_exists.approved.json
@@ -1844,6 +1881,7 @@ test_files:
1844
1881
  - spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb
1845
1882
  - spec/lib/pact_broker/api/decorators/webhook_request_template_decorator_spec.rb
1846
1883
  - spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
1884
+ - spec/lib/pact_broker/api/middleware/basic_auth_spec.rb
1847
1885
  - spec/lib/pact_broker/api/pact_broker_urls_spec.rb
1848
1886
  - spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb
1849
1887
  - spec/lib/pact_broker/api/renderers/integrations_dot_renderer_spec.rb
@@ -1879,12 +1917,14 @@ test_files:
1879
1917
  - spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
1880
1918
  - spec/lib/pact_broker/api/resources/webhook_execution_spec.rb
1881
1919
  - spec/lib/pact_broker/api/resources/webhook_spec.rb
1920
+ - spec/lib/pact_broker/app_basic_auth_spec.rb
1882
1921
  - spec/lib/pact_broker/app_spec.rb
1883
1922
  - spec/lib/pact_broker/badges/service_spec.rb
1884
1923
  - spec/lib/pact_broker/build_http_options_spec.rb
1885
1924
  - spec/lib/pact_broker/certificates/service_spec.rb
1886
1925
  - spec/lib/pact_broker/config/load_spec.rb
1887
- - spec/lib/pact_broker/config/save_and_load_spec.rb
1926
+ - spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb
1927
+ - spec/lib/pact_broker/config/runtime_configuration_spec.rb
1888
1928
  - spec/lib/pact_broker/config/save_spec.rb
1889
1929
  - spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb
1890
1930
  - spec/lib/pact_broker/config/space_delimited_string_list_spec.rb
@@ -1975,7 +2015,6 @@ test_files:
1975
2015
  - spec/lib/pact_broker/pacts/selected_pact_spec.rb
1976
2016
  - spec/lib/pact_broker/pacts/selector_spec.rb
1977
2017
  - spec/lib/pact_broker/pacts/selectors_spec.rb
1978
- - spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb
1979
2018
  - spec/lib/pact_broker/pacts/service_spec.rb
1980
2019
  - spec/lib/pact_broker/pacts/sort_content_spec.rb
1981
2020
  - spec/lib/pact_broker/pacts/squash_pacts_for_verification_spec.rb
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "pact_broker"
4
- gem "pg"
5
- gem "thin"
@@ -1 +0,0 @@
1
- web: bundle exec thin start -p $PORT
@@ -1,43 +0,0 @@
1
- # Example of Pact Broker configuration on heroku with basic authentication
2
-
3
- ## Create your Pact Broker project
4
-
5
- ```
6
- $ mkdir my-pact-broker
7
- $ cd my-pact-broker
8
- $ git init
9
- ```
10
-
11
- Then copy the files `Gemfile`, `Procfile` and `config.ru` into your project and run bundle
12
- ```
13
- $ bundle
14
- $ gid add .
15
- $ git commit -m "Initial commit"
16
- ```
17
-
18
- It's now time to deploy to heroku! Assuming you already have an account, you need to create a new application with a postgres add-on:
19
- ```
20
- $ gem install heroku
21
- $ heroku create
22
- $ heroku addons:add heroku-postgresql
23
- $ heroku config:set PACT_BROKER_USERNAME=admin
24
- $ heroku config:set PACT_BROKER_PASSWORD=changeme
25
- $ git push heroku master
26
- ```
27
- Your Pact Broker instance is now available!
28
-
29
- ## Publish consumer pacts - consumer side
30
- You will need to set these environment variables with your basic auth credentials
31
- ```
32
- export PACT_BROKER_USERNAME=admin
33
- export PACT_BROKER_PASSWORD=changeme
34
- rake pact:publish
35
- ```
36
-
37
- ## Verify pacts - provider side
38
- In your pact_helper.rb file, you need to specify the basic auth credentials in the pact uris
39
- ```ruby
40
- pact_uri URI.encode("http://#{ENV['PACT_BROKER_USERNAME']}:#{ENV['PACT_BROKER_PASSWORD']}@my-pact-broker.herokuapp.com/pacts/provider_pact_endpoint")
41
- ```
42
-
43
- Enjoy!
@@ -1,19 +0,0 @@
1
- require "fileutils"
2
- require "logger"
3
- require "sequel"
4
- require "pact_broker"
5
- require "pg"
6
-
7
- use Rack::Auth::Basic, "Restricted Area" do |username, password|
8
- username == ENV["PACT_BROKER_USERNAME"] and password == ENV["PACT_BROKER_PASSWORD"]
9
- end
10
-
11
- app = PactBroker::App.new do | config |
12
- # change these from their default values if desired
13
- # config.log_dir = "./log"
14
- # config.auto_migrate_db = true
15
- # config.use_hal_browser = true
16
- config.database_connection = Sequel.connect(ENV["DATABASE_URL"], adapter: "postgres", encoding: "utf8")
17
- end
18
-
19
- run app
@@ -1,19 +0,0 @@
1
- BEGIN TRANSACTION;
2
- INSERT INTO pacticipants VALUES(1,'Animal Service',NULL,'2014-11-18 06:28:36.261868','2014-11-18 06:28:36.261868');
3
- INSERT INTO pacticipants VALUES(2,'Zoo App',NULL,'2014-11-18 06:28:36.290466','2014-11-18 06:28:36.290466');
4
- INSERT INTO pacticipants VALUES(3,'Bar',NULL,'2017-05-23 06:10:23.235822','2017-05-23 06:10:23.235822');
5
- INSERT INTO pacticipants VALUES(4,'Foo',NULL,'2017-05-23 06:10:23.239004','2017-05-23 06:10:23.239004');
6
- INSERT INTO versions VALUES(1,'1.0.0',NULL,2,0,'2014-11-18 06:28:36.295750','2014-11-18 06:28:36.333021');
7
- INSERT INTO versions VALUES(2,'1.0.1',NULL,2,1,'2015-01-19 22:13:57.743993','2015-01-19 22:13:57.746417');
8
- INSERT INTO versions VALUES(3,'1.0.2',NULL,2,2,'2016-11-08 22:45:37.244731','2016-11-08 22:45:37.274760');
9
- INSERT INTO versions VALUES(4,'1.0.0',NULL,4,0,'2017-05-23 06:10:23.243015','2017-05-23 06:10:23.245281');
10
- INSERT INTO pact_versions VALUES(1,2,1,'15a22e805caa9d0153b815fc6566a0c03d4a82ae',replace('{\n "provider": {\n "name": "Animal Service"\n },\n "consumer": {\n "name": "Zoo App"\n },\n "interactions": [\n {\n "description": "a request for an alligator",\n "provider_state": "there is an alligator named Mary",\n "request": {\n "method": "get",\n "path": "/alligators/Mary",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 200,\n "headers": {\n "Content-Type": "application/json;charset=utf-8"\n },\n "body": {\n "name": "Mary"\n }\n }\n },\n {\n "description": "a request for an alligator",\n "provider_state": "there is not an alligator named Mary",\n "request": {\n "method": "get",\n "path": "/alligators/Mary",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 404\n }\n },\n {\n "description": "a request for an alligator",\n "provider_state": "an error occurs retrieving an alligator",\n "request": {\n "method": "get",\n "path": "/alligators/Mary",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 500,\n "headers": {\n "Content-Type": "application/json;charset=utf-8"\n },\n "body": {\n "error": "Argh!!!"\n }\n }\n }\n ],\n "metadata": {\n "pactSpecificationVersion": "1.0.0"\n }\n}','\n',''),'2014-11-18 06:28:36.340041');
11
- INSERT INTO pact_versions VALUES(3,2,1,'23b64b5c5f5baf0e56dd92c4deddf9eb1e249d11',replace('{\n "provider": {\n "name": "Animal Service"\n },\n "consumer": {\n "name": "Zoo App"\n },\n "interactions": [\n {\n "description": "a request for an alligator",\n "provider_state": "there is an alligator named Mary",\n "request": {\n "method": "get",\n "path": "/alligators/Mary",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 200,\n "headers": {\n "Content-Type": "application/json;charset=utf-8"\n },\n "body": {\n "name": "Mary"\n }\n }\n },\n {\n "description": "a request for an alligator",\n "provider_state": "there is not an alligator named Mary",\n "request": {\n "method": "get",\n "path": "/alligators/Mary",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 404\n }\n },\n {\n "description": "a request for an alligator",\n "provider_state": "an error occurs retrieving an alligator",\n "request": {\n "method": "get",\n "path": "/alligators/Mary",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 500,\n "headers": {\n "Content-Type": "application/json;charset=utf-8"\n },\n "body": {\n "error": "Argh!!!"\n }\n }\n },\n {\n "description": "a request for an alligator''s sister",\n "provider_state": "there is an alligator named Mary",\n "request": {\n "method": "get",\n "path": "/alligators/Mary/sister",\n "headers": {\n "Accept": "application/json"\n }\n },\n "response": {\n "status": 200,\n "headers": {\n "Content-Type": "application/json;charset=utf-8"\n },\n "body": {\n "name": "Sue"\n }\n }\n }\n ],\n "metadata": {\n "pactSpecificationVersion": "1.0.0"\n }\n}','\n',''),'2015-01-19 22:15:10.964768');
12
- INSERT INTO pact_versions VALUES(4,4,3,'73cd294d54d900e5ebb313896b1df8d1da8914f9',replace('{\n "consumer": {\n "name": "Foo"\n },\n "provider": {\n "name": "Bar"\n },\n "interactions": [\n {\n "description": "a retrieve thing request",\n "request": {\n "method": "get",\n "path": "/thing"\n },\n "response": {\n "status": 200,\n "headers": {\n "Content-Type": "application/json"\n },\n "body": [\n {\n "status": "4"\n }\n ],\n "matchingRules": {\n "$.body": {\n "min": 1\n },\n "$.body[*].*": {\n "match": "type"\n },\n "$.body[*].status": {\n "match": "regex",\n "regex": "\\d+"\n }\n }\n }\n }\n ],\n "metadata": {\n "pactSpecification": {\n "version": "2.0.0"\n }\n }\n}','\n',''),'2017-05-23 06:10:23.249813');
13
- INSERT INTO pact_publications VALUES(1,1,1,1,1,'2014-11-18 06:28:36.340041');
14
- INSERT INTO pact_publications VALUES(2,2,1,1,3,'2015-01-19 22:15:10.969518');
15
- INSERT INTO pact_publications VALUES(3,3,1,1,1,'2016-11-08 22:45:37.291839');
16
- INSERT INTO pact_publications VALUES(4,4,3,1,4,'2017-05-23 06:10:23.252829');
17
- INSERT INTO materialized_matrix SELECT * FROM matrix;
18
- INSERT INTO materialized_head_matrix SELECT * FROM head_matrix;
19
- COMMIT;
@@ -1,25 +0,0 @@
1
- require "pact_broker/config/load"
2
- require "pact_broker/config/save"
3
-
4
- module PactBroker
5
- module Config
6
- describe "Save and Load" do
7
-
8
- let(:setting_names) { configuration_to_save.to_h.keys }
9
- let(:configuration_to_save) do
10
- OpenStruct.new(foo: true, bar: false, wiffle: nil, meep: [1, "2"], mop: {a: "b"}, la: 1, lala: 1.2)
11
- end
12
-
13
- let(:loaded_configuration) do
14
- OpenStruct.new(foo: nil, bar: "1", wiffle: [], meep: nil, mop: nil, la: nil, lala: nil)
15
- end
16
-
17
- subject { Save.call(configuration_to_save, setting_names); Load.call(loaded_configuration) }
18
-
19
- it "the loaded configuration is the same as the saved one" do
20
- subject
21
- expect(loaded_configuration).to eq configuration_to_save
22
- end
23
- end
24
- end
25
- end
@@ -1,50 +0,0 @@
1
- require "spec_helper"
2
- require "pact_broker/pacts/service"
3
- require "pact_broker/pacts/pact_params"
4
-
5
- module PactBroker
6
- module Pacts
7
- describe Service do
8
- let(:td) { TestDataBuilder.new }
9
-
10
- describe "find_for_verification" do
11
- include_context "stubbed repositories"
12
-
13
- let(:head_pacts) { [pact_1, pact_2] }
14
- let(:head_tag_1) { "dev" }
15
- let(:head_tag_2) { "feat-x" }
16
- let(:pact_version_sha_1) { "1" }
17
- let(:pact_version_sha_2) { "2" }
18
- let(:domain_pact_1) { double("pact1", pending?: true) }
19
- let(:domain_pact_2) { double("pact2", pending?: true) }
20
-
21
- let(:pact_1) do
22
- double("HeadPact",
23
- head_tag: head_tag_1,
24
- pact_version_sha: pact_version_sha_1,
25
- pact: domain_pact_1
26
- )
27
- end
28
-
29
- let(:pact_2) do
30
- double("HeadPact",
31
- head_tag: head_tag_2,
32
- pact_version_sha: pact_version_sha_2,
33
- pact: domain_pact_2
34
- )
35
- end
36
-
37
- let(:provider_name) { "Bar" }
38
- let(:provider_version_tags) { [] }
39
- let(:provider_version_branch) { "main" }
40
- let(:consumer_version_selectors) { [] }
41
-
42
- before do
43
- allow(pact_repository).to receive(:find_for_verification).and_return(head_pacts)
44
- end
45
-
46
- subject { Service.find_for_verification(provider_name, provider_version_branch, provider_version_tags, consumer_version_selectors) }
47
- end
48
- end
49
- end
50
- end