Skip to content

Commit 5e9b735

Browse files
committed
Spec out Net::LDAP#search instrumentation
1 parent bcf2505 commit 5e9b735

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

spec/unit/ldap_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
subject do
1414
Net::LDAP.new \
1515
:server => "test.mocked.com", :port => 636,
16+
:force_no_page => true, # so server capabilities are not queried
1617
:instrumentation_service => @service
1718
end
1819

@@ -28,6 +29,22 @@
2829
result.should be_true
2930
payload[:bind].should == bind_result
3031
end
32+
33+
it "should instrument search" do
34+
events = @service.subscribe "search.net_ldap"
35+
36+
@connection.should_receive(:bind).and_return(flexmock(:bind_result, :result_code => 0))
37+
@connection.should_receive(:search).with(Hash, Proc).
38+
yields(entry = Net::LDAP::Entry.new("uid=user1,ou=users,dc=example,dc=com")).
39+
and_return(flexmock(:search_result, :success? => true, :result_code => 0))
40+
41+
subject.search(:filter => "(uid=user1)").should be_true
42+
43+
payload, result = events.pop
44+
result.should == [entry]
45+
payload[:result].should == [entry]
46+
payload[:filter].should == "(uid=user1)"
47+
end
3148
end
3249
end
3350
end

0 commit comments

Comments
 (0)