2017-06-27 14:02:09 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PasswordsController do
|
2017-08-31 06:21:40 -04:00
|
|
|
describe '#prevent_ldap_reset' do
|
2017-06-27 14:02:09 -04:00
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when password authentication is disabled' do
|
2017-08-31 06:21:40 -04:00
|
|
|
it 'allows password reset' do
|
2017-06-27 14:02:09 -04:00
|
|
|
stub_application_setting(password_authentication_enabled: false)
|
|
|
|
|
|
|
|
post :create
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
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
|
|
|
|
post :create, user: { email: user.email }
|
|
|
|
|
2017-08-31 06:21:40 -04:00
|
|
|
expect(flash[:alert]).to eq('Cannot reset password for LDAP user.')
|
2017-06-27 14:02:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|