Commit a157fa3fb3c10ca784073c087ea28b3235fb29b7
1 parent
a59e035b
Exists in
master
and in
2 other branches
Fixed test for logout instead login
Showing
2 changed files
with
14 additions
and
16 deletions
Show diff stats
spec/omniauth/strategies/remote_user_spec.rb
| ... | ... | @@ -23,12 +23,12 @@ describe 'Test Strategy Remote_User' do |
| 23 | 23 | |
| 24 | 24 | context 'Without REMOTE_USER and logged in' do |
| 25 | 25 | before(:each){ |
| 26 | - clear_cookies | |
| 26 | + clear_cookies | |
| 27 | 27 | set_cookie "_gitlab_session=test" |
| 28 | 28 | set_cookie "_remote_user=test" |
| 29 | 29 | get '/', {}, {} |
| 30 | 30 | } |
| 31 | - | |
| 31 | + | |
| 32 | 32 | it 'Logout curreent user' do |
| 33 | 33 | cookie_session_str = "_gitlab_session=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000" << |
| 34 | 34 | "\n_remote_user=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000" |
| ... | ... | @@ -45,49 +45,48 @@ describe 'Test Strategy Remote_User' do |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | it 'logs REMOTE_USER in' do |
| 48 | - expect(last_response.status).to eq(302) | |
| 48 | + expect(last_response.status).to eq(302) | |
| 49 | 49 | expect(last_response['Set-Cookie']).to eq('_remote_user=foobar') |
| 50 | 50 | end |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | context 'With REMOTE_USER, logged in and current user equals REMOTE_USER' do |
| 54 | 54 | before(:each){ |
| 55 | - clear_cookies | |
| 55 | + clear_cookies | |
| 56 | 56 | set_cookie "_gitlab_session=foobar" |
| 57 | 57 | set_cookie "_remote_user=foobar" |
| 58 | 58 | get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | it 'Do nothing' do |
| 62 | - cookie_session_str = "_gitlab_session=foobar\n_remote_user=foobar" | |
| 63 | 62 | expect(last_request.cookies['_gitlab_session']).to eq('foobar') |
| 64 | 63 | expect(last_request.cookies['_remote_user']).to eq('foobar') |
| 65 | - expect(last_response.status).to eq(200) | |
| 66 | - expect(last_response['Set-Cookie']).to eq(nil) | |
| 64 | + expect(last_response.status).to eq(200) | |
| 65 | + expect(last_response['Set-Cookie']).to eq(nil) | |
| 67 | 66 | end |
| 68 | 67 | end |
| 69 | 68 | |
| 70 | 69 | context 'With REMOTE_USER, logged in and current user not equals REMOTE_USER' do |
| 71 | 70 | before(:each){ |
| 72 | - clear_cookies | |
| 71 | + clear_cookies | |
| 73 | 72 | set_cookie "_gitlab_session=foobar" |
| 74 | 73 | set_cookie "_remote_user=foobar" |
| 75 | 74 | get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar2' } |
| 76 | 75 | } |
| 77 | 76 | |
| 78 | - it 'Logout current user and login REMOTE_USER' do | |
| 77 | + it 'Logout current user and login REMOTE_USER and no have _gitlab_session' do | |
| 79 | 78 | expect(last_request.cookies['_gitlab_session']).to eq('foobar') |
| 80 | 79 | expect(last_request.cookies['_remote_user']).to eq('foobar') |
| 81 | - expect(last_response.status).to eq(302) | |
| 82 | - expect(last_response['Set-Cookie']).to eq('_remote_user=foobar2') | |
| 80 | + expect(last_response.status).to eq(302) | |
| 81 | + expect(last_response['Set-Cookie']).to include('_gitlab_session=') | |
| 83 | 82 | end |
| 84 | 83 | end |
| 85 | 84 | |
| 86 | 85 | context 'Verify omniauth hash with REMOTE_USER_DATA' do |
| 87 | 86 | before(:each){ |
| 88 | 87 | clear_cookies |
| 89 | - post '/auth/remoteuser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar', | |
| 90 | - 'HTTP_REMOTE_USER_DATA' => JSON.dump({'name' => 'foobar', 'email' => 'foobar@test.com'})} | |
| 88 | + post '/auth/remoteuser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar', | |
| 89 | + 'HTTP_REMOTE_USER_DATA' => JSON.dump({'name' => 'foobar', 'email' => 'foobar@test.com'})} | |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | 92 | it 'Verify uid' do |
| ... | ... | @@ -103,7 +102,7 @@ describe 'Test Strategy Remote_User' do |
| 103 | 102 | context 'Verify omniauth.auth info without REMOTE_USER_DATA' do |
| 104 | 103 | before(:each){ |
| 105 | 104 | clear_cookies |
| 106 | - post '/auth/remoteuser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | |
| 105 | + post '/auth/remoteuser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | |
| 107 | 106 | } |
| 108 | 107 | |
| 109 | 108 | it 'Verify uid' do |
| ... | ... | @@ -115,4 +114,3 @@ describe 'Test Strategy Remote_User' do |
| 115 | 114 | end |
| 116 | 115 | end |
| 117 | 116 | end |
| 118 | - | ... | ... |
spec/spec_helper.rb