Skip to content

Commit

Permalink
feat: add support for bearer token
Browse files Browse the repository at this point in the history
  • Loading branch information
vixplows committed Feb 20, 2019
1 parent f4d0a4d commit 3a102c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/pact/provider_verifier/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def verify_pact(config)
backtrace: ENV['BACKTRACE'] == 'true',
pact_broker_username: options.broker_username,
pact_broker_password: options.broker_password,
pact_broker_token: options.broker_token,
format: options.format,
out: options.out,
ignore_failures: config.pending,
Expand Down Expand Up @@ -164,7 +165,7 @@ def reset_pact_configuration
end

def all_pact_urls
http_client_options = { username: options.broker_username, password: options.broker_password, verbose: options.verbose }
http_client_options = { username: options.broker_username, password: options.broker_password, token: options.broker_token, verbose: options.verbose }
AggregatePactConfigs.call(pact_urls, options.provider, consumer_version_tags, options.pact_broker_base_url, http_client_options)
end

Expand Down
1 change: 1 addition & 0 deletions lib/pact/provider_verifier/cli/verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class InvalidArgumentsError < ::Thor::Error; end
method_option :pact_broker_base_url, desc: "Base URL of the Pact Broker from which to retrieve the pacts.", :required => false
method_option :broker_username, aliases: "-n", desc: "Pact Broker basic auth username", :required => false
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password", :required => false
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token", :required => false
method_option :provider, required: false
method_option :consumer_version_tag, type: :array, banner: "TAG", desc: "Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.", :required => false
method_option :provider_app_version, aliases: "-a", desc: "Provider application version, required when publishing verification results", :required => false
Expand Down
6 changes: 3 additions & 3 deletions spec/integration_with_pact_broker_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
allow(ENV).to receive(:[]).with('PACT_INCLUDE_PENDING').and_return('true')
end

let(:args) { %W{pact-provider-verifier --provider Foo --consumer-version-tag master --consumer-version-tag prod --pact-broker-base-url http://localhost:5738 --broker-username username --broker-password password --provider-base-url http://localhost:4567} }
let(:args) { %W{pact-provider-verifier --provider Foo --consumer-version-tag master --consumer-version-tag prod --pact-broker-base-url http://localhost:5738 --broker-username username --broker-password password --broker-token token --provider-base-url http://localhost:4567} }
let(:pact_uris) { ["http://non-pending-pact"] }
let(:pending_pact_uris) { ["http://pending-pact"] }
let(:pact_broker_api) { class_double(Pact::PactBroker).as_stubbed_const }
Expand All @@ -23,12 +23,12 @@
end

it "fetches the pact URIs from the broker" do
expect(pact_broker_api).to receive(:fetch_pact_uris).with("Foo", ["master", "prod"], "http://localhost:5738", { username: "username", password: "password", verbose: nil })
expect(pact_broker_api).to receive(:fetch_pact_uris).with("Foo", ["master", "prod"], "http://localhost:5738", { username: "username", password: "password", token: "token", verbose: nil })
subject
end

it "fetches the pending pacts URIs from the broker" do
expect(pact_broker_api).to receive(:fetch_pending_pact_uris).with("Foo", "http://localhost:5738", { username: "username", password: "password", verbose: nil })
expect(pact_broker_api).to receive(:fetch_pending_pact_uris).with("Foo", "http://localhost:5738", { username: "username", password: "password", token: "token", verbose: nil })
subject
end

Expand Down

0 comments on commit 3a102c4

Please sign in to comment.