Skip to content

Commit

Permalink
feat(auth): add Authorization header for authenticated brokers
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jun 1, 2017
1 parent 31fe4ce commit 260d86f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/pact/provider_verifier/set_up_provider_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def self.call provider_state, consumer, options
end

conn = Faraday.new(:url => provider_states_setup_url) do |faraday|
if ENV['PACT_BROKER_USERNAME'] && ENV['PACT_BROKER_PASSWORD']
faraday.use Faraday::Request::BasicAuthentication, ENV['PACT_BROKER_USERNAME'], ENV['PACT_BROKER_PASSWORD']
end
faraday.adapter Faraday.default_adapter
end
response = conn.post do |req|
Expand All @@ -19,9 +22,9 @@ def self.call provider_state, consumer, options
end

# Not sure about this?
# if response.status >= 300
# raise SetUpProviderStateError.new("Error setting up provider state '#{provider_state}' for consumer '#{consumer}' at #{provider_states_setup_url}. response status=#{response.status} response.body=#{response.body}")
# end
if response.status >= 300
raise SetUpProviderStateError.new("Error setting up provider state '#{provider_state}' for consumer '#{consumer}' at #{provider_states_setup_url}. response status=#{response.status} response.body=#{response.body}")
end

end

Expand Down

5 comments on commit 260d86f

@bethesque
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using the pact broker environment variable for this @mefellows? I can't see what the broker has to do with setting up state?

@mefellows
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point, can I say NFI?

@mefellows
Copy link
Member Author

@mefellows mefellows commented on 260d86f Jun 1, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bethesque
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I deleted it was that I thought it must have been copy pasted from the code used to get the pacts in another file.

@mefellows
Copy link
Member Author

@mefellows mefellows commented on 260d86f Jun 1, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.