pact_broker 1.18.0 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -9
- data/DEVELOPER_DOCUMENTATION.md +53 -0
- data/README.md +13 -13
- data/db/migrations/23_create_pact_contents_table.rb +19 -0
- data/db/migrations/24_populate_pact_contents.rb +9 -0
- data/db/migrations/25_populate_pact_contents_pacticipants.rb +7 -0
- data/db/migrations/26_make_pc_pacticipants_mandatory.rb +8 -0
- data/db/migrations/27_create_pact_publications.rb +18 -0
- data/db/migrations/28_populate_pact_publications.rb +13 -0
- data/db/migrations/29_recreate_all_pacts.rb +16 -0
- data/db/migrations/30_drop_pacts.rb +8 -0
- data/db/migrations/31_drop_pact_version_contents.rb +5 -0
- data/db/migrations/32_rename_pact_contents.rb +5 -0
- data/db/migrations/33_recreate_all_pacts.rb +52 -0
- data/db/migrations/34_recreate_latest_tagged_pacts.rb +23 -0
- data/db/migrations/35_create_verifications.rb +15 -0
- data/db/migrations/36_create_latest_verifications.rb +14 -0
- data/db/pact_broker_database.sqlite3 +0 -0
- data/lib/pact_broker/api.rb +25 -10
- data/lib/pact_broker/api/contracts/verification_contract.rb +41 -0
- data/lib/pact_broker/api/decorators/pact_decorator.rb +7 -0
- data/lib/pact_broker/api/decorators/pact_version_decorator.rb +0 -1
- data/lib/pact_broker/api/decorators/representable_pact.rb +4 -3
- data/lib/pact_broker/api/decorators/timestamps.rb +1 -1
- data/lib/pact_broker/api/decorators/verification_decorator.rb +30 -0
- data/lib/pact_broker/api/decorators/verifications_decorator.rb +21 -0
- data/lib/pact_broker/api/decorators/version_decorator.rb +14 -0
- data/lib/pact_broker/api/decorators/versions_decorator.rb +1 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +41 -2
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +1 -1
- data/lib/pact_broker/api/resources/base_resource.rb +11 -2
- data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +39 -0
- data/lib/pact_broker/api/resources/pacticipants.rb +1 -1
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
- data/lib/pact_broker/api/resources/verifications.rb +67 -0
- data/lib/pact_broker/api/resources/versions.rb +1 -1
- data/lib/pact_broker/api/resources/webhooks.rb +1 -1
- data/lib/pact_broker/app.rb +0 -2
- data/lib/pact_broker/configuration.rb +1 -4
- data/lib/pact_broker/doc/views/latest-verifications.markdown +7 -0
- data/lib/pact_broker/doc/views/publish-verification.markdown +14 -0
- data/lib/pact_broker/domain.rb +1 -1
- data/lib/pact_broker/domain/order_versions.rb +5 -15
- data/lib/pact_broker/domain/pact.rb +10 -2
- data/lib/pact_broker/domain/relationship.rb +31 -4
- data/lib/pact_broker/domain/verification.rb +77 -0
- data/lib/pact_broker/domain/version.rb +6 -1
- data/lib/pact_broker/domain/webhook.rb +1 -0
- data/lib/pact_broker/domain/webhook_request.rb +4 -6
- data/lib/pact_broker/locale/en.yml +2 -1
- data/lib/pact_broker/logging.rb +0 -4
- data/lib/pact_broker/pacticipants/repository.rb +1 -2
- data/lib/pact_broker/pacticipants/service.rb +11 -5
- data/lib/pact_broker/pacts/all_pact_publications.rb +96 -0
- data/lib/pact_broker/pacts/all_pacts.rb +4 -89
- data/lib/pact_broker/pacts/diff.rb +2 -2
- data/lib/pact_broker/pacts/latest_pact_publications.rb +11 -0
- data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +11 -0
- data/lib/pact_broker/pacts/latest_pacts.rb +1 -0
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +11 -0
- data/lib/pact_broker/pacts/pact_params.rb +11 -1
- data/lib/pact_broker/pacts/pact_publication.rb +50 -0
- data/lib/pact_broker/pacts/pact_version.rb +39 -0
- data/lib/pact_broker/pacts/repository.rb +46 -36
- data/lib/pact_broker/pacts/service.rb +2 -2
- data/lib/pact_broker/repositories.rb +5 -0
- data/lib/pact_broker/services.rb +5 -0
- data/lib/pact_broker/ui/view_models/relationship.rb +38 -0
- data/lib/pact_broker/ui/views/relationships/show.haml +9 -0
- data/lib/pact_broker/verifications/repository.rb +45 -0
- data/lib/pact_broker/verifications/service.rb +40 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/parse_semantic_version.rb +9 -6
- data/lib/pact_broker/webhooks/service.rb +8 -9
- data/lib/pact_broker/webhooks/webhook.rb +1 -1
- data/pact_broker.gemspec +3 -4
- data/pact_broker_client-pact_broker.json +4 -4
- data/script/publish.sh +2 -2
- data/script/record_verification.sh +3 -0
- data/spec/features/delete_pact_spec.rb +1 -1
- data/spec/features/get_verifications_for_consumer_version_spec.rb +33 -0
- data/spec/features/publish_verification_spec.rb +28 -0
- data/spec/fixtures/a_consumer-a_provider-2.json +1 -1
- data/spec/fixtures/a_consumer-a_provider-3.json +1 -1
- data/spec/fixtures/a_consumer-a_provider-conflict.json +1 -1
- data/spec/fixtures/a_consumer-a_provider-merged.json +2 -2
- data/spec/fixtures/a_consumer-a_provider.json +1 -1
- data/spec/fixtures/consumer-provider.json +1 -1
- data/spec/fixtures/renderer_pact.json +1 -1
- data/spec/fixtures/verification.json +4 -0
- data/spec/lib/pact_broker/api/contracts/verification_contract_spec.rb +91 -0
- data/spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb +0 -18
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +6 -2
- data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +0 -3
- data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +61 -0
- data/spec/lib/pact_broker/api/decorators/verifications_decorator_spec.rb +42 -0
- data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +4 -0
- data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/latest_verifications_for_consumer_version_spec.rb +68 -0
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/pacticipants_spec.rb +1 -1
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +92 -0
- data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +1 -1
- data/spec/lib/pact_broker/domain/order_versions_spec.rb +10 -30
- data/spec/lib/pact_broker/domain/verification_spec.rb +41 -0
- data/spec/lib/pact_broker/domain/version_spec.rb +26 -0
- data/spec/lib/pact_broker/domain/webhook_request_spec.rb +1 -3
- data/spec/lib/pact_broker/pacticipants/repository_spec.rb +0 -16
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +4 -3
- data/spec/lib/pact_broker/pacts/pact_params_spec.rb +14 -1
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +50 -0
- data/spec/lib/pact_broker/pacts/repository_spec.rb +85 -36
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +48 -2
- data/spec/lib/pact_broker/verifications/repository_spec.rb +92 -0
- data/spec/lib/pact_broker/verifications/service_spec.rb +61 -0
- data/spec/lib/pact_broker/versions/parse_semantic_version_spec.rb +39 -0
- data/spec/lib/pact_broker/webhooks/service_spec.rb +3 -40
- data/spec/migrations/23_pact_versions_spec.rb +95 -0
- data/spec/migrations/24_populate_pact_contents_spec.rb +48 -0
- data/spec/migrations/34_latest_tagged_pacts_spec.rb +108 -0
- data/spec/migrations/34_pact_revisions_spec.rb +106 -0
- data/spec/support/database_cleaner.rb +8 -4
- data/spec/support/provider_state_builder.rb +22 -8
- metadata +81 -36
- data/lib/pact_broker/pacts/database_model.rb +0 -35
- data/lib/pact_broker/pacts/latest_tagged_pacts.rb +0 -11
- data/lib/pact_broker/pacts/pact_version_content.rb +0 -11
- data/lib/pact_broker/webhooks/job.rb +0 -46
- data/script/foo-bar.json +0 -22
- data/script/publish-new.sh +0 -7
- data/script/recreate-pg-db.sh +0 -7
- data/spec/lib/pact_broker/webhooks/job_spec.rb +0 -67
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'reform'
|
2
|
+
require 'reform/form'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
module Api
|
7
|
+
module Contracts
|
8
|
+
class VerificationContract < Reform::Form
|
9
|
+
|
10
|
+
property :success
|
11
|
+
property :provider_version, as: :providerApplicationVersion
|
12
|
+
property :build_url, as: :buildUrl
|
13
|
+
|
14
|
+
validation do
|
15
|
+
configure do
|
16
|
+
config.messages_file = File.expand_path("../../../locale/en.yml", __FILE__)
|
17
|
+
|
18
|
+
def not_blank? value
|
19
|
+
value && value.to_s.strip.size > 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def valid_url? url
|
23
|
+
URI(url)
|
24
|
+
rescue URI::InvalidURIError
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def valid_version_number?(value)
|
29
|
+
parsed_version_number = PactBroker.configuration.version_parser.call(value)
|
30
|
+
!!parsed_version_number
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
required(:success).filled(:bool?)
|
35
|
+
required(:provider_version) { not_blank? & valid_version_number? }
|
36
|
+
optional(:build_url).maybe(:valid_url?)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -99,6 +99,13 @@ module PactBroker
|
|
99
99
|
}
|
100
100
|
end
|
101
101
|
|
102
|
+
link :'pb:publish-verification' do | options |
|
103
|
+
{
|
104
|
+
title: "Publish verification",
|
105
|
+
href: verification_publication_url(represented, options.fetch(:base_url))
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
102
109
|
curies do | options |
|
103
110
|
[{
|
104
111
|
name: :pb,
|
@@ -7,18 +7,19 @@ module PactBroker
|
|
7
7
|
module Decorators
|
8
8
|
class RepresentablePact
|
9
9
|
|
10
|
-
attr_reader :consumer, :provider, :consumer_version, :consumer_version_number, :created_at, :
|
10
|
+
attr_reader :consumer, :provider, :consumer_version, :consumer_version_number, :created_at, :consumer_name, :provider_name
|
11
11
|
|
12
12
|
def initialize pact
|
13
13
|
@consumer_version = pact.consumer_version
|
14
14
|
@consumer_version_number = pact.consumer_version.number
|
15
15
|
@consumer = OpenStruct.new(:version => @consumer_version, :name => pact.consumer.name)
|
16
16
|
@provider = OpenStruct.new(:version => nil, :name => pact.provider.name)
|
17
|
+
@consumer_name = pact.consumer.name
|
18
|
+
@provider_name = pact.provider.name
|
17
19
|
@created_at = pact.created_at
|
18
|
-
@updated_at = pact.updated_at
|
19
20
|
end
|
20
21
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
24
|
-
end
|
25
|
+
end
|
@@ -14,7 +14,7 @@ module PactBroker
|
|
14
14
|
property :createdAt, getter: lambda { |_| created_at.xmlschema }, writeable: false
|
15
15
|
|
16
16
|
def optional_updated_at
|
17
|
-
if represented.updated_at != represented.created_at
|
17
|
+
if represented.respond_to?(:updated_at) && represented.updated_at != represented.created_at
|
18
18
|
represented.updated_at.xmlschema
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'base_decorator'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Api
|
5
|
+
module Decorators
|
6
|
+
class VerificationDecorator < BaseDecorator
|
7
|
+
|
8
|
+
property :success
|
9
|
+
property :provider_version, as: :providerApplicationVersion
|
10
|
+
property :build_url, as: :buildUrl
|
11
|
+
|
12
|
+
link :self do | options |
|
13
|
+
{
|
14
|
+
title: 'Verification',
|
15
|
+
name: represented.number,
|
16
|
+
href: verification_url(represented, options.fetch(:base_url), )
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
link 'pb:pact-version' do | options |
|
21
|
+
{
|
22
|
+
title: 'Pact',
|
23
|
+
name: represented.latest_pact_publication.name,
|
24
|
+
href: pact_url(options.fetch(:base_url), represented.latest_pact_publication)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'base_decorator'
|
2
|
+
require_relative 'version_decorator'
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module Api
|
6
|
+
module Decorators
|
7
|
+
|
8
|
+
class VerificationsDecorator < BaseDecorator
|
9
|
+
|
10
|
+
collection :entries, as: :verifications, embedded: true, :extend => PactBroker::Api::Decorators::VerificationDecorator
|
11
|
+
|
12
|
+
link :self do | context |
|
13
|
+
{
|
14
|
+
href: context.fetch(:resource_url),
|
15
|
+
title: "Latest verifications for consumer #{context.fetch(:consumer_name)} version #{context.fetch(:consumer_version_number)}"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -18,6 +18,13 @@ module PactBroker
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
|
+
link :'pb:latest-verifications' do | options |
|
22
|
+
{
|
23
|
+
title: "Latest verifications for consumer version",
|
24
|
+
href: latest_verifications_for_consumer_version_url(represented, options.fetch(:base_url))
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
21
28
|
link :pacticipant do | options |
|
22
29
|
{
|
23
30
|
title: 'Pacticipant',
|
@@ -26,6 +33,13 @@ module PactBroker
|
|
26
33
|
}
|
27
34
|
end
|
28
35
|
|
36
|
+
curies do | options |
|
37
|
+
[{
|
38
|
+
name: :pb,
|
39
|
+
href: options.fetch(:base_url) + '/doc/{rel}',
|
40
|
+
templated: true
|
41
|
+
}]
|
42
|
+
end
|
29
43
|
end
|
30
44
|
end
|
31
45
|
end
|
@@ -28,6 +28,10 @@ module PactBroker
|
|
28
28
|
"#{pactigration_base_url(base_url, pact)}/version/#{pact.consumer_version_number}"
|
29
29
|
end
|
30
30
|
|
31
|
+
def pact_version_url pact, base_url
|
32
|
+
"#{pactigration_base_url(base_url, path)}/pact-version/#{pact.sha}"
|
33
|
+
end
|
34
|
+
|
31
35
|
def pact_url_from_params base_url, params
|
32
36
|
[ base_url, 'pacts',
|
33
37
|
'provider', url_encode(params[:provider_name]),
|
@@ -59,6 +63,32 @@ module PactBroker
|
|
59
63
|
"#{version_url(base_url, version)}/tags"
|
60
64
|
end
|
61
65
|
|
66
|
+
def new_verification_url params, number, base_url
|
67
|
+
[ base_url, 'pacts',
|
68
|
+
'provider', url_encode(params[:provider_name]),
|
69
|
+
'consumer', url_encode(params[:consumer_name]),
|
70
|
+
'pact-version', params[:sha],
|
71
|
+
'verifications', number
|
72
|
+
].join('/')
|
73
|
+
end
|
74
|
+
|
75
|
+
def verification_url verification, base_url
|
76
|
+
[ base_url, 'pacts',
|
77
|
+
'provider', url_encode(verification.provider_name),
|
78
|
+
'consumer', url_encode(verification.consumer_name),
|
79
|
+
'pact-version', verification.pact_version.sha,
|
80
|
+
'verifications', verification.number
|
81
|
+
].join('/')
|
82
|
+
end
|
83
|
+
|
84
|
+
def latest_verifications_for_consumer_version_url version, base_url
|
85
|
+
"#{base_url}/pacts/consumer/#{url_encode(version.pacticipant.name)}/versions/#{version.number}/verifications/latest"
|
86
|
+
end
|
87
|
+
|
88
|
+
def verification_publication_url pact, base_url
|
89
|
+
"#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}/verifications"
|
90
|
+
end
|
91
|
+
|
62
92
|
def tag_url base_url, tag
|
63
93
|
"#{tags_url(base_url, tag.version)}/#{tag.name}"
|
64
94
|
end
|
@@ -94,8 +124,17 @@ module PactBroker
|
|
94
124
|
end
|
95
125
|
|
96
126
|
def pactigration_base_url base_url, pact
|
97
|
-
|
127
|
+
provider_name = pact.respond_to?(:provider_name) ? pact.provider_name : pact.provider.name
|
128
|
+
consumer_name = pact.respond_to?(:consumer_name) ? pact.consumer_name : pact.consumer.name
|
129
|
+
"#{base_url}/pacts/provider/#{url_encode(provider_name)}/consumer/#{url_encode(consumer_name)}"
|
130
|
+
end
|
131
|
+
|
132
|
+
def pactigration_base_url_from_params base_url, params
|
133
|
+
[ base_url, 'pacts',
|
134
|
+
'provider', url_encode(params[:provider_name]),
|
135
|
+
'consumer', url_encode(params[:consumer_name])
|
136
|
+
].join('/')
|
98
137
|
end
|
99
138
|
end
|
100
139
|
end
|
101
|
-
end
|
140
|
+
end
|
@@ -5,6 +5,7 @@ require 'pact_broker/logging'
|
|
5
5
|
require 'pact_broker/api/pact_broker_urls'
|
6
6
|
require 'pact_broker/api/decorators/decorator_context'
|
7
7
|
require 'pact_broker/json'
|
8
|
+
require 'pact_broker/pacts/pact_params'
|
8
9
|
|
9
10
|
module PactBroker
|
10
11
|
|
@@ -67,6 +68,14 @@ module PactBroker
|
|
67
68
|
@params ||= JSON.parse(request.body.to_s, {symbolize_names: true}.merge(PACT_PARSING_OPTIONS))
|
68
69
|
end
|
69
70
|
|
71
|
+
def params_with_string_keys
|
72
|
+
JSON.parse(request.body.to_s, {symbolize_names: false}.merge(PACT_PARSING_OPTIONS))
|
73
|
+
end
|
74
|
+
|
75
|
+
def pact_params
|
76
|
+
@pact_params ||= PactBroker::Pacts::PactParams.from_request request, path_info
|
77
|
+
end
|
78
|
+
|
70
79
|
def set_json_error_message message
|
71
80
|
response.headers['Content-Type'] = 'application/json;charset=utf-8'
|
72
81
|
response.body = {error: message}.to_json
|
@@ -114,8 +123,8 @@ module PactBroker
|
|
114
123
|
end
|
115
124
|
end
|
116
125
|
|
117
|
-
def contract_validation_errors? contract,
|
118
|
-
if (invalid = !contract.validate(
|
126
|
+
def contract_validation_errors? contract, params
|
127
|
+
if (invalid = !contract.validate(params))
|
119
128
|
set_json_validation_error_messages contract.errors.messages
|
120
129
|
end
|
121
130
|
invalid
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'pact_broker/api/resources/base_resource'
|
2
|
+
require 'pact_broker/configuration'
|
3
|
+
require 'pact_broker/domain/verification'
|
4
|
+
require 'pact_broker/api/contracts/verification_contract'
|
5
|
+
require 'pact_broker/api/decorators/verifications_decorator'
|
6
|
+
|
7
|
+
module PactBroker
|
8
|
+
module Api
|
9
|
+
module Resources
|
10
|
+
|
11
|
+
class LatestVerificationsForConsumerVersion < BaseResource
|
12
|
+
|
13
|
+
def allowed_methods
|
14
|
+
["GET"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def content_types_provided
|
18
|
+
[["application/hal+json", :to_json]]
|
19
|
+
end
|
20
|
+
|
21
|
+
def resource_exists?
|
22
|
+
version_params = {pacticipant_name: identifier_from_path[:consumer_name], pacticipant_version_number: identifier_from_path[:consumer_version_number]}
|
23
|
+
!!version_service.find_by_pacticipant_name_and_number(version_params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_json
|
27
|
+
verifications = verification_service.find_latest_verifications_for_consumer_version(identifier_from_path)
|
28
|
+
decorator_for(verifications).to_json(user_options: decorator_context(identifier_from_path))
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def decorator_for verifications
|
34
|
+
PactBroker::Api::Decorators::VerificationsDecorator.new(verifications)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -33,7 +33,7 @@ module PactBroker
|
|
33
33
|
|
34
34
|
def from_json
|
35
35
|
created_model = pacticipant_service.create params
|
36
|
-
response.body = decorator_for(created_model).to_json(
|
36
|
+
response.body = decorator_for(created_model).to_json(decorator_context)
|
37
37
|
end
|
38
38
|
|
39
39
|
def create_path
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'pact_broker/api/resources/base_resource'
|
2
|
+
require 'pact_broker/configuration'
|
3
|
+
require 'pact_broker/domain/verification'
|
4
|
+
require 'pact_broker/api/contracts/verification_contract'
|
5
|
+
require 'pact_broker/api/decorators/verification_decorator'
|
6
|
+
|
7
|
+
module PactBroker
|
8
|
+
module Api
|
9
|
+
module Resources
|
10
|
+
|
11
|
+
class Verifications < BaseResource
|
12
|
+
|
13
|
+
def content_types_accepted
|
14
|
+
[["application/json", :from_json]]
|
15
|
+
end
|
16
|
+
|
17
|
+
def allowed_methods
|
18
|
+
["POST"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def post_is_create?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def resource_exists?
|
26
|
+
!!pact
|
27
|
+
end
|
28
|
+
|
29
|
+
def malformed_request?
|
30
|
+
if request.post?
|
31
|
+
return true if invalid_json?
|
32
|
+
errors = verification_service.errors(params)
|
33
|
+
if !errors.empty?
|
34
|
+
set_json_validation_error_messages(errors.messages)
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_path
|
42
|
+
new_verification_url(pact_params, next_verification_number, base_url)
|
43
|
+
end
|
44
|
+
|
45
|
+
def from_json
|
46
|
+
verification = verification_service.create(next_verification_number, params_with_string_keys, pact)
|
47
|
+
response.body = decorator_for(verification).to_json(user_options: {base_url: base_url})
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def pact
|
54
|
+
@pact ||= pact_service.find_pact(pact_params)
|
55
|
+
end
|
56
|
+
|
57
|
+
def next_verification_number
|
58
|
+
@next_verification_number ||= verification_service.next_number_for(pact)
|
59
|
+
end
|
60
|
+
|
61
|
+
def decorator_for model
|
62
|
+
PactBroker::Api::Decorators::VerificationDecorator.new(model)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -16,7 +16,7 @@ module PactBroker
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def to_json
|
19
|
-
Decorators::WebhooksDecorator.new(webhooks).to_json(
|
19
|
+
Decorators::WebhooksDecorator.new(webhooks).to_json(decorator_context(resource_title: "Webhooks"))
|
20
20
|
end
|
21
21
|
|
22
22
|
def webhooks
|