Commit bd6a9133 authored by James Lopez's avatar James Lopez

fix spec

parent d2755c32
...@@ -7,6 +7,7 @@ describe EE::Gitlab::LDAP::UserFilter do ...@@ -7,6 +7,7 @@ describe EE::Gitlab::LDAP::UserFilter do
OmniAuth::AuthHash.new(uid: 'uid=john,ou=people,dc=example,dc=com', provider: 'ldapmain') OmniAuth::AuthHash.new(uid: 'uid=john,ou=people,dc=example,dc=com', provider: 'ldapmain')
end end
let!(:fake_proxy) { fake_ldap_sync_proxy(auth_hash.provider) } let!(:fake_proxy) { fake_ldap_sync_proxy(auth_hash.provider) }
let(:fake_entry) { ldap_user_entry('user1') }
before do before do
stub_ldap_config( stub_ldap_config(
...@@ -19,10 +20,15 @@ describe EE::Gitlab::LDAP::UserFilter do ...@@ -19,10 +20,15 @@ describe EE::Gitlab::LDAP::UserFilter do
it 'returns dns from an LDAP search' do it 'returns dns from an LDAP search' do
filter = '(ou=people)' filter = '(ou=people)'
entry = ldap_group_entry(%w(john mary)) allow(fake_proxy.adapter).to receive(:ldap_search).and_return([fake_entry])
allow(fake_proxy.adapter).to receive(:ldap_search).and_return([entry])
expect(described_class.filter(fake_proxy, filter)).to eq('') expect(described_class.filter(fake_proxy, filter)).to eq(['uid=user1,ou=users,dc=example,dc=com'])
end
it 'errors out with an invalid filter' do
filter = ')('
expect{ described_class.filter(fake_proxy, filter) }.to raise_error(Net::LDAP::FilterSyntaxInvalidError, 'Invalid filter syntax.')
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment