pact_broker 2.99.0 → 2.102.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 +50 -0
- data/Gemfile +1 -0
- data/README.md +14 -4
- data/db/migrations/20220622_default_allow_dangerous_contract_modification_to_false_for_new_installations.rb +22 -0
- data/db/migrations/20220625_delete_pacticipants_with_no_name.rb +62 -0
- data/db/migrations/migration_helper.rb +6 -0
- data/docs/CONFIGURATION.md +3 -1
- data/docs/api/PACTICIPANTS.md +290 -0
- data/docs/api/WEBHOOKS.md +40 -40
- data/lib/pact_broker/api/contracts/pacticipant_create_schema.rb +28 -0
- data/lib/pact_broker/api/decorators/embedded_version_decorator.rb +0 -1
- data/lib/pact_broker/api/decorators/reason_decorator.rb +1 -15
- data/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb +1 -2
- data/lib/pact_broker/api/resources/all_webhooks.rb +1 -4
- data/lib/pact_broker/api/resources/base_resource.rb +58 -5
- data/lib/pact_broker/api/resources/branch_version.rb +10 -1
- data/lib/pact_broker/api/resources/clean.rb +11 -9
- data/lib/pact_broker/api/resources/currently_deployed_versions_for_environment.rb +0 -4
- data/lib/pact_broker/api/resources/currently_supported_versions_for_environment.rb +0 -4
- data/lib/pact_broker/api/resources/deployed_version.rb +20 -16
- data/lib/pact_broker/api/resources/deployed_versions_for_version_and_environment.rb +1 -1
- data/lib/pact_broker/api/resources/environment.rb +5 -5
- data/lib/pact_broker/api/resources/environments.rb +1 -5
- data/lib/pact_broker/api/resources/label.rb +4 -0
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +10 -0
- data/lib/pact_broker/api/resources/pact.rb +14 -5
- data/lib/pact_broker/api/resources/pact_webhooks.rb +1 -4
- data/lib/pact_broker/api/resources/pacticipant.rb +11 -5
- data/lib/pact_broker/api/resources/pacticipant_resource_methods.rb +0 -1
- data/lib/pact_broker/api/resources/pacticipant_webhooks.rb +1 -4
- data/lib/pact_broker/api/resources/pacticipants.rb +7 -6
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +19 -11
- data/lib/pact_broker/api/resources/publish_contracts.rb +12 -16
- data/lib/pact_broker/api/resources/released_version.rb +20 -8
- data/lib/pact_broker/api/resources/released_versions_for_version_and_environment.rb +11 -7
- data/lib/pact_broker/api/resources/tag.rb +7 -3
- data/lib/pact_broker/api/resources/verifications.rb +7 -9
- data/lib/pact_broker/api/resources/version.rb +8 -8
- data/lib/pact_broker/api/resources/webhook.rb +5 -4
- data/lib/pact_broker/api/resources/webhook_execution.rb +4 -6
- data/lib/pact_broker/config/runtime_configuration.rb +1 -1
- data/lib/pact_broker/contracts/contract_to_publish.rb +4 -0
- data/lib/pact_broker/contracts/contracts_to_publish.rb +4 -0
- data/lib/pact_broker/contracts/service.rb +23 -5
- data/lib/pact_broker/doc/views/index/pacticipant-branch-version.markdown +13 -2
- data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +1 -1
- data/lib/pact_broker/domain/pacticipant.rb +1 -0
- data/lib/pact_broker/domain/tag.rb +8 -32
- data/lib/pact_broker/domain/verification.rb +3 -2
- data/lib/pact_broker/domain/version.rb +26 -10
- data/lib/pact_broker/locale/en.yml +8 -4
- data/lib/pact_broker/matrix/deployment_status_summary.rb +28 -19
- data/lib/pact_broker/matrix/parse_query.rb +5 -0
- data/lib/pact_broker/matrix/quick_row.rb +5 -2
- data/lib/pact_broker/matrix/repository.rb +3 -3
- data/lib/pact_broker/matrix/resolved_selector.rb +47 -10
- data/lib/pact_broker/matrix/service.rb +17 -7
- data/lib/pact_broker/matrix/unresolved_selector.rb +14 -2
- data/lib/pact_broker/messages.rb +0 -15
- data/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb +3 -3
- data/lib/pact_broker/pacticipants/repository.rb +5 -4
- data/lib/pact_broker/pacticipants/service.rb +11 -1
- data/lib/pact_broker/pacts/generate_sha.rb +1 -0
- data/lib/pact_broker/pacts/pact_version.rb +1 -0
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +4 -2
- data/lib/pact_broker/repositories/helpers.rb +13 -0
- data/lib/pact_broker/string_refinements.rb +8 -0
- data/lib/pact_broker/test/http_test_data_builder.rb +15 -0
- data/lib/pact_broker/test/test_data_builder.rb +20 -0
- data/lib/pact_broker/ui/controllers/index.rb +3 -1
- data/lib/pact_broker/ui/views/index/show.haml +3 -4
- data/lib/pact_broker/ui/views/matrix/show.haml +5 -2
- data/lib/pact_broker/verifications/pact_version_provider_tag_successful_verification.rb +15 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/branch_service.rb +7 -0
- data/lib/pact_broker/versions/branch_version_repository.rb +17 -0
- data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +1 -1
- data/lib/rack/pact_broker/cascade.rb +87 -0
- data/lib/webmachine/describe_routes.rb +43 -9
- metadata +8 -5
- data/lib/db.rb +0 -79
- data/lib/pact_broker/api/resources/default_base_resource.rb +0 -0
@@ -27,11 +27,7 @@ module PactBroker
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def malformed_request?
|
30
|
-
|
31
|
-
invalid_json? || validation_errors_for_schema?(schema, params.merge(uuid: uuid))
|
32
|
-
else
|
33
|
-
false
|
34
|
-
end
|
30
|
+
super || (request.post? && validation_errors_for_schema?(schema, params.merge(uuid: uuid)))
|
35
31
|
end
|
36
32
|
|
37
33
|
def create_path
|
@@ -23,6 +23,16 @@ module PactBroker
|
|
23
23
|
consumer && provider
|
24
24
|
end
|
25
25
|
|
26
|
+
def malformed_request?
|
27
|
+
error_messages = matrix_service.validate_options(options)
|
28
|
+
if error_messages.any?
|
29
|
+
set_json_validation_error_messages error_messages
|
30
|
+
true
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
26
36
|
def to_json
|
27
37
|
decorator_class(:matrix_decorator).new(results).to_json(decorator_options)
|
28
38
|
end
|
@@ -36,18 +36,27 @@ module PactBroker
|
|
36
36
|
["GET", "PUT", "DELETE", "PATCH", "OPTIONS"]
|
37
37
|
end
|
38
38
|
|
39
|
+
def request_body_required?
|
40
|
+
request.put? || request.patch?
|
41
|
+
end
|
42
|
+
|
43
|
+
def put_can_create?
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def patch_can_create?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
39
51
|
def is_conflict?
|
40
52
|
merge_conflict = request.patch? && resource_exists? && Pacts::Merger.conflict?(pact.json_content, pact_params.json_content)
|
41
53
|
|
42
54
|
potential_duplicate_pacticipants?(pact_params.pacticipant_names) || merge_conflict || disallowed_modification?
|
43
55
|
end
|
44
56
|
|
57
|
+
|
45
58
|
def malformed_request?
|
46
|
-
|
47
|
-
invalid_json? || contract_validation_errors?(Contracts::PutPactParamsContract.new(pact_params), pact_params)
|
48
|
-
else
|
49
|
-
false
|
50
|
-
end
|
59
|
+
super || ((request.patch? || request.really_put?) && contract_validation_errors?(Contracts::PutPactParamsContract.new(pact_params), pact_params))
|
51
60
|
end
|
52
61
|
|
53
62
|
def resource_exists?
|
@@ -21,18 +21,23 @@ module PactBroker
|
|
21
21
|
["GET", "PUT", "PATCH", "DELETE", "OPTIONS"]
|
22
22
|
end
|
23
23
|
|
24
|
+
def put_can_create?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def patch_can_create?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
24
32
|
def known_methods
|
25
33
|
super + ["PATCH"]
|
26
34
|
end
|
27
35
|
|
28
36
|
def malformed_request?
|
29
|
-
|
30
|
-
invalid_json? || validation_errors_for_schema?
|
31
|
-
else
|
32
|
-
false
|
33
|
-
end
|
37
|
+
super || ((request.patch? || request.really_put?) && any_request_body? && validation_errors_for_schema?)
|
34
38
|
end
|
35
39
|
|
40
|
+
# PUT or PATCH with content-type application/json
|
36
41
|
def from_json
|
37
42
|
if pacticipant
|
38
43
|
@pacticipant = update_existing_pacticipant
|
@@ -47,6 +52,7 @@ module PactBroker
|
|
47
52
|
response.body = to_json
|
48
53
|
end
|
49
54
|
|
55
|
+
# PUT or PATCH with content-type application/merge-patch+json
|
50
56
|
def from_merge_patch_json
|
51
57
|
if request.patch?
|
52
58
|
from_json
|
@@ -2,7 +2,7 @@ require "pact_broker/api/resources/base_resource"
|
|
2
2
|
require "pact_broker/api/decorators/pacticipant_decorator"
|
3
3
|
require "pact_broker/domain/pacticipant"
|
4
4
|
require "pact_broker/hash_refinements"
|
5
|
-
require "pact_broker/api/contracts/
|
5
|
+
require "pact_broker/api/contracts/pacticipant_create_schema"
|
6
6
|
|
7
7
|
module PactBroker
|
8
8
|
module Api
|
@@ -23,10 +23,11 @@ module PactBroker
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def malformed_request?
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
super || (request.post? && validation_errors_for_schema?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def request_body_required?
|
30
|
+
request.post?
|
30
31
|
end
|
31
32
|
|
32
33
|
def post_is_create?
|
@@ -65,7 +66,7 @@ module PactBroker
|
|
65
66
|
private
|
66
67
|
|
67
68
|
def schema
|
68
|
-
PactBroker::Api::Contracts::
|
69
|
+
PactBroker::Api::Contracts::PacticipantCreateSchema
|
69
70
|
end
|
70
71
|
|
71
72
|
def pacticipants
|
@@ -11,28 +11,27 @@ module PactBroker
|
|
11
11
|
class ProviderPactsForVerification < ProviderPacts
|
12
12
|
using PactBroker::HashRefinements
|
13
13
|
|
14
|
+
def content_types_provided
|
15
|
+
[["application/hal+json", :to_json]]
|
16
|
+
end
|
17
|
+
|
14
18
|
def allowed_methods
|
15
19
|
["GET", "POST", "OPTIONS"]
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
|
22
|
+
def malformed_request?
|
23
|
+
super || ((request.get? || (request.post? && content_type_json?)) && schema_validation_errors?)
|
20
24
|
end
|
21
25
|
|
22
|
-
def
|
23
|
-
if
|
24
|
-
|
26
|
+
def process_post
|
27
|
+
if content_type_json?
|
28
|
+
response.body = to_json
|
25
29
|
true
|
26
30
|
else
|
27
|
-
|
31
|
+
415
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
|
-
def process_post
|
32
|
-
response.body = to_json
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
35
|
def read_methods
|
37
36
|
super + %w{POST}
|
38
37
|
end
|
@@ -96,6 +95,15 @@ module PactBroker
|
|
96
95
|
def nested_query
|
97
96
|
@nested_query ||= Rack::Utils.parse_nested_query(request.uri.query)
|
98
97
|
end
|
98
|
+
|
99
|
+
def schema_validation_errors?
|
100
|
+
if (errors = query_schema.call(query)).any?
|
101
|
+
set_json_validation_error_messages(errors)
|
102
|
+
true
|
103
|
+
else
|
104
|
+
false
|
105
|
+
end
|
106
|
+
end
|
99
107
|
end
|
100
108
|
end
|
101
109
|
end
|
@@ -11,11 +11,7 @@ module PactBroker
|
|
11
11
|
include WebhookExecutionMethods
|
12
12
|
|
13
13
|
def content_types_provided
|
14
|
-
[["application/hal+json"
|
15
|
-
end
|
16
|
-
|
17
|
-
def content_types_accepted
|
18
|
-
[["application/json"]]
|
14
|
+
[["application/hal+json"]]
|
19
15
|
end
|
20
16
|
|
21
17
|
def allowed_methods
|
@@ -23,20 +19,20 @@ module PactBroker
|
|
23
19
|
end
|
24
20
|
|
25
21
|
def malformed_request?
|
26
|
-
|
27
|
-
invalid_json? || validation_errors_for_schema?
|
28
|
-
else
|
29
|
-
false
|
30
|
-
end
|
22
|
+
super || (request.post? && content_type_json? && validation_errors_for_schema?)
|
31
23
|
end
|
32
24
|
|
33
25
|
def process_post
|
34
|
-
if
|
35
|
-
|
36
|
-
|
26
|
+
if content_type_json?
|
27
|
+
if conflict_notices.any?
|
28
|
+
set_conflict_response
|
29
|
+
409
|
30
|
+
else
|
31
|
+
publish_contracts
|
32
|
+
true
|
33
|
+
end
|
37
34
|
else
|
38
|
-
|
39
|
-
true
|
35
|
+
415
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
@@ -100,7 +96,7 @@ module PactBroker
|
|
100
96
|
end
|
101
97
|
|
102
98
|
def conflict_notices
|
103
|
-
@conflict_notices ||= contract_service.conflict_notices(parsed_contracts)
|
99
|
+
@conflict_notices ||= contract_service.conflict_notices(parsed_contracts, base_url: base_url)
|
104
100
|
end
|
105
101
|
|
106
102
|
def base64_decode(content)
|
@@ -8,11 +8,6 @@ module PactBroker
|
|
8
8
|
class ReleasedVersion < BaseResource
|
9
9
|
include PactBroker::Messages
|
10
10
|
|
11
|
-
def initialize
|
12
|
-
super
|
13
|
-
@currently_supported_param = params(default: {})[:currentlySupported]
|
14
|
-
end
|
15
|
-
|
16
11
|
def content_types_provided
|
17
12
|
[["application/hal+json", :to_json]]
|
18
13
|
end
|
@@ -27,6 +22,10 @@ module PactBroker
|
|
27
22
|
["GET", "PATCH", "OPTIONS"]
|
28
23
|
end
|
29
24
|
|
25
|
+
def patch_can_create?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
30
29
|
def resource_exists?
|
31
30
|
!!released_version
|
32
31
|
end
|
@@ -48,16 +47,29 @@ module PactBroker
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def policy_name
|
51
|
-
:'versions::
|
50
|
+
:'versions::released_version'
|
51
|
+
end
|
52
|
+
|
53
|
+
def policy_record_context
|
54
|
+
{
|
55
|
+
pacticipant: released_version&.pacticipant
|
56
|
+
}
|
52
57
|
end
|
53
58
|
|
54
59
|
def policy_record
|
55
|
-
released_version&.
|
60
|
+
released_version&.environment
|
56
61
|
end
|
57
62
|
|
58
63
|
private
|
59
64
|
|
60
|
-
|
65
|
+
# can't use ||= with a potentially nil value
|
66
|
+
def currently_supported_param
|
67
|
+
if defined?(@currently_deployed_param)
|
68
|
+
@currently_supported_param
|
69
|
+
else
|
70
|
+
@currently_supported_param = params(default: {})[:currentlySupported]
|
71
|
+
end
|
72
|
+
end
|
61
73
|
|
62
74
|
def process_currently_supported_param
|
63
75
|
if currently_supported_param == false
|
@@ -5,11 +5,6 @@ module PactBroker
|
|
5
5
|
module Api
|
6
6
|
module Resources
|
7
7
|
class ReleasedVersionsForVersionAndEnvironment < BaseResource
|
8
|
-
def initialize
|
9
|
-
super
|
10
|
-
@existing_released_version = version && environment && released_version_service.find_released_version_for_version_and_environment(version, environment)
|
11
|
-
end
|
12
|
-
|
13
8
|
def content_types_accepted
|
14
9
|
[["application/json", :from_json]]
|
15
10
|
end
|
@@ -35,6 +30,7 @@ module PactBroker
|
|
35
30
|
end
|
36
31
|
|
37
32
|
def from_json
|
33
|
+
existing_released_version # make sure we have this before we update the database
|
38
34
|
@released_version = released_version_service.create_or_update(next_released_version_uuid, version, environment)
|
39
35
|
response.body = decorator_class(:released_version_decorator).new(released_version).to_json(decorator_options)
|
40
36
|
true
|
@@ -45,7 +41,7 @@ module PactBroker
|
|
45
41
|
end
|
46
42
|
|
47
43
|
def policy_name
|
48
|
-
:'versions::
|
44
|
+
:'versions::released_versions'
|
49
45
|
end
|
50
46
|
|
51
47
|
def policy_record
|
@@ -61,7 +57,15 @@ module PactBroker
|
|
61
57
|
|
62
58
|
private
|
63
59
|
|
64
|
-
attr_reader :released_version
|
60
|
+
attr_reader :released_version
|
61
|
+
|
62
|
+
def existing_released_version
|
63
|
+
if defined?(@existing_released_version)
|
64
|
+
@existing_released_version
|
65
|
+
else
|
66
|
+
@existing_released_version = version && environment && released_version_service.find_released_version_for_version_and_environment(version, environment)
|
67
|
+
end
|
68
|
+
end
|
65
69
|
|
66
70
|
def version
|
67
71
|
@version ||= version_service.find_by_pacticipant_name_and_number(identifier_from_path)
|
@@ -17,9 +17,13 @@ module PactBroker
|
|
17
17
|
["GET","PUT","DELETE", "OPTIONS"]
|
18
18
|
end
|
19
19
|
|
20
|
+
def put_can_create?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
20
24
|
def from_json
|
21
25
|
unless tag
|
22
|
-
@tag = tag_service.create
|
26
|
+
@tag = tag_service.create(identifier_from_path)
|
23
27
|
# Make it return a 201 by setting the Location header
|
24
28
|
response.headers["Location"] = tag_url(base_url, tag)
|
25
29
|
end
|
@@ -36,11 +40,11 @@ module PactBroker
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def tag
|
39
|
-
@tag ||= tag_service.find
|
43
|
+
@tag ||= tag_service.find(identifier_from_path)
|
40
44
|
end
|
41
45
|
|
42
46
|
def delete_resource
|
43
|
-
tag_service.delete
|
47
|
+
tag_service.delete(identifier_from_path)
|
44
48
|
true
|
45
49
|
end
|
46
50
|
|
@@ -34,15 +34,7 @@ module PactBroker
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def malformed_request?
|
37
|
-
|
38
|
-
return true if invalid_json?
|
39
|
-
errors = verification_service.errors(params)
|
40
|
-
if !errors.empty?
|
41
|
-
set_json_validation_error_messages(errors.messages)
|
42
|
-
return true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
false
|
37
|
+
super || (request.post? && any_validation_errors?)
|
46
38
|
end
|
47
39
|
|
48
40
|
def create_path
|
@@ -91,6 +83,12 @@ module PactBroker
|
|
91
83
|
def verification_params
|
92
84
|
params(symbolize_names: false).merge("wip" => wip?, "pending" => pending?)
|
93
85
|
end
|
86
|
+
|
87
|
+
def any_validation_errors?
|
88
|
+
errors = verification_service.errors(params)
|
89
|
+
set_json_validation_error_messages(errors.messages) if !errors.empty?
|
90
|
+
!errors.empty?
|
91
|
+
end
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
@@ -21,16 +21,16 @@ module PactBroker
|
|
21
21
|
["GET", "PUT", "PATCH", "DELETE", "OPTIONS"]
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def put_can_create?
|
25
|
+
true
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
def patch_can_create?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def resource_exists?
|
33
|
+
!!version
|
34
34
|
end
|
35
35
|
|
36
36
|
def from_json
|
@@ -22,15 +22,16 @@ module PactBroker
|
|
22
22
|
["GET", "PUT", "DELETE", "OPTIONS"]
|
23
23
|
end
|
24
24
|
|
25
|
+
def put_can_create?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
25
29
|
def resource_exists?
|
26
30
|
!!webhook
|
27
31
|
end
|
28
32
|
|
29
33
|
def malformed_request?
|
30
|
-
|
31
|
-
return invalid_json? || webhook_validation_errors?(parsed_webhook, uuid)
|
32
|
-
end
|
33
|
-
false
|
34
|
+
super || (request.put? && webhook_validation_errors?(parsed_webhook, uuid))
|
34
35
|
end
|
35
36
|
|
36
37
|
def from_json
|
@@ -13,10 +13,6 @@ module PactBroker
|
|
13
13
|
include WebhookResourceMethods
|
14
14
|
include WebhookExecutionMethods
|
15
15
|
|
16
|
-
def content_types_accepted
|
17
|
-
[["application/json"]]
|
18
|
-
end
|
19
|
-
|
20
16
|
def content_types_provided
|
21
17
|
[["application/hal+json"]]
|
22
18
|
end
|
@@ -37,14 +33,16 @@ module PactBroker
|
|
37
33
|
end
|
38
34
|
|
39
35
|
def malformed_request?
|
40
|
-
if
|
36
|
+
if super
|
37
|
+
true
|
38
|
+
elsif request.post?
|
41
39
|
if uuid
|
42
40
|
false
|
43
41
|
else
|
44
42
|
webhook_validation_errors?(webhook)
|
45
43
|
end
|
46
44
|
else
|
47
|
-
|
45
|
+
false
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -85,7 +85,7 @@ module PactBroker
|
|
85
85
|
use_first_tag_as_branch_time_limit: 10,
|
86
86
|
auto_detect_main_branch: true,
|
87
87
|
main_branch_candidates: ["develop", "main", "master"],
|
88
|
-
allow_dangerous_contract_modification:
|
88
|
+
allow_dangerous_contract_modification: false,
|
89
89
|
semver_formats: ["%M.%m.%p%s%d", "%M.%m", "%M"],
|
90
90
|
seed_example_data: true,
|
91
91
|
features: []
|
@@ -43,19 +43,26 @@ module PactBroker
|
|
43
43
|
)
|
44
44
|
end
|
45
45
|
|
46
|
-
def conflict_notices(parsed_contracts)
|
46
|
+
def conflict_notices(parsed_contracts, base_url: )
|
47
47
|
notices = []
|
48
|
+
add_pact_conflict_notices(notices, parsed_contracts)
|
49
|
+
add_pacticipant_conflict_notices(notices, parsed_contracts, base_url)
|
50
|
+
notices
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_pact_conflict_notices(notices, parsed_contracts)
|
48
54
|
parsed_contracts.contracts.collect do | contract_to_publish |
|
49
55
|
pact_params = create_pact_params(parsed_contracts, contract_to_publish)
|
50
56
|
existing_pact = pact_service.find_pact(pact_params)
|
51
57
|
if existing_pact && pact_service.disallowed_modification?(existing_pact, contract_to_publish.decoded_content)
|
52
|
-
|
58
|
+
add_pact_conflict_notice(notices, parsed_contracts, contract_to_publish, existing_pact.json_content, contract_to_publish.decoded_content)
|
53
59
|
end
|
54
60
|
end
|
55
|
-
notices
|
56
61
|
end
|
57
62
|
|
58
|
-
|
63
|
+
private :add_pact_conflict_notices
|
64
|
+
|
65
|
+
def add_pact_conflict_notice(notices, parsed_contracts, contract_to_publish, existing_json_content, new_json_content)
|
59
66
|
message_params = {
|
60
67
|
consumer_name: contract_to_publish.provider_name,
|
61
68
|
consumer_version_number: parsed_contracts.pacticipant_version_number,
|
@@ -65,7 +72,18 @@ module PactBroker
|
|
65
72
|
notices << Notice.info(PactBroker::Pacts::CreateFormattedDiff.call(new_json_content, existing_json_content))
|
66
73
|
end
|
67
74
|
|
68
|
-
private :
|
75
|
+
private :add_pact_conflict_notice
|
76
|
+
|
77
|
+
def add_pacticipant_conflict_notices(notices, parsed_contracts, base_url)
|
78
|
+
if PactBroker.configuration.check_for_potential_duplicate_pacticipant_names
|
79
|
+
duplicate_pacticipant_messages = pacticipant_service.messages_for_potential_duplicate_pacticipants(parsed_contracts.pacticipant_names, base_url)
|
80
|
+
duplicate_pacticipant_messages.each do | message_text |
|
81
|
+
notices << Notice.error(message_text)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
private :add_pacticipant_conflict_notices
|
69
87
|
|
70
88
|
def create_version(parsed_contracts)
|
71
89
|
version_params = {
|
@@ -1,14 +1,25 @@
|
|
1
1
|
# Pacticipant branch version
|
2
2
|
|
3
|
-
Allowed methods: `GET`, `PUT`
|
3
|
+
Allowed methods: `GET`, `PUT`, `DELETE`
|
4
4
|
|
5
5
|
Path: `/pacticipants/{pacticipant}/branches/{branch}/versions/{version}`
|
6
6
|
|
7
7
|
Get or add/create a pacticipant version for a branch.
|
8
8
|
|
9
|
-
##
|
9
|
+
## Create
|
10
|
+
|
11
|
+
### Example
|
10
12
|
|
11
13
|
Add a version to a branch. The pacticipant and branch are automatically created if they do not exist.
|
12
14
|
|
13
15
|
curl -XPUT http://broker/pacticipants/Bar/branches/main/versions/1e70030c6579915e5ff56b107a0fd25cf5df7464 \
|
14
16
|
-H "Content-Type: application/json" -d "{}"
|
17
|
+
|
18
|
+
|
19
|
+
## Delete
|
20
|
+
|
21
|
+
Removes a pacticipant version from a branch. Does not delete the actual pacticipant version.
|
22
|
+
|
23
|
+
Send a `DELETE` request to the branch version resource.
|
24
|
+
|
25
|
+
curl -XDELETE http://broker/pacticipants/Bar/branches/main/versions/1e70030c6579915e5ff56b107a0fd25cf5df7464
|
@@ -48,7 +48,7 @@ Example: This data structure represents the way a user might specify "I want to
|
|
48
48
|
|
49
49
|
`consumerVersionSelectors.tag`: the tag name(s) of the consumer versions to get the pacts for. *This field is still supported but it is recommended to use the `branch` in preference now.*
|
50
50
|
|
51
|
-
`consumerVersionSelectors.fallbackTag`: the name of the tag to fallback to if the specified `tag` does not exist. This is useful when the consumer and provider use matching branch names to coordinate the development of new features. *This field is still supported but it is recommended to use the
|
51
|
+
`consumerVersionSelectors.fallbackTag`: the name of the tag to fallback to if the specified `tag` does not exist. This is useful when the consumer and provider use matching branch names to coordinate the development of new features. *This field is still supported but it is recommended to use two separate selectors - one with the main branch name and one with the feature branch name.*
|
52
52
|
|
53
53
|
`providerVersionBranch`: the repository branch name for the provider application version that will be published with the verification results. This is used by the Broker to determine whether or not a particular pact is in pending state or not.
|
54
54
|
|