diff options
author | Lourens Naude <lourens@methodmissing.com> | 2008-12-18 11:33:53 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-12-18 11:33:53 -0600 |
commit | 3ff6b00ee30d0961f57e3c4b64ec8ff0155aaf2d (patch) | |
tree | e8adf40ecf077c4216ee36bcf9cc20f5ef071952 /actionpack/test/controller/session | |
parent | 33f76bb25a973a4707437064e2f963c521413fcb (diff) | |
download | rails-3ff6b00ee30d0961f57e3c4b64ec8ff0155aaf2d.tar.gz rails-3ff6b00ee30d0961f57e3c4b64ec8ff0155aaf2d.tar.bz2 rails-3ff6b00ee30d0961f57e3c4b64ec8ff0155aaf2d.zip |
Persistent session identifier support for CookieSessionStore and API compat. with the server side stores [#1591 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/test/controller/session')
-rw-r--r-- | actionpack/test/controller/session/cookie_store_test.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/actionpack/test/controller/session/cookie_store_test.rb b/actionpack/test/controller/session/cookie_store_test.rb index 8098059d46..ad8ff09884 100644 --- a/actionpack/test/controller/session/cookie_store_test.rb +++ b/actionpack/test/controller/session/cookie_store_test.rb @@ -9,6 +9,8 @@ class CookieStoreTest < ActionController::IntegrationTest CookieStoreApp = ActionController::Session::CookieStore.new(DispatcherApp, :key => SessionKey, :secret => SessionSecret) + Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1') + SignedBar = "BAh7BjoIZm9vIghiYXI%3D--" + "fef868465920f415f2c0652d6910d3af288a0367" @@ -17,9 +19,13 @@ class CookieStoreTest < ActionController::IntegrationTest head :ok end + def persistent_session_id + render :text => session[:session_id] + end + def set_session_value session[:foo] = "bar" - head :ok + render :text => Marshal.dump(session.to_hash) end def get_session_value @@ -83,7 +89,8 @@ class CookieStoreTest < ActionController::IntegrationTest with_test_route_set do get '/set_session_value' assert_response :success - assert_equal ["_myapp_session=#{SignedBar}; path=/"], + session_payload = Verifier.generate( Marshal.load(response.body) ) + assert_equal ["_myapp_session=#{session_payload}; path=/"], headers['Set-Cookie'] end end @@ -132,6 +139,21 @@ class CookieStoreTest < ActionController::IntegrationTest end end + def test_persistent_session_id + with_test_route_set do + cookies[SessionKey] = SignedBar + get '/persistent_session_id' + assert_response :success + assert_equal response.body.size, 32 + session_id = response.body + get '/persistent_session_id' + assert_equal session_id, response.body + reset! + get '/persistent_session_id' + assert_not_equal session_id, response.body + end + end + private def with_test_route_set with_routing do |set| |