pact_broker 2.59.0 → 2.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release_gem.yml +19 -6
  3. data/CHANGELOG.md +43 -0
  4. data/README.md +1 -1
  5. data/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb +10 -3
  6. data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +1 -0
  7. data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +5 -5
  8. data/lib/pact_broker/api/resources/all_webhooks.rb +1 -6
  9. data/lib/pact_broker/api/resources/can_i_deploy.rb +0 -4
  10. data/lib/pact_broker/api/resources/default_base_resource.rb +9 -0
  11. data/lib/pact_broker/api/resources/error_handler.rb +2 -4
  12. data/lib/pact_broker/api/resources/error_test.rb +4 -2
  13. data/lib/pact_broker/api/resources/group.rb +0 -4
  14. data/lib/pact_broker/api/resources/index.rb +11 -8
  15. data/lib/pact_broker/api/resources/integration.rb +0 -4
  16. data/lib/pact_broker/api/resources/integrations.rb +0 -4
  17. data/lib/pact_broker/api/resources/label.rb +0 -8
  18. data/lib/pact_broker/api/resources/latest_pact.rb +1 -5
  19. data/lib/pact_broker/api/resources/latest_pacts.rb +1 -5
  20. data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +0 -4
  21. data/lib/pact_broker/api/resources/matrix.rb +4 -0
  22. data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +4 -0
  23. data/lib/pact_broker/api/resources/metrics.rb +4 -0
  24. data/lib/pact_broker/api/resources/pact.rb +4 -8
  25. data/lib/pact_broker/api/resources/pact_content_diff.rb +4 -0
  26. data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +5 -1
  27. data/lib/pact_broker/api/resources/pact_versions.rb +5 -1
  28. data/lib/pact_broker/api/resources/pact_webhooks.rb +5 -1
  29. data/lib/pact_broker/api/resources/pact_webhooks_status.rb +5 -1
  30. data/lib/pact_broker/api/resources/pacticipant.rb +5 -9
  31. data/lib/pact_broker/api/resources/pacticipants.rb +0 -4
  32. data/lib/pact_broker/api/resources/pacticipants_for_label.rb +4 -0
  33. data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +4 -9
  34. data/lib/pact_broker/api/resources/provider_pacts.rb +1 -5
  35. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +8 -6
  36. data/lib/pact_broker/api/resources/relationships.rb +4 -2
  37. data/lib/pact_broker/api/resources/tag.rb +5 -5
  38. data/lib/pact_broker/api/resources/tagged_pact_versions.rb +5 -2
  39. data/lib/pact_broker/api/resources/triggered_webhook_logs.rb +7 -5
  40. data/lib/pact_broker/api/resources/verification.rb +5 -5
  41. data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +6 -12
  42. data/lib/pact_broker/api/resources/verifications.rb +5 -5
  43. data/lib/pact_broker/api/resources/version.rb +5 -5
  44. data/lib/pact_broker/api/resources/versions.rb +5 -2
  45. data/lib/pact_broker/api/resources/webhook.rb +4 -0
  46. data/lib/pact_broker/api/resources/webhook_execution.rb +4 -0
  47. data/lib/pact_broker/api/resources/webhooks.rb +5 -1
  48. data/lib/pact_broker/app.rb +1 -1
  49. data/lib/pact_broker/badges/service.rb +1 -1
  50. data/lib/pact_broker/certificates/service.rb +2 -2
  51. data/lib/pact_broker/configuration.rb +10 -1
  52. data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +78 -0
  53. data/lib/pact_broker/domain/pact.rb +9 -0
  54. data/lib/pact_broker/groups/service.rb +1 -1
  55. data/lib/pact_broker/index/service.rb +6 -0
  56. data/lib/pact_broker/matrix/deployment_status_summary.rb +1 -1
  57. data/lib/pact_broker/pacts/build_verifiable_pact_notices.rb +7 -4
  58. data/lib/pact_broker/pacts/content.rb +30 -5
  59. data/lib/pact_broker/pacts/repository.rb +25 -31
  60. data/lib/pact_broker/pacts/selector.rb +8 -0
  61. data/lib/pact_broker/version.rb +1 -1
  62. data/lib/pact_broker/webhooks/job.rb +8 -2
  63. data/lib/pact_broker/webhooks/service.rb +1 -1
  64. data/script/seed.rb +39 -17
  65. data/spec/features/get_provider_pacts_for_verification_spec.rb +8 -0
  66. data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_spec.rb +23 -4
  67. data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +10 -5
  68. data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +18 -1
  69. data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +1 -1
  70. data/spec/lib/pact_broker/api/resources/verification_triggered_webhooks_spec.rb +0 -1
  71. data/spec/lib/pact_broker/badges/service_spec.rb +1 -1
  72. data/spec/lib/pact_broker/certificates/service_spec.rb +3 -3
  73. data/spec/lib/pact_broker/pacts/content_spec.rb +90 -0
  74. data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +14 -0
  75. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +62 -0
  76. data/spec/lib/pact_broker/webhooks/job_spec.rb +19 -1
  77. data/spec/lib/pact_broker/webhooks/service_spec.rb +2 -2
  78. data/spec/support/database_cleaner.rb +1 -5
  79. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9b0e297ccfb28aff9a5671f6db509740d72b305ea876c90dd9f43801a29d678
4
- data.tar.gz: 2671cd878bcdfa50e841b8f69f40188053f7c65646100b94ea2d700add445132
3
+ metadata.gz: 3495dd128672a4f4e614b7c60d93734cb3eee3799863af054963c503172d86f2
4
+ data.tar.gz: be415648babf90774ef011a0485835f386632768fb95b5a1f125ea9bddea2492
5
5
  SHA512:
6
- metadata.gz: 2a1e25b8199ca7a2ed5940d32f749273d1e9be09bb376440902fd3b72bcfaaa26820b98c177cf22922d1ea325afd821b12b8136e3e0728febbed261ecbe92a12
7
- data.tar.gz: 64735e63241058558c290c24e46ff929bb89d7515d7d97413d9e18491b543128a610fc568b711efb9e2fba6bb099d99ed4600aee842c9119e47961a5b99d7a46
6
+ metadata.gz: aabedcd424d01dfa172424f99feac69d71ce2c55fe97f5c6b25dc1e29247168c14f0aa0d56c144c353a9444cd1cce99e14f7b677161f609ca829d00fdd2cf72c
7
+ data.tar.gz: a18db48c05cb2f3ae9ebc48b18673d45b4bafe19574633fef2d0ae6c21c2242a7b5cd80dab359eeccedb7044dcb1c2895b8290065fd4e7c7db5ba9c6686fefc4
@@ -24,9 +24,22 @@ jobs:
24
24
  GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'
25
25
  GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
26
26
  INCREMENT: '${{ github.event.client_payload.increment }}'
27
- # - name: Trigger release of pact-cli Docker image
28
- # uses: peter-evans/repository-dispatch@v1
29
- # with:
30
- # token: ${{ secrets.GHTOKENFORPACTCLIRELEASE }}
31
- # repository: pact-foundation/pact-ruby-cli
32
- # event-type: gem-released
27
+ notify-gem-released:
28
+ needs: release
29
+ strategy:
30
+ matrix:
31
+ repository: [pact-foundation/pact-broker-docker, DiUS/pact_broker-docker]
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - name: Notify ${{ matrix.repository }} of gem release
35
+ uses: peter-evans/repository-dispatch@v1
36
+ with:
37
+ token: ${{ secrets.GHTOKENNOTIFYPBRELEASED }}
38
+ repository: ${{ matrix.repository }}
39
+ event-type: gem-released
40
+ client-payload: |
41
+ {
42
+ "name": "${{ needs.release.outputs.gem_name }}",
43
+ "version": "${{ needs.release.outputs.version }}",
44
+ "increment": "${{ needs.release.outputs.increment }}"
45
+ }
@@ -1,3 +1,46 @@
1
+ <a name="v2.61.0"></a>
2
+ ### v2.61.0 (2020-09-12)
3
+
4
+ #### Features
5
+
6
+ * add back support for GET requests to the 'pacts for verification' API with a deprecation notice in the response ([8f45cc9f](/../../commit/8f45cc9f))
7
+
8
+ <a name="v2.60.1"></a>
9
+ ### v2.60.1 (2020-09-10)
10
+
11
+ #### Bug Fixes
12
+
13
+ * href for beta:provider-pacts-for-verification ([3949fdd1](/../../commit/3949fdd1))
14
+
15
+ <a name="v2.60.0"></a>
16
+ ### v2.60.0 (2020-09-08)
17
+
18
+ #### Features
19
+
20
+ * **pacts for verification**
21
+ * add deprecation title to beta:provider-pacts-for-verification relation ([47a61f69](/../../commit/47a61f69))
22
+ * do not require environment variable feature toggle to enable feature ([7d0fe1ea](/../../commit/7d0fe1ea))
23
+ * allow consumer to be specified with fallback tags, and overall latest to be specified with or without a consumer ([2d52d173](/../../commit/2d52d173))
24
+
25
+ #### Bug Fixes
26
+
27
+ * correctly handle new test results format when merging test results with pact contents ([b35ab71b](/../../commit/b35ab71b))
28
+
29
+ <a name="v2.59.2"></a>
30
+ ### v2.59.2 (2020-08-06)
31
+
32
+ #### Bug Fixes
33
+
34
+ * gracefully handle contracts without interactions or messages in deployment status warnings ([6c223e69](/../../commit/6c223e69))
35
+ * add missing info level log for business level errors ([80a895bf](/../../commit/80a895bf))
36
+
37
+ <a name="v2.59.1"></a>
38
+ ### v2.59.1 (2020-08-04)
39
+
40
+ #### Bug Fixes
41
+
42
+ * fix error rendering relationships diagram when the number of index items is greater than one page ([93a19982](/../../commit/93a19982))
43
+
1
44
  <a name="v2.59.0"></a>
2
45
  ### v2.59.0 (2020-07-30)
3
46
 
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Code Climate](https://codeclimate.com/github/pact-foundation/pact_broker/badges/gpa.svg)](https://codeclimate.com/github/pact-foundation/pact_broker)
7
7
  [![Test Coverage](https://codeclimate.com/github/pact-foundation/pact_broker/badges/coverage.svg)](https://codeclimate.com/github/pact-foundation/pact_broker/coverage)
8
8
 
9
- The Pact Broker is an application for sharing for consumer driven contracts and verification results. It is optimised for use with "pacts" (contracts created by the [Pact][pact-docs] framework), but can be used for any type of contract that can be serialized to JSON.
9
+ The Pact Broker is an application for sharing of consumer driven contracts and verification results. It is optimised for use with "pacts" (contracts created by the [Pact][pact-docs] framework), but can be used for any type of contract that can be serialized to JSON.
10
10
 
11
11
  <br/>
12
12
  <a href="https:/pactflow.io/?utm_source=github&utm_campaign=pact_broker_intro"><img src="docs/images/Pactflow logo - black small.png"></a>
@@ -1,5 +1,6 @@
1
1
  require 'dry-validation'
2
2
  require 'pact_broker/hash_refinements'
3
+ require 'pact_broker/string_refinements'
3
4
  require 'pact_broker/api/contracts/dry_validation_workarounds'
4
5
  require 'pact_broker/api/contracts/dry_validation_predicates'
5
6
 
@@ -9,6 +10,7 @@ module PactBroker
9
10
  class VerifiablePactsJSONQuerySchema
10
11
  extend DryValidationWorkarounds
11
12
  using PactBroker::HashRefinements
13
+ using PactBroker::StringRefinements
12
14
 
13
15
  SCHEMA = Dry::Validation.Schema do
14
16
  configure do
@@ -24,7 +26,7 @@ module PactBroker
24
26
  # end
25
27
  # end
26
28
 
27
- required(:tag).filled(:str?)
29
+ optional(:tag).filled(:str?)
28
30
  optional(:latest).filled(included_in?: [true, false])
29
31
  optional(:fallbackTag).filled(:str?)
30
32
  optional(:consumer).filled(:str?, :not_blank?)
@@ -54,8 +56,9 @@ module PactBroker
54
56
  errors << "fallbackTag can only be set if latest is true (at index #{index})"
55
57
  end
56
58
 
57
- if selector[:consumer] && selector[:latest]
58
- errors << "specifying a consumer with latest == true is not yet supported (at index #{index})"
59
+
60
+ if not_provided?(selector[:tag]) && selector[:latest] != true
61
+ errors << "latest must be true, or a tag must be provided (at index #{index})"
59
62
  end
60
63
  end
61
64
  if errors.any?
@@ -64,6 +67,10 @@ module PactBroker
64
67
  end
65
68
  end
66
69
  end
70
+
71
+ def self.not_provided?(value)
72
+ value.nil? || value.blank?
73
+ end
67
74
  end
68
75
  end
69
76
  end
@@ -30,6 +30,7 @@ module PactBroker
30
30
  def self.call(params)
31
31
  select_first_message(flatten_indexed_messages(SCHEMA.call(params&.symbolize_keys).messages(full: true)))
32
32
  end
33
+
33
34
  end
34
35
  end
35
36
  end
@@ -14,14 +14,14 @@ module PactBroker
14
14
 
15
15
  property :pending,
16
16
  if: ->(context) { context[:options][:user_options][:include_pending_status] }
17
- property :wip, if: -> (context) { context[:represented].wip }
18
-
19
- property :notices, getter: -> (context) { context[:decorator].notices(context[:options][:user_options]) }
20
- property :noteToDevelopers, getter: -> (_) { "Please print out the text from the 'notices' rather than using the inclusionReason and the pendingReason fields. These will be removed when this API moves out of beta."}
17
+ property :wip,
18
+ if: -> (context) { context[:represented].wip }
19
+ property :notices,
20
+ getter: -> (context) { context[:decorator].notices(context[:options][:user_options]) }
21
21
 
22
22
  def notices(user_options)
23
23
  pact_url = pact_version_url(represented, user_options[:base_url])
24
- PactBroker::Pacts::BuildVerifiablePactNotices.call(represented, pact_url, include_pending_status: user_options[:include_pending_status])
24
+ PactBroker::Pacts::BuildVerifiablePactNotices.call(represented, pact_url, user_options)
25
25
  end
26
26
  end
27
27
 
@@ -46,12 +46,7 @@ module PactBroker
46
46
  end
47
47
 
48
48
  def policy_name
49
- :'webhooks::webooks'
50
- end
51
-
52
- def policy_record
53
- # Note: consumer and provider not yet set on new webhook
54
- request.post? ? webhook : webhooks
49
+ :'webhooks::webhooks'
55
50
  end
56
51
 
57
52
  private
@@ -25,10 +25,6 @@ module PactBroker
25
25
  :'matrix::can_i_deploy'
26
26
  end
27
27
 
28
- def policy_record
29
- selectors
30
- end
31
-
32
28
  private
33
29
 
34
30
  attr_reader :query_params, :selectors, :options
@@ -202,6 +202,15 @@ module PactBroker
202
202
  @pact ||= pact_service.find_pact(pact_params)
203
203
  end
204
204
 
205
+ # Not necessarily an existing integration
206
+ def integration
207
+ if consumer_specified? && provider_specified?
208
+ OpenStruct.new(consumer: consumer, provider: provider)
209
+ else
210
+ nil
211
+ end
212
+ end
213
+
205
214
  def database_connector
206
215
  request.env["pactbroker.database_connector"]
207
216
  end
@@ -5,11 +5,8 @@ module PactBroker
5
5
  module Api
6
6
  module Resources
7
7
  class ErrorHandler
8
-
9
8
  include PactBroker::Logging
10
9
 
11
- WARNING_ERROR_CLASSES = [Sequel::ForeignKeyConstraintViolation]
12
-
13
10
  def self.call e, request, response
14
11
  error_reference = generate_error_reference
15
12
  if log_as_warning?(e)
@@ -17,6 +14,7 @@ module PactBroker
17
14
  elsif reportable?(e)
18
15
  log_error(e, "Error reference #{error_reference}")
19
16
  report(e, error_reference, request)
17
+ else
20
18
  logger.info("Error reference #{error_reference}", e)
21
19
  end
22
20
  response.body = response_body_hash(e, error_reference).to_json
@@ -31,7 +29,7 @@ module PactBroker
31
29
  end
32
30
 
33
31
  def self.log_as_warning?(e)
34
- WARNING_ERROR_CLASSES.any? { |clazz| e.is_a?(clazz) }
32
+ PactBroker.configuration.warning_error_classes.any? { |clazz| e.is_a?(clazz) }
35
33
  end
36
34
 
37
35
  def self.display_message(e, error_reference)
@@ -4,9 +4,7 @@ require 'pact_broker/error'
4
4
  module PactBroker
5
5
  module Api
6
6
  module Resources
7
-
8
7
  class ErrorTest < BaseResource
9
-
10
8
  def content_types_provided
11
9
  [
12
10
  ["application/hal+json", :to_json]
@@ -24,6 +22,10 @@ module PactBroker
24
22
  def process_post
25
23
  raise PactBroker::TestError.new("Don't panic. This is a test API error.")
26
24
  end
25
+
26
+ def policy_name
27
+ :'default'
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -26,10 +26,6 @@ module PactBroker
26
26
  :'groups::group'
27
27
  end
28
28
 
29
- def policy_record
30
- pacticipant
31
- end
32
-
33
29
  private
34
30
 
35
31
  def group
@@ -121,6 +121,17 @@ module PactBroker
121
121
  title: "Determine if an application can be safely deployed to an environment identified by the given tag",
122
122
  templated: true
123
123
  },
124
+ 'pb:provider-pacts-for-verification' => {
125
+ href: base_url + '/pacts/provider/{provider}/for-verification',
126
+ title: 'Pact versions to be verified for the specified provider',
127
+ templated: true
128
+ },
129
+ 'beta:provider-pacts-for-verification' => {
130
+ name: 'beta',
131
+ href: base_url + '/pacts/provider/{provider}/for-verification',
132
+ title: 'DEPRECATED - please use pb:provider-pacts-for-verification',
133
+ templated: true
134
+ },
124
135
  'curies' =>
125
136
  [{
126
137
  name: 'pb',
@@ -133,14 +144,6 @@ module PactBroker
133
144
  }]
134
145
  }
135
146
 
136
- if PactBroker.feature_enabled?(:pacts_for_verification)
137
- links_hash['beta:provider-pacts-for-verification'] = {
138
- href: base_url + '/pacts/provider/{provider}/for-verification',
139
- title: 'Pact versions to be verified for the specified provider',
140
- templated: true
141
- }
142
- end
143
-
144
147
  links_hash
145
148
  end
146
149
 
@@ -21,10 +21,6 @@ module PactBroker
21
21
  :'integrations::integration'
22
22
  end
23
23
 
24
- def policy_resource
25
- integration
26
- end
27
-
28
24
  def integration
29
25
  @integration ||= OpenStruct.new(consumer: consumer, provider: provider)
30
26
  end
@@ -37,10 +37,6 @@ module PactBroker
37
37
  def policy_name
38
38
  :'integrations::integrations'
39
39
  end
40
-
41
- def policy_resource
42
- integrations
43
- end
44
40
  end
45
41
  end
46
42
  end
@@ -30,18 +30,10 @@ module PactBroker
30
30
  !!label
31
31
  end
32
32
 
33
- def resource_object
34
- label
35
- end
36
-
37
33
  def policy_name
38
34
  :'labels::label'
39
35
  end
40
36
 
41
- def policy_record
42
- label
43
- end
44
-
45
37
  def to_json
46
38
  PactBroker::Api::Decorators::LabelDecorator.new(label).to_json(decorator_options)
47
39
  end
@@ -25,11 +25,7 @@ module PactBroker
25
25
  end
26
26
 
27
27
  def policy_name
28
- :'pacts:pact'
29
- end
30
-
31
- def policy_record
32
- pact
28
+ :'pacts::pact'
33
29
  end
34
30
 
35
31
  def to_json
@@ -22,11 +22,7 @@ module PactBroker
22
22
  end
23
23
 
24
24
  def policy_name
25
- :'pacts:pacts'
26
- end
27
-
28
- def policy_record
29
- pacts
25
+ :'pacts::pacts'
30
26
  end
31
27
  end
32
28
  end
@@ -30,10 +30,6 @@ module PactBroker
30
30
  :'verifications::verifications'
31
31
  end
32
32
 
33
- def policy_record
34
- version
35
- end
36
-
37
33
  private
38
34
 
39
35
  def version
@@ -43,6 +43,10 @@ module PactBroker
43
43
  PactBroker::Api::Decorators::MatrixTextDecorator.new(results).to_text(decorator_options)
44
44
  end
45
45
 
46
+ def policy_name
47
+ :'matrix::matrix'
48
+ end
49
+
46
50
  def results
47
51
  @results ||= matrix_service.find(selectors, options)
48
52
  end
@@ -27,6 +27,10 @@ module PactBroker
27
27
  PactBroker::Api::Decorators::MatrixDecorator.new(results).to_json(decorator_options)
28
28
  end
29
29
 
30
+ def policy_name
31
+ :'matrix::matrix'
32
+ end
33
+
30
34
  private
31
35
 
32
36
  attr_reader :options
@@ -15,6 +15,10 @@ module PactBroker
15
15
  def to_json
16
16
  metrics_service.metrics.to_json
17
17
  end
18
+
19
+ def policy_name
20
+ :'metrics::metrics'
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -53,14 +53,6 @@ module PactBroker
53
53
  !!pact
54
54
  end
55
55
 
56
- def resource_object
57
- pact
58
- end
59
-
60
- def policy_resource
61
- pact
62
- end
63
-
64
56
  def from_json
65
57
  response_code = pact ? 200 : 201
66
58
 
@@ -96,6 +88,10 @@ module PactBroker
96
88
  true
97
89
  end
98
90
 
91
+ def policy_name
92
+ :'pacts::pact'
93
+ end
94
+
99
95
  private
100
96
 
101
97
  def pact