summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-05-14 18:11:14 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-05-14 18:11:14 +0200
commit982d4d51e8110bec280eb00db0fb756b062103d9 (patch)
treeaf82769b180392c9613d6cdac6b500ec47fd6085 /spec
parentf4bca105d16e3bc47c2cd2725c519d2dcd788e70 (diff)
downloadgitlab-ce-982d4d51e8110bec280eb00db0fb756b062103d9.tar.gz
Backport Adapter#dn_matches_filter? from EE
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ldap/ldap_adapter_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ldap/ldap_adapter_spec.rb b/spec/lib/gitlab/ldap/ldap_adapter_spec.rb
new file mode 100644
index 00000000000..c3f07334431
--- /dev/null
+++ b/spec/lib/gitlab/ldap/ldap_adapter_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe Gitlab::LDAP::Adapter do
+ let(:adapter) { Gitlab::LDAP::Adapter.new }
+
+ describe :dn_matches_filter? do
+ let(:ldap) { double(:ldap) }
+ subject { adapter.dn_matches_filter?(:dn, :filter) }
+ before { adapter.stub(ldap: ldap) }
+
+ context "when the search is successful" do
+ context "and the result is non-empty" do
+ before { ldap.stub(search: [:foo]) }
+
+ it { should be_true }
+ end
+
+ context "and the result is empty" do
+ before { ldap.stub(search: []) }
+
+ it { should be_false }
+ end
+ end
+
+ context "when the search encounters an error" do
+ before { ldap.stub(search: nil, get_operation_result: double(code: 1, message: 'some error')) }
+
+ it { should be_false }
+ end
+ end
+end