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', {'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', {'openid_url' => "http://localhost:1123/john.doe", :referer => "/diary"}
31 assert_response :redirect
33 res = openid_request(@response.redirected_to)
36 assert_response :redirect
38 assert_response :success
39 assert_template 'login'
42 def test_login_openid_invalid_provider
44 assert_response :redirect
45 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
47 assert_response :success
48 #Use a different port that doesn't have the OpenID provider running on to test an invalid openID
49 post '/login', {'openid_url' => "http://localhost:1124/john.doe", :referer => "/diary"}
50 assert_response :redirect
52 assert_response :success
53 assert_template 'login'
56 def test_login_openid_invalid_url
58 assert_response :redirect
59 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
61 assert_response :success
62 #Use a url with an invalid protocol to make sure it handles that correctly too
63 post '/login', {'openid_url' => "htt://localhost:1123/john.doe", :referer => "/diary"}
64 assert_response :redirect
66 assert_response :success
67 assert_template 'login'
70 def test_login_openid_unknown
72 assert_response :redirect
73 assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
75 assert_response :success
76 post '/login', {'openid_url' => "http://localhost:1123/john.doe?openid.success=true_somethingelse", :referer => "/diary"}
77 assert_response :redirect
79 res = openid_request(@response.redirected_to)
80 res2 = post '/login', res
82 assert_response :redirect
84 assert_response :success
85 assert_template 'user/new'