- {return_to: client_url},
- {'omniauth.auth' => mock})
- assert_response :redirect, 'Did not redirect to client with token'
+ params: {return_to: client_url(remote: remote)},
+ headers: {'omniauth.auth' => mock})
+
+ errors = {
+ :redirect => 'Did not redirect to client with token',
+ 400 => 'Did not return Bad Request error',
+ }
+ assert_response expected_response, errors[expected_response]
+ end
+
+ test 'assign username from sso' do
+ mock_auth_with(email: 'foo@example.com', username: 'bar')
+ u = assigns(:user)
+ assert_equal 'bar', u.username
+ end
+
+ test 'no assign username from sso' do
+ mock_auth_with(email: 'foo@example.com')
+ u = assigns(:user)
+ assert_equal 'foo', u.username
+ end
+
+ test 'existing user login' do
+ mock_auth_with(identity_url: "https://active-user.openid.local")
+ u = assigns(:user)
+ assert_equal 'zzzzz-tpzed-xurymjxw79nv3jz', u.uuid
+ end
+
+ test 'user redirect_to_user_uuid' do
+ mock_auth_with(identity_url: "https://redirects-to-active-user.openid.local")
+ u = assigns(:user)
+ assert_equal 'zzzzz-tpzed-xurymjxw79nv3jz', u.uuid
+ end
+
+ test 'user double redirect_to_user_uuid' do
+ mock_auth_with(identity_url: "https://double-redirects-to-active-user.openid.local")
+ u = assigns(:user)
+ assert_equal 'zzzzz-tpzed-xurymjxw79nv3jz', u.uuid