@@ -61,6 +61,13 class AccountControllerTest < ActionController::TestCase | |||
|
61 | 61 | assert_error_tag :content => /Something wrong/ |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | def test_login_should_reset_session | |
|
65 | @controller.expects(:reset_session).once | |
|
66 | ||
|
67 | post :login, :username => 'jsmith', :password => 'jsmith' | |
|
68 | assert_response 302 | |
|
69 | end | |
|
70 | ||
|
64 | 71 | if Object.const_defined?(:OpenID) |
|
65 | 72 | |
|
66 | 73 | def test_login_with_openid_for_existing_user |
@@ -171,6 +178,14 class AccountControllerTest < ActionController::TestCase | |||
|
171 | 178 | assert_nil @request.session[:user_id] |
|
172 | 179 | end |
|
173 | 180 | |
|
181 | def test_logout_should_reset_session | |
|
182 | @controller.expects(:reset_session).once | |
|
183 | ||
|
184 | @request.session[:user_id] = 2 | |
|
185 | get :logout | |
|
186 | assert_response 302 | |
|
187 | end | |
|
188 | ||
|
174 | 189 | def test_get_register_with_registration_on |
|
175 | 190 | with_settings :self_registration => '3' do |
|
176 | 191 | get :register |
@@ -179,22 +179,4 class AccountTest < ActionController::IntegrationTest | |||
|
179 | 179 | assert_equal 66, user.auth_source_id |
|
180 | 180 | assert user.hashed_password.blank? |
|
181 | 181 | end |
|
182 | ||
|
183 | def test_login_and_logout_should_clear_session | |
|
184 | get '/login' | |
|
185 | sid = session[:session_id] | |
|
186 | ||
|
187 | post '/login', :username => 'admin', :password => 'admin' | |
|
188 | assert_redirected_to '/my/page' | |
|
189 | assert_not_equal sid, session[:session_id], "login should reset session" | |
|
190 | assert_equal 1, session[:user_id] | |
|
191 | sid = session[:session_id] | |
|
192 | ||
|
193 | get '/' | |
|
194 | assert_equal sid, session[:session_id] | |
|
195 | ||
|
196 | get '/logout' | |
|
197 | assert_not_equal sid, session[:session_id], "logout should reset session" | |
|
198 | assert_nil session[:user_id] | |
|
199 | end | |
|
200 | 182 | end |
General Comments 0
You need to be logged in to leave comments.
Login now