X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c9893e186b32bfd8e8ee8f00e78258387f4aac9c..5f495b43d18bfa7a9bcaf918aa4db15261bea46a:/test/integration/user_login_test.rb?ds=sidebyside diff --git a/test/integration/user_login_test.rb b/test/integration/user_login_test.rb index 9cab196f2..a48933cf4 100644 --- a/test/integration/user_login_test.rb +++ b/test/integration/user_login_test.rb @@ -11,6 +11,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest OmniAuth.config.mock_auth[:openid] = nil OmniAuth.config.mock_auth[:google] = nil OmniAuth.config.mock_auth[:facebook] = nil + OmniAuth.config.mock_auth[:windowslive] = nil OmniAuth.config.test_mode = false end @@ -971,9 +972,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest end def test_login_facebook_success - OmniAuth.config.add_mock(:facebook, :uid => "123456789", :extra => { - :id_info => { "openid_id" => "http://localhost:1123/fred.bloggs" } - }) + OmniAuth.config.add_mock(:facebook, :uid => "123456789") get "/login", :referer => "/history" assert_response :redirect @@ -1041,9 +1040,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest end def test_login_facebook_unknown - OmniAuth.config.add_mock(:facebook, :uid => "987654321", :extra => { - :id_info => { "openid_id" => "http://localhost:1123/fred.bloggs" } - }) + OmniAuth.config.add_mock(:facebook, :uid => "987654321") get "/login", :referer => "/history" assert_response :redirect @@ -1061,4 +1058,92 @@ class UserLoginTest < ActionDispatch::IntegrationTest assert_template "user/new" assert_select "span.username", false end + + def test_login_windowslive_success + OmniAuth.config.add_mock(:windowslive, :uid => "123456789") + + get "/login", :referer => "/history" + assert_response :redirect + assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true", "referer" => "/history" + follow_redirect! + assert_response :success + assert_template "user/login" + get auth_path(:provider => "windowslive", :origin => "/login") + assert_response :redirect + assert_redirected_to auth_success_path(:provider => "windowslive") + follow_redirect! + assert_response :redirect + follow_redirect! + assert_response :success + assert_template "changeset/history" + assert_select "span.username", "windowsliveuser" + end + + def test_login_windowslive_connection_failed + OmniAuth.config.mock_auth[:windowslive] = :connection_failed + + get "/login", :referer => "/history" + assert_response :redirect + assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true", "referer" => "/history" + follow_redirect! + assert_response :success + assert_template "user/login" + get auth_path(:provider => "windowslive", :origin => "/login") + assert_response :redirect + assert_redirected_to auth_success_path(:provider => "windowslive") + follow_redirect! + assert_response :redirect + assert_redirected_to auth_failure_path(:strategy => "windowslive", :message => "connection_failed", :origin => "/login") + follow_redirect! + assert_response :redirect + follow_redirect! + assert_response :success + assert_template "login" + assert_select "div.flash.error", "Connection to authentication provider failed" + assert_select "span.username", false + end + + def test_login_windowslive_invalid_credentials + OmniAuth.config.mock_auth[:windowslive] = :invalid_credentials + + get "/login", :referer => "/history" + assert_response :redirect + assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true", "referer" => "/history" + follow_redirect! + assert_response :success + assert_template "user/login" + get auth_path(:provider => "windowslive", :origin => "/login") + assert_response :redirect + assert_redirected_to auth_success_path(:provider => "windowslive") + follow_redirect! + assert_response :redirect + assert_redirected_to auth_failure_path(:strategy => "windowslive", :message => "invalid_credentials", :origin => "/login") + follow_redirect! + assert_response :redirect + follow_redirect! + assert_response :success + assert_template "login" + assert_select "div.flash.error", "Invalid authentication credentials" + assert_select "span.username", false + end + + def test_login_windowslive_unknown + OmniAuth.config.add_mock(:windowslive, :uid => "987654321") + + get "/login", :referer => "/history" + assert_response :redirect + assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true", "referer" => "/history" + follow_redirect! + assert_response :success + assert_template "user/login" + get auth_path(:provider => "windowslive", :origin => "/login") + assert_response :redirect + assert_redirected_to auth_success_path(:provider => "windowslive") + follow_redirect! + assert_response :redirect + follow_redirect! + assert_response :success + assert_template "user/new" + assert_select "span.username", false + end end