Commit d24e68a66ac59f69ac2493006c9be77762d58cf4
1 parent
f9e8687d
Exists in
master
and in
2 other branches
Fixed test bugs and add new headers
Showing
2 changed files
with
5 additions
and
9 deletions
Show diff stats
lib/omniauth/strategies/remote_user.rb
... | ... | @@ -8,15 +8,11 @@ module OmniAuth |
8 | 8 | |
9 | 9 | def call(env) |
10 | 10 | request = Rack::Request.new env |
11 | - cookies = request.cookies | |
12 | - response = Rack::Response.new | |
13 | - | |
14 | - if cookies['gitlab_session'] != nil and !env['HTTP_REMOTE_USER'].blank? | |
15 | - response.redirect "#{OmniAuth.config.path_prefix}/users/auth/env/" | |
16 | - else | |
11 | + cookies = request.cookies["_gitlab_session"] | |
12 | + remote_user = env["HTTP_REMOTE_USER"] | |
13 | + unless remote_user.empty? && cookies.empty? | |
17 | 14 | super(env) |
18 | 15 | end |
19 | - | |
20 | 16 | end |
21 | 17 | |
22 | 18 | def request_phase | ... | ... |
spec/omniauth/strategies/remote_user_spec.rb
... | ... | @@ -5,12 +5,12 @@ describe 'Test Strategy Remote_User' do |
5 | 5 | Rack::Builder.new do |b| |
6 | 6 | b.use Rack::Session::Cookie, :secret => 'abc123' |
7 | 7 | b.use OmniAuth::Strategies::RemoteUser, :fields => [:name, :email], :uid_field => :name |
8 | - b.run lambda { |_env| [200, {}, ['Not Found']] } | |
8 | + b.run lambda { |_env| [200, {}, ['Not Found']] } | |
9 | 9 | end.to_app |
10 | 10 | end |
11 | 11 | |
12 | 12 | context 'request phase' do |
13 | - before(:each) { get '/user/auth/env' } | |
13 | + before(:each) { get '/user/auth/env',{},{'HTTP_COOKIE' => '_gitlab_session=user@myuser','HTTP_REMOTE_USER' => "user@myuser" }} | |
14 | 14 | it 'displays a form' do |
15 | 15 | expect(last_response.status).to eq(200) |
16 | 16 | end | ... | ... |