Skip to content

Commit

Permalink
Remove new line from basic auth (#185)
Browse files Browse the repository at this point in the history
* Fixes #64 - Removes new line from basic auth
* Fixed grammar
  • Loading branch information
absrd authored and perlun committed Jul 12, 2017
1 parent d3c44cf commit 0987ddc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions History.md
@@ -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
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
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 0987ddc

Please sign in to comment.