Skip to content

Commit

Permalink
fix(create webhook): pass in token from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 25, 2019
1 parent f8b3432 commit 9d3170e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/pact_broker/client/webhooks/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def self.call(params, pact_broker_base_url, pact_broker_client_options)
def initialize(params, pact_broker_base_url, pact_broker_client_options)
@params = OpenStruct.new(params)
@pact_broker_base_url = pact_broker_base_url
@basic_auth_options = pact_broker_client_options[:basic_auth] || {}
@verbose = pact_broker_client_options[:verbose]
@http_client = PactBroker::Client::Hal::HttpClient.new(basic_auth_options.merge(verbose: verbose))
@http_client = PactBroker::Client::Hal::HttpClient.new(pact_broker_client_options.merge(pact_broker_client_options[:basic_auth] || {}))
end

def call
Expand Down
12 changes: 9 additions & 3 deletions spec/lib/pact_broker/client/webhooks/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Webhooks
}.to_json
end
let!(:index_request) do
stub_request(:get, "http://broker").to_return(status: 200, body: index_body, headers: { "Content-Type" => "application/hal+json" } )
stub_request(:get, "http://broker").with(headers: { "Authorization" => /.*/}).to_return(status: 200, body: index_body, headers: { "Content-Type" => "application/hal+json" } )
end

let!(:webhook_request) do
Expand All @@ -34,10 +34,16 @@ module Webhooks
}.tap { |it| Pact::Fixture.add_fixture(:create_webhook_params, it) }
end

subject { Create.call(params, "http://broker", {}) }
let(:pact_broker_client_options) do
{
token: 'token',
verbose: 'verbose'
}
end

context "when a 405 is returned from the webhook creation request" do
subject { Create.call(params, "http://broker", pact_broker_client_options) }

context "when a 405 is returned from the webhook creation request" do
it "raises an error with a message to upgrade the Pact Broker" do
expect { subject }.to raise_error PactBroker::Client::Error, /This version of the Pact Broker/
end
Expand Down

0 comments on commit 9d3170e

Please sign in to comment.