Skip to content

Commit

Permalink
fix: correct logic for showing webhook response bodies in logs when a…
Browse files Browse the repository at this point in the history
… whitelist is configured
  • Loading branch information
bethesque committed Jun 9, 2018
1 parent 86bc1ec commit db2f9d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/webhooks/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def self.find_all

def self.execute_webhook_now webhook, pact, verification = nil
triggered_webhook = webhook_repository.create_triggered_webhook(next_uuid, webhook, pact, verification, USER)
options = { failure_log_message: "Webhook execution failed", show_response: PactBroker.configuration.show_webhook_response?}
options = { failure_log_message: "Webhook execution failed"}
webhook_execution_result = execute_triggered_webhook_now triggered_webhook, options
if webhook_execution_result.success?
webhook_repository.update_triggered_webhook_status triggered_webhook, TriggeredWebhook::STATUS_SUCCESS
Expand All @@ -72,7 +72,7 @@ def self.execute_webhook_now webhook, pact, verification = nil
end

def self.execute_triggered_webhook_now triggered_webhook, options
webhook_execution_result = triggered_webhook.execute options
webhook_execution_result = triggered_webhook.execute options.merge(show_response: PactBroker.configuration.show_webhook_response?)
webhook_repository.create_execution triggered_webhook, webhook_execution_result
webhook_execution_result
end
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/pact_broker/webhooks/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ module Webhooks

subject { PactBroker::Webhooks::Service.execute_webhook_now td.webhook, pact, td.verification }

it "executes the triggered webhook with the correct options" do
allow(PactBroker.configuration).to receive(:show_webhook_response?).and_return('foo')
expected_options = { :failure_log_message => "Webhook execution failed", :show_response => 'foo' }
expect_any_instance_of(PactBroker::Webhooks::TriggeredWebhook).to receive(:execute).with(expected_options).and_call_original
subject
end

it "executes the HTTP request of the webhook" do
subject
expect(http_request).to have_been_made
Expand Down Expand Up @@ -165,6 +158,13 @@ module Webhooks
expect(http_request).to have_been_made
end

it "executes the webhook with the correct options" do
allow(PactBroker.configuration).to receive(:show_webhook_response?).and_return('foo')
expected_options = {:show_response => 'foo' }
expect_any_instance_of(PactBroker::Domain::WebhookRequest).to receive(:execute).with(anything, anything, hash_including(expected_options)).and_call_original
subject
end

it "saves the triggered webhook" do
expect { subject }.to change { PactBroker::Webhooks::TriggeredWebhook.count }.by(1)
end
Expand Down

0 comments on commit db2f9d1

Please sign in to comment.