Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/auth_helper_spec.rb')
-rw-r--r--spec/helpers/auth_helper_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/helpers/auth_helper_spec.rb b/spec/helpers/auth_helper_spec.rb
index 1764a2bbc3c..23f3449d9a7 100644
--- a/spec/helpers/auth_helper_spec.rb
+++ b/spec/helpers/auth_helper_spec.rb
@@ -184,4 +184,40 @@ describe AuthHelper do
end
end
end
+
+ describe '#allow_admin_mode_password_authentication_for_web?' do
+ let(:user) { create(:user) }
+
+ subject { helper.allow_admin_mode_password_authentication_for_web? }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
+ it { is_expected.to be(true) }
+
+ context 'when password authentication for web is disabled' do
+ before do
+ stub_application_setting(password_authentication_enabled_for_web: false)
+ end
+
+ it { is_expected.to be(false) }
+ end
+
+ context 'when current_user is an ldap user' do
+ before do
+ allow(user).to receive(:ldap_user?).and_return(true)
+ end
+
+ it { is_expected.to be(false) }
+ end
+
+ context 'when user got password automatically set' do
+ before do
+ user.update_attribute(:password_automatically_set, true)
+ end
+
+ it { is_expected.to be(false) }
+ end
+ end
end