diff --git a/spec/lib/gitlab/ldap/ldap_access_spec.rb b/spec/lib/gitlab/ldap/ldap_access_spec.rb new file mode 100644 index 0000000..e76cc4f --- /dev/null +++ b/spec/lib/gitlab/ldap/ldap_access_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Gitlab::LDAP::Access do + let(:access) { Gitlab::LDAP::Access.new } + let(:user) { create(:user) } + + describe :allowed? do + subject { access.allowed?(user) } + + 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 Active Directory disabled flag is set' do + before { Gitlab::LDAP::Person.stub(ad_disabled?: true) } + + it { should be_false } + end + + context 'and the Active Directory disabled flag is not set' do + before { Gitlab::LDAP::Person.stub(ad_disabled?: false) } + + it { should be_true } + end + end + end +end -- libgit2 0.21.2