1 require File.dirname(__FILE__) + '/../test_helper'
3 class UserLoginTest < ActionController::IntegrationTest
6 def test_login_openid_success
8 assert_response :redirect
9 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
11 assert_response :success
12 post '/login', {'user[openid_url]' => "http://localhost:1123/john.doe?openid.success=true", :referer => "/browse"}
13 assert_response :redirect
15 res = openid_request(@response.redirected_to)
16 res2 = post '/login', res
18 assert_response :redirect
20 assert_response :success
21 assert_template 'changeset/list'
24 def test_login_openid_cancel
26 assert_response :redirect
27 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
29 assert_response :success
30 post '/login', {'user[openid_url]' => "http://localhost:1123/john.doe", :referer => "/diary"}
31 assert_response :redirect
33 res = openid_request(@response.redirected_to)
36 assert_response :success
37 assert_template 'login'
40 def test_login_openid_invalid_provider
42 assert_response :redirect
43 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
45 assert_response :success
46 #Use a different port that doesn't have the OpenID provider running on to test an invalid openID
47 post '/login', {'user[openid_url]' => "http://localhost:1124/john.doe", :referer => "/diary"}
48 assert_response :success
49 assert_template 'login'
52 def test_login_openid_invalid_url
54 assert_response :redirect
55 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
57 assert_response :success
58 #Use a url with an invalid protocol to make sure it handles that correctly too
59 post '/login', {'user[openid_url]' => "htt://localhost:1123/john.doe", :referer => "/diary"}
60 assert_response :success
61 assert_template 'login'
64 def test_login_openid_unknown
66 assert_response :redirect
67 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
69 assert_response :success
70 post '/login', {'user[openid_url]' => "http://localhost:1123/john.doe?openid.success=true_somethingelse", :referer => "/diary"}
71 assert_response :redirect
73 res = openid_request(@response.redirected_to)
74 res2 = post '/login', res
76 assert_response :redirect
78 assert_response :success
79 assert_template 'user/new'