From 0987ddcd991caa40d3a7657e497aa7e3a7df5973 Mon Sep 17 00:00:00 2001 From: absrd Date: Wed, 12 Jul 2017 07:53:50 +0200 Subject: [PATCH] Remove new line from basic auth (#185) * Fixes #64 - Removes new line from basic auth * Fixed grammar --- History.md | 3 +++ lib/rack/test.rb | 2 +- spec/rack/test_spec.rb | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 9f9764f9..63f74d29 100644 --- a/History.md +++ b/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 diff --git a/lib/rack/test.rb b/lib/rack/test.rb index b7288c62..523bb65e 100644 --- a/lib/rack/test.rb +++ b/lib/rack/test.rb @@ -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 diff --git a/spec/rack/test_spec.rb b/spec/rack/test_spec.rb index bb7f7768..1fc871ed 100644 --- a/spec/rack/test_spec.rb +++ b/spec/rack/test_spec.rb @@ -339,12 +339,12 @@ 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 @@ -352,7 +352,7 @@ def close 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