-
Notifications
You must be signed in to change notification settings - Fork 252
/
Copy pathtest_return_codes.rb
46 lines (36 loc) · 1.76 KB
/
test_return_codes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require_relative '../test_helper'
# NOTE: These tests depend on the OpenLDAP retcode overlay.
# See: section 12.12 http://www.openldap.org/doc/admin24/overlays.html
class TestReturnCodeIntegration < LDAPIntegrationTestCase
def test_open_error
@ldap.authenticate "cn=fake", "creds"
@ldap.open do
result = @ldap.get_operation_result
assert_equal Net::LDAP::ResultCodeInvalidCredentials, result.code
end
end
def test_operations_error
refute @ldap.search(filter: "cn=operationsError", base: "ou=Retcodes,dc=example,dc=org")
assert result = @ldap.get_operation_result
assert_equal Net::LDAP::ResultCodeOperationsError, result.code
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeOperationsError], result.message
end
def test_protocol_error
refute @ldap.search(filter: "cn=protocolError", base: "ou=Retcodes,dc=example,dc=org")
assert result = @ldap.get_operation_result
assert_equal Net::LDAP::ResultCodeProtocolError, result.code
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeProtocolError], result.message
end
def test_time_limit_exceeded
assert @ldap.search(filter: "cn=timeLimitExceeded", base: "ou=Retcodes,dc=example,dc=org")
assert result = @ldap.get_operation_result
assert_equal Net::LDAP::ResultCodeTimeLimitExceeded, result.code
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeTimeLimitExceeded], result.message
end
def test_size_limit_exceeded
assert @ldap.search(filter: "cn=sizeLimitExceeded", base: "ou=Retcodes,dc=example,dc=org")
assert result = @ldap.get_operation_result
assert_equal Net::LDAP::ResultCodeSizeLimitExceeded, result.code
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeSizeLimitExceeded], result.message
end
end