diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-02-08 11:28:53 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-02-11 01:54:17 -0800 |
commit | ba6861d032013416034cdb20012962b97460795f (patch) | |
tree | dd33bfc4ac00d77b6a77a2e594ef7cf910fb8679 /actionpack/test/dispatch | |
parent | 6de4888e0485d50c7d5e3b97a485e126b561ef6c (diff) | |
download | rails-ba6861d032013416034cdb20012962b97460795f.tar.gz rails-ba6861d032013416034cdb20012962b97460795f.tar.bz2 rails-ba6861d032013416034cdb20012962b97460795f.zip |
Changed the tests to ensure HybridSerializer actually migrates the cookies (currently failing)
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/cookies_test.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb index 4da19933f0..0c3d3d687c 100644 --- a/actionpack/test/dispatch/cookies_test.rb +++ b/actionpack/test/dispatch/cookies_test.rb @@ -399,20 +399,24 @@ class CookiesTest < ActionController::TestCase assert_equal '45 was dumped and loaded', cookies.signed[:user_id] end - def test_signed_cookie_using_hybrid_serializer_can_read_from_marshal_dumped_value + def test_signed_cookie_using_hybrid_serializer_can_migrate_marshal_dumped_value_to_json @request.env["action_dispatch.cookies_serializer"] = :hybrid key_generator = @request.env["action_dispatch.key_generator"] signed_cookie_salt = @request.env["action_dispatch.signed_cookie_salt"] secret = key_generator.generate_key(signed_cookie_salt) - legacy_value = ActiveSupport::MessageVerifier.new(secret, serializer: Marshal).generate(45) - @request.headers["Cookie"] = "user_id=#{legacy_value}" + + marshal_value = ActiveSupport::MessageVerifier.new(secret, serializer: Marshal).generate(45) + @request.headers["Cookie"] = "user_id=#{marshal_value}" get :get_signed_cookie cookies = @controller.send :cookies assert_not_equal 45, cookies[:user_id] assert_equal 45, cookies.signed[:user_id] + + json_value = ActiveSupport::MessageVerifier.new(secret, serializer: JSON).generate(45) + assert_equal @response.cookies['user_id'], json_value end def test_signed_cookie_using_hybrid_serializer_can_read_from_json_dumped_value @@ -421,8 +425,8 @@ class CookiesTest < ActionController::TestCase key_generator = @request.env["action_dispatch.key_generator"] signed_cookie_salt = @request.env["action_dispatch.signed_cookie_salt"] secret = key_generator.generate_key(signed_cookie_salt) - legacy_value = ActiveSupport::MessageVerifier.new(secret, serializer: JSON).generate(45) - @request.headers["Cookie"] = "user_id=#{legacy_value}" + json_value = ActiveSupport::MessageVerifier.new(secret, serializer: JSON).generate(45) + @request.headers["Cookie"] = "user_id=#{json_value}" get :get_signed_cookie @@ -475,7 +479,7 @@ class CookiesTest < ActionController::TestCase assert_equal 'bar was dumped and loaded', cookies.encrypted[:foo] end - def test_encrypted_cookie_using_hybrid_serializer_can_read_from_marshal_dumped_value + def test_encrypted_cookie_using_hybrid_serializer_can_migrate_marshal_dumped_value_to_json @request.env["action_dispatch.cookies_serializer"] = :hybrid key_generator = @request.env["action_dispatch.key_generator"] @@ -483,14 +487,18 @@ class CookiesTest < ActionController::TestCase encrypted_signed_cookie_salt = @request.env["action_dispatch.encrypted_signed_cookie_salt"] secret = key_generator.generate_key(encrypted_cookie_salt) sign_secret = key_generator.generate_key(encrypted_signed_cookie_salt) - legacy_value = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: Marshal).encrypt_and_sign(45) - @request.headers["Cookie"] = "user_id=#{legacy_value}" + + marshal_value = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: Marshal).encrypt_and_sign(45) + @request.headers["Cookie"] = "user_id=#{marshal_value}" get :get_encrypted_cookie cookies = @controller.send :cookies assert_not_equal 45, cookies[:user_id] assert_equal 45, cookies.encrypted[:user_id] + + json_value = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: JSON).encrypt_and_sign(45) + assert_equal @response.cookies["user_id"], json_value end def test_encrypted_cookie_using_hybrid_serializer_can_read_from_json_dumped_value @@ -501,8 +509,8 @@ class CookiesTest < ActionController::TestCase encrypted_signed_cookie_salt = @request.env["action_dispatch.encrypted_signed_cookie_salt"] secret = key_generator.generate_key(encrypted_cookie_salt) sign_secret = key_generator.generate_key(encrypted_signed_cookie_salt) - legacy_value = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: JSON).encrypt_and_sign(45) - @request.headers["Cookie"] = "user_id=#{legacy_value}" + json_value = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: JSON).encrypt_and_sign(45) + @request.headers["Cookie"] = "user_id=#{json_value}" get :get_encrypted_cookie |