Skip to content

Commit 04ed1cc

Browse files
committed
feat(verification webhooks): invoke verification webhooks on publication of verification
1 parent ec18943 commit 04ed1cc

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

lib/pact_broker/domain/webhook_request.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,15 @@ def log_response response, execution_logger
120120
end
121121

122122
def log_completion_message options, execution_logger, success
123-
execution_logger.info(options[:success_log_message]) if options[:success_log_message] && success
124-
execution_logger.info(options[:failure_log_message]) if options[:failure_log_message] && !success
123+
if options[:success_log_message] && success
124+
execution_logger.info(options[:success_log_message])
125+
logger.info(options[:success_log_message])
126+
end
127+
128+
if options[:failure_log_message] && !success
129+
execution_logger.info(options[:failure_log_message])
130+
logger.info(options[:failure_log_message])
131+
end
125132
end
126133

127134
def to_s

lib/pact_broker/verifications/service.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def create next_verification_number, params, pact
2222
provider_version_number = params.fetch('providerApplicationVersion')
2323
PactBroker::Api::Decorators::VerificationDecorator.new(verification).from_hash(params)
2424
verification.number = next_verification_number
25-
verification_repository.create(verification, provider_version_number, pact)
25+
webhook_service.execute_webhooks pact, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED
26+
verification = verification_repository.create(verification, provider_version_number, pact)
2627
end
2728

2829
def errors params

lib/pact_broker/webhooks/webhook_event.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ module Webhooks
66
class WebhookEvent < Sequel::Model
77

88
CONTRACT_CONTENT_CHANGED = 'contract_content_changed'
9-
CONTRACT_VERIFIABLE_CONTENT_CHANGED = 'contract_verifiable_content_changed'
10-
VERIFICATION_PUBLISHED = 'verification_published'
11-
VERIFICATION_STATUS_CHANGED = 'verification_status_changed'
9+
VERIFICATION_PUBLISHED = 'provider_verification_published'
1210
DEFAULT_EVENT_NAME = CONTRACT_CONTENT_CHANGED
11+
#CONTRACT_VERIFIABLE_CONTENT_CHANGED = 'contract_verifiable_content_changed'
12+
#VERIFICATION_STATUS_CHANGED = 'verification_status_changed'
13+
14+
EVENT_NAMES = [CONTRACT_CONTENT_CHANGED, VERIFICATION_PUBLISHED]
1315

1416
dataset_module do
1517
include PactBroker::Repositories::Helpers

0 commit comments

Comments
 (0)