@@ -61,6 +61,13 class AccountControllerTest < ActionController::TestCase | |||||
61 | assert_error_tag :content => /Something wrong/ |
|
61 | assert_error_tag :content => /Something wrong/ | |
62 | end |
|
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 | if Object.const_defined?(:OpenID) |
|
71 | if Object.const_defined?(:OpenID) | |
65 |
|
72 | |||
66 | def test_login_with_openid_for_existing_user |
|
73 | def test_login_with_openid_for_existing_user | |
@@ -171,6 +178,14 class AccountControllerTest < ActionController::TestCase | |||||
171 | assert_nil @request.session[:user_id] |
|
178 | assert_nil @request.session[:user_id] | |
172 | end |
|
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 | def test_get_register_with_registration_on |
|
189 | def test_get_register_with_registration_on | |
175 | with_settings :self_registration => '3' do |
|
190 | with_settings :self_registration => '3' do | |
176 | get :register |
|
191 | get :register |
@@ -179,22 +179,4 class AccountTest < ActionController::IntegrationTest | |||||
179 | assert_equal 66, user.auth_source_id |
|
179 | assert_equal 66, user.auth_source_id | |
180 | assert user.hashed_password.blank? |
|
180 | assert user.hashed_password.blank? | |
181 | end |
|
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 | end |
|
182 | end |
General Comments 0
You need to be logged in to leave comments.
Login now