diff options
author | Kartikey Tanna <tannakartikey@gmail.com> | 2019-06-18 16:18:14 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-06-18 16:18:14 +0000 |
commit | 53af3e6b9e6fd221f2b6da1f6029017cf4a23831 (patch) | |
tree | e8d9bc09eb215b0a2b8fcb4a0a4f4aaedff23557 /spec | |
parent | c8f18c50a8e3bf9de66552be46ecd093c65572a7 (diff) | |
download | gitlab-ce-53af3e6b9e6fd221f2b6da1f6029017cf4a23831.tar.gz |
#57815 Password authentication disabled for UltraAuth users
Disabled password authentication for the users registered using
omniauth-ultraauth strategy
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 32 |
2 files changed, 39 insertions, 0 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 40669ec5451..447a12b2fac 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -289,6 +289,13 @@ describe ApplicationController do expect(subject).to be_truthy end + + it 'returns true if user has signed up using omniauth-ultraauth' do + user = create(:omniauth_user, provider: 'ultraauth') + allow(controller).to receive(:current_user).and_return(user) + + expect(subject).to be_truthy + end end describe '#two_factor_grace_period' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c95bbb0b3f5..b098fe3c9f4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1769,6 +1769,26 @@ describe User do end end + describe '#ultraauth_user?' do + it 'is true if provider is ultraauth' do + user = create(:omniauth_user, provider: 'ultraauth') + + expect(user.ultraauth_user?).to be_truthy + end + + it 'is false with othe provider' do + user = create(:omniauth_user, provider: 'not-ultraauth') + + expect(user.ultraauth_user?).to be_falsey + end + + it 'is false if no extern_uid is provided' do + user = create(:omniauth_user, extern_uid: nil) + + expect(user.ldap_user?).to be_falsey + end + end + describe '#full_website_url' do let(:user) { create(:user) } @@ -2807,6 +2827,12 @@ describe User do expect(user.allow_password_authentication_for_web?).to be_falsey end + + it 'returns false for ultraauth user' do + user = create(:omniauth_user, provider: 'ultraauth') + + expect(user.allow_password_authentication_for_web?).to be_falsey + end end describe '#allow_password_authentication_for_git?' do @@ -2829,6 +2855,12 @@ describe User do expect(user.allow_password_authentication_for_git?).to be_falsey end + + it 'returns false for ultraauth user' do + user = create(:omniauth_user, provider: 'ultraauth') + + expect(user.allow_password_authentication_for_git?).to be_falsey + end end describe '#assigned_open_merge_requests_count' do |