Add success and failure methods.

This commit is contained in:
Michael Baker 2011-11-30 20:03:02 +00:00
parent 2763040162
commit 40f0e1857e
2 changed files with 16 additions and 8 deletions

View file

@ -128,6 +128,14 @@ class Net::LDAP::PDU
result_code == 0 ? :success : :failure
end
def success?
status == :success
end
def failure?
!success?
end
##
# Return serverSaslCreds, which are only present in BindResponse packets.
#--

View file

@ -7,11 +7,11 @@ describe Net::LDAP::Connection do
flexmock(TCPSocket).
should_receive(:new).and_raise(Errno::ECONNREFUSED)
end
it "should raise LdapError" do
lambda {
Net::LDAP::Connection.new(
:server => 'test.mocked.com',
:server => 'test.mocked.com',
:port => 636)
}.should raise_error(Net::LDAP::LdapError)
end
@ -21,11 +21,11 @@ describe Net::LDAP::Connection do
flexmock(TCPSocket).
should_receive(:new).and_raise(SocketError)
end
it "should raise LdapError" do
lambda {
Net::LDAP::Connection.new(
:server => 'test.mocked.com',
:server => 'test.mocked.com',
:port => 636)
}.should raise_error(Net::LDAP::LdapError)
end
@ -35,11 +35,11 @@ describe Net::LDAP::Connection do
flexmock(TCPSocket).
should_receive(:new).and_raise(NameError)
end
it "should rethrow the exception" do
lambda {
Net::LDAP::Connection.new(
:server => 'test.mocked.com',
:server => 'test.mocked.com',
:port => 636)
}.should raise_error(NameError)
end
@ -61,7 +61,7 @@ describe Net::LDAP::Connection do
@tcp_socket.should_receive(:read_ber).and_return([2, ber])
result = subject.modify(:dn => "1", :operations => [[:replace, "mail", "something@sothsdkf.com"]])
result.status.should == :failure
result.should be_failure
result.error_message.should == "The provided password value was rejected by a password validator: The provided password did not contain enough characters from the character set 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. The minimum number of characters from that set that must be present in user passwords is 1"
end
@ -71,7 +71,7 @@ describe Net::LDAP::Connection do
@tcp_socket.should_receive(:read_ber).and_return([2, ber])
result = subject.modify(:dn => "1", :operations => [[:replace, "mail", "something@sothsdkf.com"]])
result.status.should == :success
result.should be_success
result.error_message.should == ""
end
end