Skip to content

Commit

Permalink
Fixes #64 - Removes new line from basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
absrd committed Jun 18, 2017
1 parent b3b20dd commit 7c04367
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#125)
* Update README code example quotes to be consistent. (Dmitry Gritsay #112)
* Update README not to recommend installing gem with sudo. (T.J. Schuck #87)
* Removed new line from basic auth. (Felix Kleinschmidt #185)

## 0.6.3 / 2015-01-09

Expand Down
2 changes: 1 addition & 1 deletion lib/rack/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def env(name, value)
# Example:
# basic_authorize "bryan", "secret"
def basic_authorize(username, password)
encoded_login = ["#{username}:#{password}"].pack("m*")
encoded_login = ["#{username}:#{password}"].pack("m0")
header('Authorization', "Basic #{encoded_login}")
end

Expand Down
6 changes: 3 additions & 3 deletions spec/rack/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,20 +339,20 @@ def close
end
end

describe "#authorize" do
describe "#basic_authorize" do
it "sets the HTTP_AUTHORIZATION header" do
authorize "bryan", "secret"
request "/"

expect(last_request.env["HTTP_AUTHORIZATION"]).to eq("Basic YnJ5YW46c2VjcmV0\n")
expect(last_request.env["HTTP_AUTHORIZATION"]).to eq("Basic YnJ5YW46c2VjcmV0")
end

it "includes the header for subsequent requests" do
basic_authorize "bryan", "secret"
request "/"
request "/"

expect(last_request.env["HTTP_AUTHORIZATION"]).to eq("Basic YnJ5YW46c2VjcmV0\n")
expect(last_request.env["HTTP_AUTHORIZATION"]).to eq("Basic YnJ5YW46c2VjcmV0")
end
end

Expand Down

0 comments on commit 7c04367

Please sign in to comment.