Commit d54133b09fdb0b2e589896dc8740bb8d0c99ed54
1 parent
982d4d51
Exists in
spb-stable
and in
2 other branches
Add spec for LDAP::Access#allowed?
Showing
1 changed file
with
32 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe Gitlab::LDAP::Access do | ||
4 | + let(:access) { Gitlab::LDAP::Access.new } | ||
5 | + let(:user) { create(:user) } | ||
6 | + | ||
7 | + describe :allowed? do | ||
8 | + subject { access.allowed?(user) } | ||
9 | + | ||
10 | + context 'when the user cannot be found' do | ||
11 | + before { Gitlab::LDAP::Person.stub(find_by_dn: nil) } | ||
12 | + | ||
13 | + it { should be_false } | ||
14 | + end | ||
15 | + | ||
16 | + context 'when the user is found' do | ||
17 | + before { Gitlab::LDAP::Person.stub(find_by_dn: :ldap_user) } | ||
18 | + | ||
19 | + context 'and the Active Directory disabled flag is set' do | ||
20 | + before { Gitlab::LDAP::Person.stub(ad_disabled?: true) } | ||
21 | + | ||
22 | + it { should be_false } | ||
23 | + end | ||
24 | + | ||
25 | + context 'and the Active Directory disabled flag is not set' do | ||
26 | + before { Gitlab::LDAP::Person.stub(ad_disabled?: false) } | ||
27 | + | ||
28 | + it { should be_true } | ||
29 | + end | ||
30 | + end | ||
31 | + end | ||
32 | +end |