2017-06-27 14:02:09 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PasswordsController do
|
2017-11-23 08:16:14 -05:00
|
|
|
describe '#check_password_authentication_available' do
|
2017-06-27 14:02:09 -04:00
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
|
|
|
end
|
|
|
|
|
2017-11-23 08:16:14 -05:00
|
|
|
context 'when password authentication is disabled for the web interface and Git' do
|
|
|
|
it 'prevents a password reset' do
|
|
|
|
stub_application_setting(password_authentication_enabled_for_web: false)
|
|
|
|
stub_application_setting(password_authentication_enabled_for_git: false)
|
2017-06-27 14:02:09 -04:00
|
|
|
|
|
|
|
post :create
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-11-23 08:16:14 -05:00
|
|
|
expect(flash[:alert]).to eq 'Password authentication is unavailable.'
|
2017-06-27 14:02:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when reset email belongs to an ldap user' do
|
|
|
|
let(:user) { create(:omniauth_user, provider: 'ldapmain', email: 'ldapuser@gitlab.com') }
|
|
|
|
|
|
|
|
it 'prevents a password reset' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :create, params: { user: { email: user.email } }
|
2017-06-27 14:02:09 -04:00
|
|
|
|
2017-11-23 08:16:14 -05:00
|
|
|
expect(flash[:alert]).to eq 'Password authentication is unavailable.'
|
2017-06-27 14:02:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|