diff options
author | Larry Lv <larrylv1990@gmail.com> | 2014-06-13 14:19:53 +0800 |
---|---|---|
committer | Larry Lv <larrylv1990@gmail.com> | 2014-06-13 16:29:15 +0800 |
commit | fdb10597952614456b45460202c0b7c7b8833ecd (patch) | |
tree | d138b0e9d3b1a6b5e25347af8316c907e3ac25b2 /actionpack/test | |
parent | 9a0c2e5c626cfbde527013bd0cfcec682baa48fa (diff) | |
download | rails-fdb10597952614456b45460202c0b7c7b8833ecd.tar.gz rails-fdb10597952614456b45460202c0b7c7b8833ecd.tar.bz2 rails-fdb10597952614456b45460202c0b7c7b8833ecd.zip |
Fix parsed token value with header `Authorization token=`.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/http_token_authentication_test.rb | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb index 86b94652ce..ef90fff178 100644 --- a/actionpack/test/controller/http_token_authentication_test.rb +++ b/actionpack/test/controller/http_token_authentication_test.rb @@ -132,13 +132,30 @@ class HttpTokenAuthenticationTest < ActionController::TestCase assert_equal(expected, actual) end - private - - def sample_request(token) - @sample_request ||= OpenStruct.new authorization: %{Token token="#{token}"} + test "token_and_options returns empty string with empty token" do + token = '' + actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first + expected = token + assert_equal(expected, actual) end - def encode_credentials(token, options = {}) - ActionController::HttpAuthentication::Token.encode_credentials(token, options) + test "token_and_options returns nil with no value after the equal sign" do + actual = ActionController::HttpAuthentication::Token.token_and_options(malformed_request).first + expected = nil + assert_equal(expected, actual) end + + private + + def sample_request(token) + @sample_request ||= OpenStruct.new authorization: %{Token token="#{token}", nonce="def"} + end + + def malformed_request + @malformed_request ||= OpenStruct.new authorization: %{Token token=} + end + + def encode_credentials(token, options = {}) + ActionController::HttpAuthentication::Token.encode_credentials(token, options) + end end |