Skip to content

Commit

Permalink
feat(verification webhooks): invoke verification webhooks on publicat…
Browse files Browse the repository at this point in the history
…ion of verification
  • Loading branch information
bethesque committed Dec 7, 2017
1 parent ec18943 commit 04ed1cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
11 changes: 9 additions & 2 deletions lib/pact_broker/domain/webhook_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,15 @@ def log_response response, execution_logger
end

def log_completion_message options, execution_logger, success
execution_logger.info(options[:success_log_message]) if options[:success_log_message] && success
execution_logger.info(options[:failure_log_message]) if options[:failure_log_message] && !success
if options[:success_log_message] && success
execution_logger.info(options[:success_log_message])
logger.info(options[:success_log_message])
end

if options[:failure_log_message] && !success
execution_logger.info(options[:failure_log_message])
logger.info(options[:failure_log_message])
end
end

def to_s
Expand Down
3 changes: 2 additions & 1 deletion lib/pact_broker/verifications/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def create next_verification_number, params, pact
provider_version_number = params.fetch('providerApplicationVersion')
PactBroker::Api::Decorators::VerificationDecorator.new(verification).from_hash(params)
verification.number = next_verification_number
verification_repository.create(verification, provider_version_number, pact)
webhook_service.execute_webhooks pact, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED
verification = verification_repository.create(verification, provider_version_number, pact)
end

def errors params
Expand Down
8 changes: 5 additions & 3 deletions lib/pact_broker/webhooks/webhook_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ module Webhooks
class WebhookEvent < Sequel::Model

CONTRACT_CONTENT_CHANGED = 'contract_content_changed'
CONTRACT_VERIFIABLE_CONTENT_CHANGED = 'contract_verifiable_content_changed'
VERIFICATION_PUBLISHED = 'verification_published'
VERIFICATION_STATUS_CHANGED = 'verification_status_changed'
VERIFICATION_PUBLISHED = 'provider_verification_published'
DEFAULT_EVENT_NAME = CONTRACT_CONTENT_CHANGED
#CONTRACT_VERIFIABLE_CONTENT_CHANGED = 'contract_verifiable_content_changed'
#VERIFICATION_STATUS_CHANGED = 'verification_status_changed'

EVENT_NAMES = [CONTRACT_CONTENT_CHANGED, VERIFICATION_PUBLISHED]

dataset_module do
include PactBroker::Repositories::Helpers
Expand Down

0 comments on commit 04ed1cc

Please sign in to comment.