diff options
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/http_token_authentication_test.rb | 35 | ||||
-rw-r--r-- | actionpack/test/controller/log_subscriber_test.rb | 32 |
2 files changed, 45 insertions, 22 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 diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 929545fc10..075347be52 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -46,20 +46,20 @@ module Another render :inline => "<%= cache('foo%bar'){ 'Contains % sign in key' } %>" end - def with_fragment_cache_and_if_true_condition - render :inline => "<%= cache('foo', :if => true) { 'bar' } %>" + def with_fragment_cache_if_with_true_condition + render :inline => "<%= cache_if(true, 'foo') { 'bar' } %>" end - def with_fragment_cache_and_if_false_condition - render :inline => "<%= cache('foo', :if => false) { 'bar' } %>" + def with_fragment_cache_if_with_false_condition + render :inline => "<%= cache_if(false, 'foo') { 'bar' } %>" end - def with_fragment_cache_and_unless_false_condition - render :inline => "<%= cache('foo', :unless => false) { 'bar' } %>" + def with_fragment_cache_unless_with_false_condition + render :inline => "<%= cache_unless(false, 'foo') { 'bar' } %>" end - def with_fragment_cache_and_unless_true_condition - render :inline => "<%= cache('foo', :unless => true) { 'bar' } %>" + def with_fragment_cache_unless_with_true_condition + render :inline => "<%= cache_unless(true, 'foo') { 'bar' } %>" end def with_exception @@ -219,9 +219,9 @@ class ACLogSubscriberTest < ActionController::TestCase @controller.config.perform_caching = true end - def test_with_fragment_cache_and_if_true + def test_with_fragment_cache_if_with_true @controller.config.perform_caching = true - get :with_fragment_cache_and_if_true_condition + get :with_fragment_cache_if_with_true_condition wait assert_equal 4, logs.size @@ -231,9 +231,9 @@ class ACLogSubscriberTest < ActionController::TestCase @controller.config.perform_caching = true end - def test_with_fragment_cache_and_if_false + def test_with_fragment_cache_if_with_false @controller.config.perform_caching = true - get :with_fragment_cache_and_if_false_condition + get :with_fragment_cache_if_with_false_condition wait assert_equal 2, logs.size @@ -243,9 +243,9 @@ class ACLogSubscriberTest < ActionController::TestCase @controller.config.perform_caching = true end - def test_with_fragment_cache_and_unless_true + def test_with_fragment_cache_unless_with_true @controller.config.perform_caching = true - get :with_fragment_cache_and_unless_true_condition + get :with_fragment_cache_unless_with_true_condition wait assert_equal 2, logs.size @@ -255,9 +255,9 @@ class ACLogSubscriberTest < ActionController::TestCase @controller.config.perform_caching = true end - def test_with_fragment_cache_and_unless_false + def test_with_fragment_cache_unless_with_false @controller.config.perform_caching = true - get :with_fragment_cache_and_unless_false_condition + get :with_fragment_cache_unless_with_false_condition wait assert_equal 4, logs.size |