diff options
author | Kurtis Rainbolt-Greene <kurtisrainboltgreene@gmail.com> | 2012-10-07 17:36:01 -0500 |
---|---|---|
committer | Kurtis Rainbolt-Greene <me@kurtisrainboltgreene.name> | 2012-12-15 15:56:42 -0800 |
commit | f71cca9e1007bd928ec6fe27e3b3147ec59afac7 (patch) | |
tree | 806ce0dde8cf3cb4e13e845bba452c9336244fbd /actionpack/test/controller | |
parent | 2d6abcce55c9024e2ef8753ab710b8a053e96eec (diff) | |
download | rails-f71cca9e1007bd928ec6fe27e3b3147ec59afac7.tar.gz rails-f71cca9e1007bd928ec6fe27e3b3147ec59afac7.tar.bz2 rails-f71cca9e1007bd928ec6fe27e3b3147ec59afac7.zip |
Refactoring the token_and_options method to fix bugs
Adding a test for the equal trun bug
Adding a test for the after equal trunc bug
Adding a test for the slash bug
Adding a test for the slash quote bug
Adding a helper method for creating a sample request object with token
Writing a method to create params array from raw params
Writing a method to rewrite param values in the params
Writing a method to get the token params from an authorization value
Refactoring the token_and_options method to fix bugs
Removing unnessecary test
A constant for this shared regex seemed appropriate
Wanting to split up this logic
Adding small documentation pieces
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/http_token_authentication_test.rb | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb index 8a409d6ed2..faf923e929 100644 --- a/actionpack/test/controller/http_token_authentication_test.rb +++ b/actionpack/test/controller/http_token_authentication_test.rb @@ -104,17 +104,40 @@ class HttpTokenAuthenticationTest < ActionController::TestCase assert_equal 'Token realm="SuperSecret"', @response.headers['WWW-Authenticate'] end - test "authentication request with valid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials('"quote" pretty', :algorithm => 'test') - get :display + test "token_and_options returns correct token" do + token = "rcHu+HzSFw89Ypyhn/896A==" + actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first + expected = token + assert_equal(expected, actual) + end + + test "token_and_options returns correct token" do + token = 'rcHu+=HzSFw89Ypyhn/896A==f34' + actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first + expected = token + assert_equal(expected, actual) + end - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body + test "token_and_options returns correct token" do + token = 'rcHu+\\\\"/896A' + actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first + expected = token + assert_equal(expected, actual) + end + + test "token_and_options returns correct token" do + token = '\"quote\" pretty' + actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token)).first + expected = token + assert_equal(expected, actual) end private + def sample_request(token) + @sample_request ||= OpenStruct.new authorization: %{Token token="#{token}"} + end + def encode_credentials(token, options = {}) ActionController::HttpAuthentication::Token.encode_credentials(token, options) end |