1 require File.dirname(__FILE__) + '/../test_helper'
3 class UserLoginTest < ActionController::IntegrationTest
10 def test_login_openid_success
12 assert_response :redirect
13 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
15 assert_response :success
16 post '/login', {'openid_url' => "http://localhost:1123/john.doe?openid.success=true", :referer => "/browse"}
17 assert_response :redirect
19 res = openid_request(@response.redirected_to)
20 res2 = post '/login', res
22 assert_response :redirect
24 assert_response :success
25 assert_template 'changeset/list'
28 def test_login_openid_cancel
30 assert_response :redirect
31 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
33 assert_response :success
34 post '/login', {'openid_url' => "http://localhost:1123/john.doe", :referer => "/diary"}
35 assert_response :redirect
37 res = openid_request(@response.redirected_to)
40 assert_response :redirect
42 assert_response :success
43 assert_template 'login'
46 def test_login_openid_invalid_provider
48 assert_response :redirect
49 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
51 assert_response :success
52 #Use a different port that doesn't have the OpenID provider running on to test an invalid openID
53 post '/login', {'openid_url' => "http://localhost:1124/john.doe", :referer => "/diary"}
54 assert_response :redirect
56 assert_response :success
57 assert_template 'login'
60 def test_login_openid_invalid_url
62 assert_response :redirect
63 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
65 assert_response :success
66 #Use a url with an invalid protocol to make sure it handles that correctly too
67 post '/login', {'openid_url' => "htt://localhost:1123/john.doe", :referer => "/diary"}
68 assert_response :redirect
70 assert_response :success
71 assert_template 'login'
74 def test_login_openid_unknown
76 assert_response :redirect
77 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
79 assert_response :success
80 post '/login', {'openid_url' => "http://localhost:1123/john.doe?openid.success=true_somethingelse", :referer => "/diary"}
81 assert_response :redirect
83 res = openid_request(@response.redirected_to)
84 res2 = post '/login', res
86 assert_response :redirect
88 assert_response :success
89 assert_template 'user/new'