Commit a790fbd0 authored by Michael Kozono's avatar Michael Kozono

Stub proxy for specs

parent d41098b9
...@@ -15,11 +15,10 @@ describe Gitlab::LDAP::User do ...@@ -15,11 +15,10 @@ describe Gitlab::LDAP::User do
let(:auth_hash) do let(:auth_hash) do
OmniAuth::AuthHash.new(uid: 'uid=john,ou=people,dc=example,dc=com', provider: 'ldapmain', info: info) OmniAuth::AuthHash.new(uid: 'uid=john,ou=people,dc=example,dc=com', provider: 'ldapmain', info: info)
end end
let(:adapter) { ldap_adapter }
let(:group_cn) { 'foo' } let(:group_cn) { 'foo' }
let(:group_member_dns) { [auth_hash.uid] } let(:group_member_dns) { [auth_hash.uid] }
let(:external_groups) { [] } let(:external_groups) { [] }
let(:fake_proxy) { double(:proxy, adapter: adapter) } let!(:fake_proxy) { fake_ldap_sync_proxy(auth_hash.provider) }
before do before do
allow(fake_proxy).to receive(:dns_for_group_cn).with(group_cn).and_return(group_member_dns) allow(fake_proxy).to receive(:dns_for_group_cn).with(group_cn).and_return(group_member_dns)
...@@ -31,10 +30,6 @@ describe Gitlab::LDAP::User do ...@@ -31,10 +30,6 @@ describe Gitlab::LDAP::User do
end end
describe '#initialize' do describe '#initialize' do
before do
expect(::EE::Gitlab::LDAP::Sync::Proxy).to receive(:open).with(auth_hash.provider).and_yield(fake_proxy)
end
context 'when the user is in an external group' do context 'when the user is in an external group' do
let(:external_groups) { [group_cn] } let(:external_groups) { [group_cn] }
......
...@@ -26,6 +26,7 @@ describe Gitlab::LDAP::User do ...@@ -26,6 +26,7 @@ describe Gitlab::LDAP::User do
let(:auth_hash_upper_case) do let(:auth_hash_upper_case) do
OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info_upper_case) OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info_upper_case)
end end
let!(:fake_proxy) { fake_ldap_sync_proxy('ldapmain') }
describe '#changed?' do describe '#changed?' do
it "marks existing ldap user as changed" do it "marks existing ldap user as changed" do
......
...@@ -5,6 +5,12 @@ module LdapHelpers ...@@ -5,6 +5,12 @@ module LdapHelpers
::Gitlab::LDAP::Adapter.new(provider, ldap) ::Gitlab::LDAP::Adapter.new(provider, ldap)
end end
def fake_ldap_sync_proxy(provider)
fake_proxy = double(:proxy, adapter: ldap_adapter)
allow(::EE::Gitlab::LDAP::Sync::Proxy).to receive(:open).with(provider).and_yield(fake_proxy)
fake_proxy
end
def user_dn(uid) def user_dn(uid)
"uid=#{uid},ou=users,dc=example,dc=com" "uid=#{uid},ou=users,dc=example,dc=com"
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