pact_broker 2.59.1 → 2.62.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -0
- data/README.md +1 -1
- data/db/migrations/20200922_add_event_to_triggered_webhook.rb +5 -0
- data/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb +10 -3
- data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +1 -0
- data/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb +1 -0
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +5 -5
- data/lib/pact_broker/api/pact_broker_urls.rb +9 -2
- data/lib/pact_broker/api/resources/all_webhooks.rb +1 -6
- data/lib/pact_broker/api/resources/can_i_deploy.rb +0 -4
- data/lib/pact_broker/api/resources/default_base_resource.rb +9 -0
- data/lib/pact_broker/api/resources/error_handler.rb +2 -4
- data/lib/pact_broker/api/resources/error_test.rb +4 -2
- data/lib/pact_broker/api/resources/group.rb +0 -4
- data/lib/pact_broker/api/resources/index.rb +11 -8
- data/lib/pact_broker/api/resources/integration.rb +0 -4
- data/lib/pact_broker/api/resources/integrations.rb +0 -4
- data/lib/pact_broker/api/resources/label.rb +0 -8
- data/lib/pact_broker/api/resources/latest_pact.rb +1 -5
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -5
- data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +0 -4
- data/lib/pact_broker/api/resources/matrix.rb +4 -0
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +4 -0
- data/lib/pact_broker/api/resources/metrics.rb +4 -0
- data/lib/pact_broker/api/resources/pact.rb +4 -8
- data/lib/pact_broker/api/resources/pact_content_diff.rb +4 -0
- data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +5 -1
- data/lib/pact_broker/api/resources/pact_versions.rb +5 -1
- data/lib/pact_broker/api/resources/pact_webhooks.rb +5 -1
- data/lib/pact_broker/api/resources/pact_webhooks_status.rb +5 -1
- data/lib/pact_broker/api/resources/pacticipant.rb +5 -9
- data/lib/pact_broker/api/resources/pacticipants.rb +0 -4
- data/lib/pact_broker/api/resources/pacticipants_for_label.rb +4 -0
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +4 -9
- data/lib/pact_broker/api/resources/provider_pacts.rb +1 -5
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +8 -6
- data/lib/pact_broker/api/resources/relationships.rb +4 -2
- data/lib/pact_broker/api/resources/tag.rb +5 -5
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +5 -2
- data/lib/pact_broker/api/resources/triggered_webhook_logs.rb +7 -5
- data/lib/pact_broker/api/resources/verification.rb +5 -5
- data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +6 -12
- data/lib/pact_broker/api/resources/verifications.rb +5 -5
- data/lib/pact_broker/api/resources/version.rb +5 -5
- data/lib/pact_broker/api/resources/versions.rb +5 -2
- data/lib/pact_broker/api/resources/webhook.rb +4 -0
- data/lib/pact_broker/api/resources/webhook_execution.rb +4 -0
- data/lib/pact_broker/api/resources/webhooks.rb +5 -1
- data/lib/pact_broker/app.rb +1 -1
- data/lib/pact_broker/badges/service.rb +1 -1
- data/lib/pact_broker/certificates/service.rb +2 -2
- data/lib/pact_broker/configuration.rb +21 -1
- data/lib/pact_broker/db.rb +14 -0
- data/lib/pact_broker/db/table_dependency_calculator.rb +45 -0
- data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +78 -0
- data/lib/pact_broker/domain/pact.rb +9 -0
- data/lib/pact_broker/domain/webhook_request.rb +3 -1
- data/lib/pact_broker/matrix/deployment_status_summary.rb +1 -1
- data/lib/pact_broker/pacts/build_verifiable_pact_notices.rb +7 -4
- data/lib/pact_broker/pacts/content.rb +30 -5
- data/lib/pact_broker/pacts/repository.rb +25 -31
- data/lib/pact_broker/pacts/selector.rb +8 -0
- data/lib/pact_broker/test/test_data_builder.rb +1 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/job.rb +8 -2
- data/lib/pact_broker/webhooks/repository.rb +3 -2
- data/lib/pact_broker/webhooks/service.rb +2 -2
- data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -3
- data/lib/pact_broker/webhooks/webhook_event.rb +1 -2
- data/script/seed.rb +39 -17
- data/spec/features/get_provider_pacts_for_verification_spec.rb +8 -0
- data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_spec.rb +23 -4
- data/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb +2 -1
- data/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb +3 -1
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +15 -0
- data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +10 -5
- data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +18 -1
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/verification_triggered_webhooks_spec.rb +0 -1
- data/spec/lib/pact_broker/badges/service_spec.rb +1 -1
- data/spec/lib/pact_broker/certificates/service_spec.rb +3 -3
- data/spec/lib/pact_broker/pacts/content_spec.rb +90 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +14 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +62 -0
- data/spec/lib/pact_broker/webhooks/job_spec.rb +19 -1
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +3 -2
- data/spec/lib/pact_broker/webhooks/service_spec.rb +2 -2
- data/spec/support/database_cleaner.rb +1 -5
- data/tasks/database.rb +1 -0
- data/tasks/database/table_dependency_calculator.rb +4 -41
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d90410ba82c9f6ee8681073d1a9435660abf73045fa4ea08658294512771106
|
4
|
+
data.tar.gz: ff2c697fa385d574c26225ebf3aa6bb93276a749bfc6851685dc17728aa18fb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c87ab86bd54c472362e678a8fd6307637ad34059beb390baf59fa33456014ed47bd725940fe792ffd7151c80201baf9c063d670b7ed4c857708c22e60e352a
|
7
|
+
data.tar.gz: 3c101564948c497f80d286eccfd70cc92734c5a94b280825bd437c3a6ab4141caf7e98fefb6594b230d0021bba732c44704e9338df081c630d752f0bbb3140cc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,56 @@
|
|
1
|
+
<a name="v2.62.0"></a>
|
2
|
+
### v2.62.0 (2020-09-23)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* **webhooks**
|
7
|
+
* remove user-agent and accept-encoding headers which the Ruby HTTP library adds by default ([ef25b88c](/../../commit/ef25b88c))
|
8
|
+
|
9
|
+
* add event name to triggered webhook ([ecce16fd](/../../commit/ecce16fd))
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* **webhooks**
|
14
|
+
* use path to initialise http request, rather than full URL ([ecbac9a6](/../../commit/ecbac9a6))
|
15
|
+
|
16
|
+
* gracefully handle corrupt webhook metadata in pact URL ([ba94c355](/../../commit/ba94c355))
|
17
|
+
|
18
|
+
<a name="v2.61.0"></a>
|
19
|
+
### v2.61.0 (2020-09-12)
|
20
|
+
|
21
|
+
#### Features
|
22
|
+
|
23
|
+
* add back support for GET requests to the 'pacts for verification' API with a deprecation notice in the response ([8f45cc9f](/../../commit/8f45cc9f))
|
24
|
+
|
25
|
+
<a name="v2.60.1"></a>
|
26
|
+
### v2.60.1 (2020-09-10)
|
27
|
+
|
28
|
+
#### Bug Fixes
|
29
|
+
|
30
|
+
* href for beta:provider-pacts-for-verification ([3949fdd1](/../../commit/3949fdd1))
|
31
|
+
|
32
|
+
<a name="v2.60.0"></a>
|
33
|
+
### v2.60.0 (2020-09-08)
|
34
|
+
|
35
|
+
#### Features
|
36
|
+
|
37
|
+
* **pacts for verification**
|
38
|
+
* add deprecation title to beta:provider-pacts-for-verification relation ([47a61f69](/../../commit/47a61f69))
|
39
|
+
* do not require environment variable feature toggle to enable feature ([7d0fe1ea](/../../commit/7d0fe1ea))
|
40
|
+
* allow consumer to be specified with fallback tags, and overall latest to be specified with or without a consumer ([2d52d173](/../../commit/2d52d173))
|
41
|
+
|
42
|
+
#### Bug Fixes
|
43
|
+
|
44
|
+
* correctly handle new test results format when merging test results with pact contents ([b35ab71b](/../../commit/b35ab71b))
|
45
|
+
|
46
|
+
<a name="v2.59.2"></a>
|
47
|
+
### v2.59.2 (2020-08-06)
|
48
|
+
|
49
|
+
#### Bug Fixes
|
50
|
+
|
51
|
+
* gracefully handle contracts without interactions or messages in deployment status warnings ([6c223e69](/../../commit/6c223e69))
|
52
|
+
* add missing info level log for business level errors ([80a895bf](/../../commit/80a895bf))
|
53
|
+
|
1
54
|
<a name="v2.59.1"></a>
|
2
55
|
### v2.59.1 (2020-08-04)
|
3
56
|
|
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
|
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
|
-
|
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
|
-
|
58
|
-
|
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
|
@@ -9,6 +9,7 @@ module PactBroker
|
|
9
9
|
property :number_of_attempts_made, as: :attemptsMade
|
10
10
|
property :number_of_attempts_remaining, as: :attemptsRemaining
|
11
11
|
property :trigger_type, as: :triggerType
|
12
|
+
property :event_name, as: :eventName
|
12
13
|
|
13
14
|
property :created_at, as: :triggeredAt
|
14
15
|
|
@@ -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,
|
18
|
-
|
19
|
-
property :notices,
|
20
|
-
|
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,
|
24
|
+
PactBroker::Pacts::BuildVerifiablePactNotices.call(represented, pact_url, user_options)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'pact_broker/pacts/metadata'
|
3
|
+
require 'pact_broker/logging'
|
3
4
|
|
4
5
|
module PactBroker
|
5
6
|
module Api
|
6
7
|
module PactBrokerUrls
|
7
8
|
|
8
9
|
include PactBroker::Pacts::Metadata
|
10
|
+
include PactBroker::Logging
|
9
11
|
# TODO make base_url the last and optional argument for all methods, defaulting to ''
|
10
12
|
|
11
13
|
extend self
|
@@ -70,8 +72,13 @@ module PactBroker
|
|
70
72
|
|
71
73
|
def decode_webhook_metadata(metadata)
|
72
74
|
if metadata
|
73
|
-
|
74
|
-
|
75
|
+
begin
|
76
|
+
Rack::Utils.parse_nested_query(Base64.strict_decode64(metadata)).each_with_object({}) do | (k, v), new_hash |
|
77
|
+
new_hash[k.to_sym] = v
|
78
|
+
end
|
79
|
+
rescue StandardError => e
|
80
|
+
logger.warn("Exception parsing webhook metadata: #{metadata}", e)
|
81
|
+
{}
|
75
82
|
end
|
76
83
|
else
|
77
84
|
{}
|
@@ -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
|
-
|
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
|
@@ -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
|
|
@@ -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
|