3 class UserSessionsApiTest < ActionDispatch::IntegrationTest
4 test 'create new user during omniauth callback' do
6 'provider' => 'josh_id',
7 'uid' => 'https://edward.example.com',
9 'identity_url' => 'https://edward.example.com',
10 'name' => 'Edward Example',
11 'first_name' => 'Edward',
12 'last_name' => 'Example',
13 'email' => 'edward@example.com',
16 client_url = 'https://wb.example.com'
17 post('/auth/josh_id/callback',
18 {return_to: client_url},
19 {'omniauth.auth' => mock})
20 assert_response :redirect, 'Did not redirect to client with token'
21 assert_equal(0, @response.redirect_url.index(client_url),
22 'Redirected to wrong address after succesful login: was ' +
23 @response.redirect_url + ', expected ' + client_url + '[...]')
24 assert_not_nil(@response.redirect_url.index('api_token='),
25 'Expected api_token in query string of redirect url ' +
26 @response.redirect_url)