Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 4.0.2

Make overwritten Authorization header possible again.

## 4.0.1

Fix so that settings port number is no longer ignored

## 4.0.0

Replace Excon with std lib Net::HTTP, so raised errors will have different underlying errors.
The returned header keys are all lowercase.

## 3.0.1

* Fixed bug where variations of Content-Type application/json got scrubbed, fx application/json;charset=UTF-8 (https://github.com/QuickPay/quickpay-ruby-client/pull/41)
Expand Down
3 changes: 2 additions & 1 deletion lib/quickpay/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def initialize(username: nil, password: nil, base_uri: "https://api.quickpay.net
if (query = req.query) && query.any?
uri.query = URI.encode_www_form(req.query)
end
net_req = method_class.new(uri, req.headers)
net_req = method_class.new(uri)
net_req.basic_auth(@username, @password) if @username || @password
req.headers.each { |key, value| net_req[key] = value }
net_req.body = req.body
res = Net::HTTP.start(
uri.hostname,
Expand Down
2 changes: 1 addition & 1 deletion lib/quickpay/api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module QuickPay
module API
VERSION = "4.0.1".freeze
VERSION = "4.0.2".freeze
end
end
11 changes: 11 additions & 0 deletions test/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
_(headers["authorization"]).must_equal "Basic OnNlY3JldA=="
end

it "overwrites Authorization header if already set" do
stub_request(:get, "http://localhost:4242/ping").to_return { |request| { headers: request.headers, status: 200 } }

client = QuickPay::API::Client.new(password: "secret", base_uri: "http://localhost:4242")
_, _, headers = *client.get("/ping", headers: { Authorization: "Basic OnRlc3RfdXNlcg==" })

_(headers["accept-version"]).must_equal "v10"
_(headers["user-agent"]).must_equal "quickpay-ruby-client, v#{QuickPay::API::VERSION}"
_(headers["authorization"]).must_equal "Basic OnRlc3RfdXNlcg=="
end

describe "JSON <=> Hash conversion of body" do
subject { QuickPay::API::Client.new }

Expand Down
Loading