Commit 869246d0 authored by Blair Lunceford's avatar Blair Lunceford

Apply suggested changes

- Add additional test
- Rename variable in auto_link_user? setting
parent 686b1dd9
...@@ -273,11 +273,11 @@ module Gitlab ...@@ -273,11 +273,11 @@ module Gitlab
end end
def auto_link_user? def auto_link_user?
providers = Gitlab.config.omniauth.auto_link_user auto_link = Gitlab.config.omniauth.auto_link_user
if providers.is_a?(Array) if auto_link.is_a?(Array)
providers.include?(auth_hash.provider) auto_link.include?(auth_hash.provider)
else else
providers auto_link
end end
end end
end end
......
...@@ -207,8 +207,20 @@ RSpec.describe Gitlab::Auth::OAuth::User do ...@@ -207,8 +207,20 @@ RSpec.describe Gitlab::Auth::OAuth::User do
stub_omniauth_config(auto_link_user: ['saml']) stub_omniauth_config(auto_link_user: ['saml'])
end end
context "and a current GitLab user with a matching email" do
let!(:existing_user) { create(:user, email: 'john@mail.com', username: 'john') }
it "adds the OmniAuth identity to the GitLab user account" do
oauth_user.save
expect(gl_user).not_to be_valid
end
end
context "and no current GitLab user with a matching email" do
include_examples "to verify compliance with allow_single_sign_on" include_examples "to verify compliance with allow_single_sign_on"
end end
end
context "with auto_link_user enabled for the correct provider" do context "with auto_link_user enabled for the correct provider" do
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment