pact_broker 2.31.0 → 2.32.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -0
- data/db/migrations/20190509_create_version_sequence.rb +8 -0
- data/db/migrations/20190510_set_version_sequence.rb +9 -0
- data/db/migrations/20190511_create_integrations_view.rb +19 -0
- data/db/migrations/20190523_add_enabled_column_to_webhooks.rb +5 -0
- data/db/migrations/20190524_set_webhooks_enabled.rb +10 -0
- data/db/migrations/20190525_add_description_column_to_webhooks.rb +5 -0
- data/lib/pact_broker/api.rb +3 -0
- data/lib/pact_broker/api/decorators/base_decorator.rb +0 -3
- data/lib/pact_broker/api/decorators/integration_decorator.rb +40 -0
- data/lib/pact_broker/api/decorators/integrations_decorator.rb +19 -0
- data/lib/pact_broker/api/decorators/pact_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/pact_details_decorator.rb +1 -6
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +12 -0
- data/lib/pact_broker/api/decorators/verifiable_pacts_decorator.rb +20 -0
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +5 -1
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +0 -1
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +2 -2
- data/lib/pact_broker/api/pact_broker_urls.rb +37 -3
- data/lib/pact_broker/api/resources/base_resource.rb +4 -0
- data/lib/pact_broker/api/resources/dashboard.rb +1 -1
- data/lib/pact_broker/api/resources/integrations.rb +10 -2
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +8 -14
- data/lib/pact_broker/api/resources/pact.rb +15 -3
- data/lib/pact_broker/api/resources/verification.rb +0 -2
- data/lib/pact_broker/api/resources/verifications.rb +18 -1
- data/lib/pact_broker/api/resources/webhook.rb +1 -1
- data/lib/pact_broker/api/resources/webhook_execution.rb +18 -9
- data/lib/pact_broker/app.rb +10 -11
- data/lib/pact_broker/db.rb +2 -2
- data/lib/pact_broker/db/data_migrations/helpers.rb +11 -0
- data/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value.rb +29 -0
- data/lib/pact_broker/db/data_migrations/set_webhooks_enabled.rb +17 -0
- data/lib/pact_broker/db/migrate_data.rb +2 -0
- data/lib/pact_broker/db/seed_example_data.rb +6 -3
- data/lib/pact_broker/domain/order_versions.rb +14 -1
- data/lib/pact_broker/domain/verification.rb +4 -0
- data/lib/pact_broker/domain/webhook.rb +13 -3
- data/lib/pact_broker/domain/webhook_request.rb +3 -2
- data/lib/pact_broker/index/service.rb +3 -0
- data/lib/pact_broker/integrations/integration.rb +10 -0
- data/lib/pact_broker/integrations/service.rb +5 -0
- data/lib/pact_broker/matrix/parse_query.rb +2 -0
- data/lib/pact_broker/matrix/row.rb +8 -0
- data/lib/pact_broker/matrix/service.rb +1 -2
- data/lib/pact_broker/pacts/service.rb +16 -9
- data/lib/pact_broker/test/test_data_builder.rb +6 -2
- data/lib/pact_broker/verifications/sequence.rb +0 -2
- data/lib/pact_broker/verifications/service.rb +10 -2
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/sequence.rb +38 -0
- data/lib/pact_broker/webhooks/job.rb +19 -7
- data/lib/pact_broker/webhooks/render.rb +30 -13
- data/lib/pact_broker/webhooks/repository.rb +3 -4
- data/lib/pact_broker/webhooks/service.rb +60 -34
- data/lib/pact_broker/webhooks/trigger_service.rb +6 -6
- data/lib/pact_broker/webhooks/webhook.rb +9 -1
- data/lib/pact_broker/webhooks/webhook_request_template.rb +11 -7
- data/lib/rack/pact_broker/database_transaction.rb +6 -2
- data/script/publish-new.sh +23 -1
- data/script/publish.sh +13 -4
- data/script/seed.rb +53 -52
- data/spec/features/create_webhook_spec.rb +2 -0
- data/spec/features/execute_webhook_spec.rb +4 -3
- data/spec/features/get_integrations_spec.rb +17 -0
- data/spec/features/get_pacts_to_verify_spec.rb +7 -3
- data/spec/features/publish_verification_spec.rb +8 -1
- data/spec/features/update_webhook_spec.rb +47 -0
- data/spec/integration/webhooks/certificate_spec.rb +1 -1
- data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +12 -0
- data/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb +82 -0
- data/spec/lib/pact_broker/api/decorators/integrations_decorator_spec.rb +29 -0
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +12 -4
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +30 -0
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_decorator_spec.rb +29 -0
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +20 -1
- data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +0 -4
- data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +5 -4
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +64 -1
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +0 -3
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +40 -10
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +13 -3
- data/spec/lib/pact_broker/app_spec.rb +28 -4
- data/spec/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value_spec.rb +68 -0
- data/spec/lib/pact_broker/domain/order_versions_spec.rb +1 -4
- data/spec/lib/pact_broker/domain/webhook_spec.rb +10 -6
- data/spec/lib/pact_broker/matrix/parse_query_spec.rb +15 -7
- data/spec/lib/pact_broker/pacts/service_spec.rb +13 -5
- data/spec/lib/pact_broker/verifications/service_spec.rb +15 -3
- data/spec/lib/pact_broker/versions/repository_spec.rb +1 -1
- data/spec/lib/pact_broker/webhooks/job_spec.rb +52 -15
- data/spec/lib/pact_broker/webhooks/render_spec.rb +28 -7
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +23 -32
- data/spec/lib/pact_broker/webhooks/service_spec.rb +186 -62
- data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +6 -5
- data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +12 -5
- data/spec/lib/rack/pact_broker/database_transaction_spec.rb +10 -0
- data/spec/lib/rack/pact_broker/ui_request_filter_spec.rb +9 -0
- data/spec/migrations/23_pact_versions_spec.rb +7 -1
- data/spec/support/database_cleaner.rb +11 -1
- data/spec/support/metadata_test_server.rb +40 -0
- data/spec/support/verification_job.rb +34 -0
- data/spec/support/webhook_endpoint_middleware.rb +22 -0
- metadata +37 -2
@@ -6,6 +6,10 @@ module PactBroker
|
|
6
6
|
module Resources
|
7
7
|
class MatrixForConsumerAndProvider < BaseResource
|
8
8
|
|
9
|
+
def initialize
|
10
|
+
_, @options = PactBroker::Matrix::ParseQuery.call(request.uri.query)
|
11
|
+
end
|
12
|
+
|
9
13
|
def content_types_provided
|
10
14
|
[["application/hal+json", :to_json]]
|
11
15
|
end
|
@@ -19,24 +23,14 @@ module PactBroker
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def to_json
|
22
|
-
lines = matrix_service.find_for_consumer_and_provider(identifier_from_path)
|
26
|
+
lines = matrix_service.find_for_consumer_and_provider(identifier_from_path, options)
|
23
27
|
PactBroker::Api::Decorators::MatrixDecorator.new(lines).to_json(user_options: { base_url: base_url })
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
@consumer ||= find_pacticipant(identifier_from_path[:consumer_name], "consumer")
|
28
|
-
end
|
29
|
-
|
30
|
-
def provider
|
31
|
-
@provider ||= find_pacticipant(identifier_from_path[:provider_name], "provider")
|
32
|
-
end
|
30
|
+
private
|
33
31
|
|
34
|
-
|
35
|
-
pacticipant_service.find_pacticipant_by_name(name).tap do | pacticipant |
|
36
|
-
set_json_error_message("No #{role} with name '#{name}' found") if pacticipant.nil?
|
37
|
-
end
|
38
|
-
end
|
32
|
+
attr_reader :options
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
42
|
-
end
|
36
|
+
end
|
@@ -65,9 +65,9 @@ module PactBroker
|
|
65
65
|
response_code = pact ? 200 : 201
|
66
66
|
|
67
67
|
if request.patch? && resource_exists?
|
68
|
-
@pact = pact_service.merge_pact(pact_params)
|
68
|
+
@pact = pact_service.merge_pact(pact_params, webhook_options)
|
69
69
|
else
|
70
|
-
@pact = pact_service.create_or_update_pact(pact_params)
|
70
|
+
@pact = pact_service.create_or_update_pact(pact_params, webhook_options)
|
71
71
|
end
|
72
72
|
|
73
73
|
response.body = to_json
|
@@ -75,7 +75,7 @@ module PactBroker
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def to_json
|
78
|
-
PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options:
|
78
|
+
PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options: decorator_context(metadata: identifier_from_path[:metadata]))
|
79
79
|
end
|
80
80
|
|
81
81
|
def to_html
|
@@ -118,6 +118,18 @@ module PactBroker
|
|
118
118
|
response.body = response_body.to_json
|
119
119
|
response.headers["Content-Type" => "application/hal+json;charset=utf-8"]
|
120
120
|
end
|
121
|
+
|
122
|
+
def webhook_options
|
123
|
+
{
|
124
|
+
database_connector: database_connector,
|
125
|
+
execution_options: {
|
126
|
+
show_response: PactBroker.configuration.show_webhook_response?
|
127
|
+
},
|
128
|
+
webhook_context: {
|
129
|
+
base_url: base_url
|
130
|
+
}
|
131
|
+
}
|
132
|
+
end
|
121
133
|
end
|
122
134
|
end
|
123
135
|
end
|
@@ -7,9 +7,7 @@ require 'pact_broker/api/decorators/verification_decorator'
|
|
7
7
|
module PactBroker
|
8
8
|
module Api
|
9
9
|
module Resources
|
10
|
-
|
11
10
|
class Verification < BaseResource
|
12
|
-
|
13
11
|
def content_types_provided
|
14
12
|
[["application/hal+json", :to_json], ["application/json", :to_json]]
|
15
13
|
end
|
@@ -47,7 +47,7 @@ module PactBroker
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def from_json
|
50
|
-
verification = verification_service.create(next_verification_number, params_with_string_keys, pact)
|
50
|
+
verification = verification_service.create(next_verification_number, params_with_string_keys, pact, webhook_options)
|
51
51
|
response.body = decorator_for(verification).to_json(user_options: {base_url: base_url})
|
52
52
|
true
|
53
53
|
end
|
@@ -69,6 +69,23 @@ module PactBroker
|
|
69
69
|
def update_matrix_after_request?
|
70
70
|
request.post?
|
71
71
|
end
|
72
|
+
|
73
|
+
|
74
|
+
def metadata
|
75
|
+
PactBrokerUrls.parse_webhook_metadata(identifier_from_path[:metadata])
|
76
|
+
end
|
77
|
+
|
78
|
+
def webhook_options
|
79
|
+
{
|
80
|
+
database_connector: database_connector,
|
81
|
+
execution_options: {
|
82
|
+
show_response: PactBroker.configuration.show_webhook_response?
|
83
|
+
},
|
84
|
+
webhook_context: metadata.merge(
|
85
|
+
base_url: base_url
|
86
|
+
)
|
87
|
+
}
|
88
|
+
end
|
72
89
|
end
|
73
90
|
end
|
74
91
|
end
|
@@ -6,7 +6,6 @@ require 'pact_broker/constants'
|
|
6
6
|
module PactBroker
|
7
7
|
module Api
|
8
8
|
module Resources
|
9
|
-
|
10
9
|
class WebhookExecution < BaseResource
|
11
10
|
|
12
11
|
def allowed_methods
|
@@ -14,15 +13,10 @@ module PactBroker
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def process_post
|
17
|
-
webhook_execution_result = webhook_service.test_execution(webhook)
|
16
|
+
webhook_execution_result = webhook_service.test_execution(webhook, webhook_options)
|
18
17
|
response.headers['Content-Type'] = 'application/hal+json;charset=utf-8'
|
19
18
|
response.body = post_response_body webhook_execution_result
|
20
|
-
|
21
|
-
true
|
22
|
-
else
|
23
|
-
response.headers[PactBroker::DO_NOT_ROLLBACK] = 'true'
|
24
|
-
500
|
25
|
-
end
|
19
|
+
true
|
26
20
|
end
|
27
21
|
|
28
22
|
def resource_exists?
|
@@ -44,7 +38,22 @@ module PactBroker
|
|
44
38
|
end
|
45
39
|
|
46
40
|
def user_options
|
47
|
-
{
|
41
|
+
{
|
42
|
+
base_url: base_url,
|
43
|
+
webhook: webhook,
|
44
|
+
show_response: PactBroker.configuration.show_webhook_response?
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def webhook_options
|
49
|
+
{
|
50
|
+
execution_options: {
|
51
|
+
show_response: PactBroker.configuration.show_webhook_response?
|
52
|
+
},
|
53
|
+
webhook_context: {
|
54
|
+
base_url: base_url
|
55
|
+
}
|
56
|
+
}
|
48
57
|
end
|
49
58
|
end
|
50
59
|
end
|
data/lib/pact_broker/app.rb
CHANGED
@@ -60,6 +60,10 @@ module PactBroker
|
|
60
60
|
@custom_ui = custom_ui
|
61
61
|
end
|
62
62
|
|
63
|
+
def use_custom_api custom_api
|
64
|
+
@custom_api = custom_api
|
65
|
+
end
|
66
|
+
|
63
67
|
def call env
|
64
68
|
running_app.call env
|
65
69
|
end
|
@@ -129,7 +133,6 @@ module PactBroker
|
|
129
133
|
configure_middleware
|
130
134
|
|
131
135
|
# need this first so UI login logic is performed before API login logic
|
132
|
-
@cascade_apps << build_custom_ui if custom_ui
|
133
136
|
@cascade_apps << build_ui
|
134
137
|
|
135
138
|
if configuration.enable_diagnostic_endpoints
|
@@ -163,30 +166,26 @@ module PactBroker
|
|
163
166
|
def build_ui
|
164
167
|
logger.info "Mounting UI"
|
165
168
|
require 'pact_broker/ui'
|
169
|
+
ui_apps = [PactBroker::UI::App.new]
|
170
|
+
ui_apps.unshift(@custom_ui) if @custom_ui
|
166
171
|
builder = ::Rack::Builder.new
|
167
172
|
builder.use Rack::PactBroker::UIRequestFilter
|
168
173
|
builder.use @make_it_later_ui_auth
|
169
174
|
builder.use Rack::PactBroker::UIAuthentication # deprecate?
|
170
|
-
builder.run
|
171
|
-
builder
|
172
|
-
end
|
173
|
-
|
174
|
-
def build_custom_ui
|
175
|
-
logger.info "Mounting Custom UI"
|
176
|
-
builder = ::Rack::Builder.new
|
177
|
-
builder.use Rack::PactBroker::UIRequestFilter
|
178
|
-
builder.run @custom_ui
|
175
|
+
builder.run Rack::Cascade.new(ui_apps)
|
179
176
|
builder
|
180
177
|
end
|
181
178
|
|
182
179
|
def build_api
|
183
180
|
logger.info "Mounting PactBroker::API"
|
184
181
|
require 'pact_broker/api'
|
182
|
+
api_apps = [PactBroker::API]
|
183
|
+
api_apps.unshift(@custom_api) if @custom_api
|
185
184
|
builder = ::Rack::Builder.new
|
186
185
|
builder.use @make_it_later_api_auth
|
187
186
|
builder.use Rack::PactBroker::Convert404ToHal
|
188
187
|
builder.use Rack::PactBroker::DatabaseTransaction, configuration.database_connection
|
189
|
-
builder.run
|
188
|
+
builder.run Rack::Cascade.new(api_apps)
|
190
189
|
builder
|
191
190
|
end
|
192
191
|
|
data/lib/pact_broker/db.rb
CHANGED
@@ -18,9 +18,9 @@ module PactBroker
|
|
18
18
|
@connection
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.run_migrations database_connection
|
21
|
+
def self.run_migrations database_connection, options = {}
|
22
22
|
Sequel.extension :migration
|
23
|
-
Sequel::TimestampMigrator.new(database_connection, PactBroker::DB::MIGRATIONS_DIR).run
|
23
|
+
Sequel::TimestampMigrator.new(database_connection, PactBroker::DB::MIGRATIONS_DIR, options).run
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.run_data_migrations database_connection
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module DB
|
3
|
+
module DataMigrations
|
4
|
+
class SetLatestVersionSequenceValue
|
5
|
+
def self.call connection
|
6
|
+
if columns_exist?(connection)
|
7
|
+
max_order = connection[:versions].max(:order) || 0
|
8
|
+
sequence_row = connection[:version_sequence_number].first
|
9
|
+
if sequence_row.nil? || sequence_row[:value] <= max_order
|
10
|
+
new_value = max_order + 100
|
11
|
+
connection[:version_sequence_number].insert(value: new_value)
|
12
|
+
# Make sure there is only ever one row in case there is a race condition
|
13
|
+
connection[:version_sequence_number].exclude(value: new_value).delete
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.columns_exist?(connection)
|
19
|
+
column_exists?(connection, :versions, :order) &&
|
20
|
+
column_exists?(connection, :version_sequence_number, :value)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.column_exists?(connection, table, column)
|
24
|
+
connection.table_exists?(table) && connection.schema(table).find{|col| col.first == column }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pact_broker/db/data_migrations/helpers'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module DB
|
5
|
+
module DataMigrations
|
6
|
+
class SetWebhooksEnabled
|
7
|
+
extend Helpers
|
8
|
+
|
9
|
+
def self.call(connection)
|
10
|
+
if column_exists?(connection, :webhooks, :enabled)
|
11
|
+
connection[:webhooks].where(enabled: nil).update(enabled: true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -16,6 +16,8 @@ module PactBroker
|
|
16
16
|
def self.call database_connection, options = {}
|
17
17
|
DataMigrations::SetPacticipantIdsForVerifications.call(database_connection)
|
18
18
|
DataMigrations::SetConsumerIdsForPactPublications.call(database_connection)
|
19
|
+
DataMigrations::SetLatestVersionSequenceValue.call(database_connection)
|
20
|
+
DataMigrations::SetWebhooksEnabled.call(database_connection)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -4,15 +4,18 @@ require 'pact_broker/pacticipants/service'
|
|
4
4
|
module PactBroker
|
5
5
|
module DB
|
6
6
|
class SeedExampleData
|
7
|
+
CONSUMER_NAME = "Example App"
|
8
|
+
PROVIDER_NAME = "Example API"
|
9
|
+
|
7
10
|
def self.call
|
8
11
|
new.call
|
9
12
|
end
|
10
13
|
|
11
|
-
def call
|
14
|
+
def call(consumer_name: CONSUMER_NAME, provider_name: PROVIDER_NAME)
|
12
15
|
return unless database_empty?
|
13
16
|
PactBroker::Test::TestDataBuilder.new
|
14
|
-
.create_consumer(
|
15
|
-
.create_provider(
|
17
|
+
.create_consumer(consumer_name, created_at: days_ago(16))
|
18
|
+
.create_provider(provider_name, created_at: days_ago(16))
|
16
19
|
.create_consumer_version("e15da45d3943bf10793a6d04cfb9f5dabe430fe2", created_at: days_ago(16))
|
17
20
|
.create_consumer_version_tag("prod", created_at: days_ago(16))
|
18
21
|
.create_consumer_version_tag("dev", created_at: days_ago(16))
|
@@ -1,13 +1,26 @@
|
|
1
1
|
require 'pact_broker/configuration'
|
2
|
+
require 'pact_broker/versions/sequence'
|
2
3
|
|
3
4
|
module PactBroker
|
4
5
|
module Domain
|
5
6
|
class OrderVersions
|
6
|
-
|
7
7
|
include PactBroker::Logging
|
8
8
|
|
9
9
|
def self.call new_version
|
10
10
|
new_version.lock!
|
11
|
+
|
12
|
+
if PactBroker.configuration.order_versions_by_date
|
13
|
+
set_sequential_order(new_version)
|
14
|
+
else
|
15
|
+
set_semantic_order(new_version)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.set_sequential_order(new_version)
|
20
|
+
set_order new_version, PactBroker::Versions::Sequence.next_val
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.set_semantic_order(new_version)
|
11
24
|
order_set = false
|
12
25
|
|
13
26
|
PactBroker::Domain::Version.for_update.where(pacticipant_id: new_version.pacticipant_id).exclude(order: nil).reverse(:order).each do | existing_version |
|
@@ -10,21 +10,31 @@ module PactBroker
|
|
10
10
|
include Messages
|
11
11
|
include Logging
|
12
12
|
|
13
|
-
attr_accessor :uuid, :consumer, :provider, :request, :created_at, :updated_at, :events
|
13
|
+
attr_accessor :uuid, :consumer, :provider, :request, :created_at, :updated_at, :events, :enabled, :description
|
14
14
|
attr_reader :attributes
|
15
15
|
|
16
16
|
def initialize attributes = {}
|
17
17
|
@attributes = attributes
|
18
18
|
@uuid = attributes[:uuid]
|
19
|
+
@description = attributes[:description]
|
19
20
|
@request = attributes[:request]
|
20
21
|
@consumer = attributes[:consumer]
|
21
22
|
@provider = attributes[:provider]
|
22
23
|
@events = attributes[:events]
|
24
|
+
@enabled = attributes[:enabled]
|
23
25
|
@created_at = attributes[:created_at]
|
24
26
|
@updated_at = attributes[:updated_at]
|
25
27
|
end
|
26
28
|
|
27
|
-
def
|
29
|
+
def display_description
|
30
|
+
if description && description.strip.size > 0
|
31
|
+
description
|
32
|
+
else
|
33
|
+
request_description
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def scope_description
|
28
38
|
if consumer && provider
|
29
39
|
"A webhook for the pact between #{consumer.name} and #{provider.name}"
|
30
40
|
elsif provider
|
@@ -42,7 +52,7 @@ module PactBroker
|
|
42
52
|
|
43
53
|
def execute pact, verification, options
|
44
54
|
logger.info "Executing #{self}"
|
45
|
-
request.build(pact: pact, verification: verification,
|
55
|
+
request.build(pact: pact, verification: verification, webhook_context: options.fetch(:webhook_context)).execute(options.fetch(:execution_options))
|
46
56
|
end
|
47
57
|
|
48
58
|
def to_s
|
@@ -9,6 +9,7 @@ require 'pact_broker/api/pact_broker_urls'
|
|
9
9
|
require 'pact_broker/build_http_options'
|
10
10
|
require 'cgi'
|
11
11
|
require 'delegate'
|
12
|
+
require 'rack/utils'
|
12
13
|
|
13
14
|
module PactBroker
|
14
15
|
|
@@ -122,7 +123,7 @@ module PactBroker
|
|
122
123
|
@http_request ||= begin
|
123
124
|
req = Net::HTTP.const_get(method.capitalize).new(url)
|
124
125
|
headers.each_pair { | name, value | req[name] = value }
|
125
|
-
req.basic_auth(username, password) if username
|
126
|
+
req.basic_auth(username, password) if username && username.size > 0
|
126
127
|
req.body = body unless body.nil?
|
127
128
|
req
|
128
129
|
end
|
@@ -152,7 +153,7 @@ module PactBroker
|
|
152
153
|
|
153
154
|
def log_response response
|
154
155
|
log_response_to_application_logger(response)
|
155
|
-
if options
|
156
|
+
if options.fetch(:show_response)
|
156
157
|
log_response_to_execution_logger(response)
|
157
158
|
else
|
158
159
|
execution_logger.info response_body_hidden_message
|