Commit c32fed8db6c90930cf3d3435112fbc2d16ca8550

Authored by Lucas Kanashiro
1 parent 616c4761

Parcial suite test

Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Showing 1 changed file with 39 additions and 8 deletions   Show diff stats
spec/omniauth/strategies/remote_user_spec.rb
@@ -10,30 +10,61 @@ describe &#39;Test Strategy Remote_User&#39; do @@ -10,30 +10,61 @@ describe &#39;Test Strategy Remote_User&#39; do
10 end 10 end
11 11
12 context 'Without REMOTE_USER and not logged in' do 12 context 'Without REMOTE_USER and not logged in' do
13 - before(:each){get '/', {}, {}} 13 + before(:each){
  14 + get '/', {}, {}
  15 + }
14 16
15 it 'Do nothing' do 17 it 'Do nothing' do
16 - last_response.status.should == 200  
17 - last_response.cookies['_remote_user'] == nil 18 + expect(last_response.status).to eq(200)
  19 + expect(last_request.cookies['_remote_user']).to eq(nil)
  20 + expect(last_request.cookies['_gitlab_session']).to eq(nil)
18 end 21 end
19 end 22 end
20 23
21 context 'Without REMOTE_USER and logged in' do 24 context 'Without REMOTE_USER and logged in' do
22 - #Logout current user 25 + before(:each){
  26 + clear_cookies
  27 + set_cookie "_gitlab_session=test"
  28 + set_cookie "_remote_user=test"
  29 + get '/', {}, {}
  30 + }
23 31
24 - 32 + it 'Logout curreent user' do
  33 + cookie_session_str = "_gitlab_session=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000" <<
  34 + "\n_remote_user=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000"
  35 + expect(last_request.cookies['_gitlab_session']).to eq('test')
  36 + expect(last_request.cookies['_remote_user']).to eq('test')
  37 + expect(last_response.status).to eq(302)
  38 + expect(last_response['Set-Cookie']).to eq(cookie_session_str)
  39 + end
25 end 40 end
26 41
27 context 'With REMOTE_USER and not logged in' do 42 context 'With REMOTE_USER and not logged in' do
28 - #Login REMOTE_USER  
29 - it 'logs user in' do 43 + before(:each){
30 get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' } 44 get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' }
  45 + }
  46 +
  47 + it 'logs REMOTE_USER in' do
  48 + expect(last_response.status).to eq(302)
  49 + expect(last_response['Set-Cookie']).to eq('_remote_user=foobar')
31 end 50 end
32 end 51 end
33 52
34 context 'With REMOTE_USER, logged in and current user equals REMOTE_USER' do 53 context 'With REMOTE_USER, logged in and current user equals REMOTE_USER' do
35 - #do nothing 54 + before(:each){
  55 + clear_cookies
  56 + set_cookie "_gitlab_session=foobar"
  57 + set_cookie "_remote_user=foobar"
  58 + get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' }
  59 + }
36 60
  61 + it 'Do nothing' do
  62 + cookie_session_str = "_gitlab_session=foobar\n_remote_user=foobar"
  63 + expect(last_request.cookies['_gitlab_session']).to eq('foobar')
  64 + 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)
  67 + end
37 end 68 end
38 69
39 context 'With REMOTE_USER, logged in and current user not equals REMOTE_USER' do 70 context 'With REMOTE_USER, logged in and current user not equals REMOTE_USER' do