gitlab-org--gitlab-foss/spec/lib/gitlab/ldap/access_spec.rb

41 lines
1.1 KiB
Ruby
Raw Normal View History

2014-05-14 16:14:06 +00:00
require 'spec_helper'
describe Gitlab::LDAP::Access do
let(:access) { Gitlab::LDAP::Access.new user }
2014-12-04 11:43:08 +00:00
let(:user) { create(:omniauth_user) }
2014-05-14 16:14:06 +00:00
describe :allowed? do
subject { access.allowed? }
2014-05-14 16:14:06 +00:00
context 'when the user cannot be found' do
before { Gitlab::LDAP::Person.stub(find_by_dn: nil) }
it { should be_false }
end
context 'when the user is found' do
before { Gitlab::LDAP::Person.stub(find_by_dn: :ldap_user) }
context 'and the user is diabled via active directory' do
before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: true) }
2014-05-14 16:14:06 +00:00
it { should be_false }
end
context 'and has no disabled flag in active diretory' do
before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false) }
2014-05-14 16:14:06 +00:00
it { should be_true }
end
context 'without ActiveDirectory enabled' do
before do
Gitlab::LDAP::Config.stub(enabled?: true)
Gitlab::LDAP::Config.any_instance.stub(active_directory: false)
end
it { should be_true }
end
2014-05-14 16:14:06 +00:00
end
end
end