Skip to content

Commit

Permalink
Remove new line from basic auth (rack#185)
Browse files Browse the repository at this point in the history
* Fixes rack#64 - Removes new line from basic auth
* Fixed grammar
  • Loading branch information
absrd authored and Alex Damian Negru committed Apr 5, 2021
1 parent cde0622 commit b8f3b95
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## vNext / 2017-xx-xx
* Remove new line from basic auth. (Felix Kleinschmidt #185, closes #64)

## 0.7.0 / 2017-07-10

* Major enhancements
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 b8f3b95

Please sign in to comment.