net-ldap 0.16.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +23 -1
- data/History.rdoc +7 -0
- data/README.rdoc +8 -3
- data/lib/net/ldap.rb +1 -1
- data/lib/net/ldap/connection.rb +4 -0
- data/lib/net/ldap/filter.rb +8 -1
- data/lib/net/ldap/version.rb +1 -1
- data/script/ldap-docker +12 -0
- data/test/fixtures/ca/docker-ca.pem +18 -0
- data/test/fixtures/{openldap/retcode.ldif → ldif/06-retcode.ldif} +7 -8
- data/test/fixtures/ldif/50-seed.ldif +374 -0
- data/test/integration/test_add.rb +1 -3
- data/test/integration/test_ber.rb +1 -1
- data/test/integration/test_bind.rb +12 -34
- data/test/integration/test_delete.rb +1 -3
- data/test/integration/test_open.rb +10 -11
- data/test/integration/test_password_modify.rb +10 -10
- data/test/integration/test_return_codes.rb +12 -4
- data/test/integration/test_search.rb +8 -8
- data/test/test_helper.rb +5 -6
- metadata +27 -41
- data/script/generate-fixture-ca +0 -48
- data/script/install-openldap +0 -134
- data/test/fixtures/ca/ca.info +0 -4
- data/test/fixtures/ca/cacert.pem +0 -24
- data/test/fixtures/ca/cakey.pem +0 -190
- data/test/fixtures/openldap/memberof.ldif +0 -33
- data/test/fixtures/openldap/slapd.conf.ldif +0 -67
- data/test/fixtures/seed.ldif +0 -374
- data/test/support/vm/openldap/README.md +0 -64
- data/test/support/vm/openldap/Vagrantfile +0 -34
@@ -3,9 +3,7 @@ require_relative '../test_helper'
|
|
3
3
|
class TestAddIntegration < LDAPIntegrationTestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
|
-
@
|
7
|
-
|
8
|
-
@dn = "uid=added-user1,ou=People,dc=rubyldap,dc=com"
|
6
|
+
@dn = "uid=added-user1,ou=People,dc=example,dc=org"
|
9
7
|
end
|
10
8
|
|
11
9
|
def test_add
|
@@ -1,13 +1,17 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
class TestBindIntegration < LDAPIntegrationTestCase
|
4
|
+
|
5
|
+
INTEGRATION_HOSTNAME = 'ldap.example.org'.freeze
|
6
|
+
|
4
7
|
def test_bind_success
|
5
8
|
assert @ldap.bind(BIND_CREDS),
|
6
9
|
@ldap.get_operation_result.inspect
|
7
10
|
end
|
8
11
|
|
9
12
|
def test_bind_timeout
|
10
|
-
@ldap.
|
13
|
+
@ldap.host = "10.255.255.1" # non-routable IP
|
14
|
+
|
11
15
|
error = assert_raise Net::LDAP::Error do
|
12
16
|
@ldap.bind BIND_CREDS
|
13
17
|
end
|
@@ -34,6 +38,7 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
34
38
|
end
|
35
39
|
|
36
40
|
def test_bind_tls_with_cafile
|
41
|
+
@ldap.host = INTEGRATION_HOSTNAME
|
37
42
|
@ldap.encryption(
|
38
43
|
method: :start_tls,
|
39
44
|
tls_options: TLS_OPTS.merge(ca_file: CA_FILE),
|
@@ -43,7 +48,7 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
43
48
|
end
|
44
49
|
|
45
50
|
def test_bind_tls_with_bad_hostname_verify_none_no_ca_passes
|
46
|
-
@ldap.host =
|
51
|
+
@ldap.host = INTEGRATION_HOSTNAME
|
47
52
|
@ldap.encryption(
|
48
53
|
method: :start_tls,
|
49
54
|
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_NONE },
|
@@ -112,7 +117,7 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
112
117
|
end
|
113
118
|
|
114
119
|
def test_bind_tls_with_valid_hostname_default_opts_passes
|
115
|
-
@ldap.host =
|
120
|
+
@ldap.host = INTEGRATION_HOSTNAME
|
116
121
|
@ldap.encryption(
|
117
122
|
method: :start_tls,
|
118
123
|
tls_options: TLS_OPTS.merge(verify_mode: OpenSSL::SSL::VERIFY_PEER,
|
@@ -123,7 +128,7 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
123
128
|
end
|
124
129
|
|
125
130
|
def test_bind_tls_with_valid_hostname_just_verify_peer_ca_passes
|
126
|
-
@ldap.host =
|
131
|
+
@ldap.host = INTEGRATION_HOSTNAME
|
127
132
|
@ldap.encryption(
|
128
133
|
method: :start_tls,
|
129
134
|
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_PEER,
|
@@ -146,13 +151,9 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
146
151
|
)
|
147
152
|
end
|
148
153
|
|
149
|
-
# The following depend on /etc/hosts hacking.
|
150
|
-
# We can do that on CI, but it's less than cool on people's dev boxes
|
151
154
|
def test_bind_tls_with_multiple_hosts
|
152
|
-
omit_unless ENV['TRAVIS'] == 'true'
|
153
|
-
|
154
155
|
@ldap.host = nil
|
155
|
-
@ldap.hosts = [[
|
156
|
+
@ldap.hosts = [[INTEGRATION_HOSTNAME, 389], [INTEGRATION_HOSTNAME, 389]]
|
156
157
|
@ldap.encryption(
|
157
158
|
method: :start_tls,
|
158
159
|
tls_options: TLS_OPTS.merge(verify_mode: OpenSSL::SSL::VERIFY_PEER,
|
@@ -163,8 +164,6 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
163
164
|
end
|
164
165
|
|
165
166
|
def test_bind_tls_with_multiple_bogus_hosts
|
166
|
-
omit_unless ENV['TRAVIS'] == 'true'
|
167
|
-
|
168
167
|
@ldap.host = nil
|
169
168
|
@ldap.hosts = [['127.0.0.1', 389], ['bogus.example.com', 389]]
|
170
169
|
@ldap.encryption(
|
@@ -181,8 +180,6 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
181
180
|
end
|
182
181
|
|
183
182
|
def test_bind_tls_with_multiple_bogus_hosts_no_verification
|
184
|
-
omit_unless ENV['TRAVIS'] == 'true'
|
185
|
-
|
186
183
|
@ldap.host = nil
|
187
184
|
@ldap.hosts = [['127.0.0.1', 389], ['bogus.example.com', 389]]
|
188
185
|
@ldap.encryption(
|
@@ -194,8 +191,6 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
194
191
|
end
|
195
192
|
|
196
193
|
def test_bind_tls_with_multiple_bogus_hosts_ca_check_only_fails
|
197
|
-
omit_unless ENV['TRAVIS'] == 'true'
|
198
|
-
|
199
194
|
@ldap.host = nil
|
200
195
|
@ldap.hosts = [['127.0.0.1', 389], ['bogus.example.com', 389]]
|
201
196
|
@ldap.encryption(
|
@@ -213,8 +208,10 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
213
208
|
# This test is CI-only because we can't add the fixture CA
|
214
209
|
# to the system CA store on people's dev boxes.
|
215
210
|
def test_bind_tls_valid_hostname_system_ca_on_travis_passes
|
211
|
+
omit "not sure how to install custom CA cert in travis"
|
216
212
|
omit_unless ENV['TRAVIS'] == 'true'
|
217
213
|
|
214
|
+
@ldap.host = INTEGRATION_HOSTNAME
|
218
215
|
@ldap.encryption(
|
219
216
|
method: :start_tls,
|
220
217
|
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_PEER },
|
@@ -222,23 +219,4 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
222
219
|
assert @ldap.bind(BIND_CREDS),
|
223
220
|
@ldap.get_operation_result.inspect
|
224
221
|
end
|
225
|
-
|
226
|
-
# Inverse of the above! Don't run this on Travis, only on Vagrant.
|
227
|
-
# Since Vagrant's hypervisor *won't* have the CA in the system
|
228
|
-
# x509 store, we can assume validation will fail
|
229
|
-
def test_bind_tls_valid_hostname_system_on_vagrant_fails
|
230
|
-
omit_if ENV['TRAVIS'] == 'true'
|
231
|
-
|
232
|
-
@ldap.encryption(
|
233
|
-
method: :start_tls,
|
234
|
-
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_PEER },
|
235
|
-
)
|
236
|
-
error = assert_raise Net::LDAP::Error do
|
237
|
-
@ldap.bind BIND_CREDS
|
238
|
-
end
|
239
|
-
assert_equal(
|
240
|
-
"SSL_connect returned=1 errno=0 state=error: certificate verify failed",
|
241
|
-
error.message,
|
242
|
-
)
|
243
|
-
end
|
244
222
|
end
|
@@ -3,9 +3,7 @@ require_relative '../test_helper'
|
|
3
3
|
class TestDeleteIntegration < LDAPIntegrationTestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
|
-
@
|
7
|
-
|
8
|
-
@dn = "uid=delete-user1,ou=People,dc=rubyldap,dc=com"
|
6
|
+
@dn = "uid=delete-user1,ou=People,dc=example,dc=org"
|
9
7
|
|
10
8
|
attrs = {
|
11
9
|
objectclass: %w(top inetOrgPerson organizationalPerson person),
|
@@ -4,8 +4,8 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
4
4
|
def test_binds_without_open
|
5
5
|
events = @service.subscribe "bind.net_ldap_connection"
|
6
6
|
|
7
|
-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=
|
8
|
-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=
|
7
|
+
@ldap.search(filter: "uid=user1", base: "ou=People,dc=example,dc=org", ignore_server_caps: true)
|
8
|
+
@ldap.search(filter: "uid=user1", base: "ou=People,dc=example,dc=org", ignore_server_caps: true)
|
9
9
|
|
10
10
|
assert_equal 2, events.size
|
11
11
|
end
|
@@ -14,8 +14,8 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
14
14
|
events = @service.subscribe "bind.net_ldap_connection"
|
15
15
|
|
16
16
|
@ldap.open do
|
17
|
-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=
|
18
|
-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=
|
17
|
+
@ldap.search(filter: "uid=user1", base: "ou=People,dc=example,dc=org", ignore_server_caps: true)
|
18
|
+
@ldap.search(filter: "uid=user1", base: "ou=People,dc=example,dc=org", ignore_server_caps: true)
|
19
19
|
end
|
20
20
|
|
21
21
|
assert_equal 1, events.size
|
@@ -29,9 +29,9 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
29
29
|
entries = []
|
30
30
|
nested_entry = nil
|
31
31
|
|
32
|
-
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=
|
32
|
+
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=example,dc=org") do |entry|
|
33
33
|
entries << entry.uid.first
|
34
|
-
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=
|
34
|
+
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=example,dc=org").first
|
35
35
|
end
|
36
36
|
|
37
37
|
assert_equal "user3", nested_entry.uid.first
|
@@ -43,9 +43,9 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
43
43
|
nested_entry = nil
|
44
44
|
|
45
45
|
@ldap.open do
|
46
|
-
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=
|
46
|
+
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=example,dc=org") do |entry|
|
47
47
|
entries << entry.uid.first
|
48
|
-
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=
|
48
|
+
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=example,dc=org").first
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -57,7 +57,7 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
57
57
|
entries = []
|
58
58
|
nested_entry = nil
|
59
59
|
|
60
|
-
dn = "uid=nested-open-added-user1,ou=People,dc=
|
60
|
+
dn = "uid=nested-open-added-user1,ou=People,dc=example,dc=org"
|
61
61
|
attrs = {
|
62
62
|
objectclass: %w(top inetOrgPerson organizationalPerson person),
|
63
63
|
uid: "nested-open-added-user1",
|
@@ -66,11 +66,10 @@ class TestBindIntegration < LDAPIntegrationTestCase
|
|
66
66
|
mail: "nested-open-added-user1@rubyldap.com",
|
67
67
|
}
|
68
68
|
|
69
|
-
@ldap.authenticate "cn=admin,dc=rubyldap,dc=com", "passworD1"
|
70
69
|
@ldap.delete dn: dn
|
71
70
|
|
72
71
|
@ldap.open do
|
73
|
-
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=
|
72
|
+
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=example,dc=org") do |entry|
|
74
73
|
entries << entry.uid.first
|
75
74
|
|
76
75
|
nested_entry ||= begin
|
@@ -3,10 +3,10 @@ require_relative '../test_helper'
|
|
3
3
|
class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
|
-
@admin_account = {dn: 'cn=admin,dc=
|
6
|
+
@admin_account = {dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple}
|
7
7
|
@ldap.authenticate @admin_account[:dn], @admin_account[:password]
|
8
8
|
|
9
|
-
@dn = 'uid=modify-password-user1,ou=People,dc=
|
9
|
+
@dn = 'uid=modify-password-user1,ou=People,dc=example,dc=org'
|
10
10
|
|
11
11
|
attrs = {
|
12
12
|
objectclass: %w(top inetOrgPerson organizationalPerson person),
|
@@ -14,7 +14,7 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
14
14
|
cn: 'modify-password-user1',
|
15
15
|
sn: 'modify-password-user1',
|
16
16
|
mail: 'modify-password-user1@rubyldap.com',
|
17
|
-
userPassword: '
|
17
|
+
userPassword: 'admin',
|
18
18
|
}
|
19
19
|
unless @ldap.search(base: @dn, scope: Net::LDAP::SearchScope_BaseObject)
|
20
20
|
assert @ldap.add(dn: @dn, attributes: attrs), @ldap.get_operation_result.inspect
|
@@ -24,20 +24,20 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
24
24
|
@auth = {
|
25
25
|
method: :simple,
|
26
26
|
username: @dn,
|
27
|
-
password: '
|
27
|
+
password: 'admin',
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_password_modify
|
32
32
|
assert @ldap.password_modify(dn: @dn,
|
33
33
|
auth: @auth,
|
34
|
-
old_password: '
|
34
|
+
old_password: 'admin',
|
35
35
|
new_password: 'passworD2')
|
36
36
|
|
37
37
|
assert @ldap.get_operation_result.extended_response.nil?,
|
38
38
|
'Should not have generated a new password'
|
39
39
|
|
40
|
-
refute @ldap.bind(username: @dn, password: '
|
40
|
+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
41
41
|
'Old password should no longer be valid'
|
42
42
|
|
43
43
|
assert @ldap.bind(username: @dn, password: 'passworD2', method: :simple),
|
@@ -47,13 +47,13 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
47
47
|
def test_password_modify_generate
|
48
48
|
assert @ldap.password_modify(dn: @dn,
|
49
49
|
auth: @auth,
|
50
|
-
old_password: '
|
50
|
+
old_password: 'admin')
|
51
51
|
|
52
52
|
generated_password = @ldap.get_operation_result.extended_response[0][0]
|
53
53
|
|
54
54
|
assert generated_password, 'Should have generated a password'
|
55
55
|
|
56
|
-
refute @ldap.bind(username: @dn, password: '
|
56
|
+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
57
57
|
'Old password should no longer be valid'
|
58
58
|
|
59
59
|
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
|
@@ -68,7 +68,7 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
68
68
|
|
69
69
|
assert generated_password, 'Should have generated a password'
|
70
70
|
|
71
|
-
refute @ldap.bind(username: @dn, password: '
|
71
|
+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
72
72
|
'Old password should no longer be valid'
|
73
73
|
|
74
74
|
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
|
@@ -80,7 +80,7 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase
|
|
80
80
|
auth: @admin_account,
|
81
81
|
new_password: 'passworD3')
|
82
82
|
|
83
|
-
refute @ldap.bind(username: @dn, password: '
|
83
|
+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
|
84
84
|
'Old password should no longer be valid'
|
85
85
|
|
86
86
|
assert @ldap.bind(username: @dn, password: 'passworD3', method: :simple),
|
@@ -4,8 +4,16 @@ require_relative '../test_helper'
|
|
4
4
|
# See: section 12.12 http://www.openldap.org/doc/admin24/overlays.html
|
5
5
|
|
6
6
|
class TestReturnCodeIntegration < LDAPIntegrationTestCase
|
7
|
+
def test_open_error
|
8
|
+
@ldap.authenticate "cn=fake", "creds"
|
9
|
+
@ldap.open do
|
10
|
+
result = @ldap.get_operation_result
|
11
|
+
assert_equal Net::LDAP::ResultCodeInvalidCredentials, result.code
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
def test_operations_error
|
8
|
-
refute @ldap.search(filter: "cn=operationsError", base: "ou=Retcodes,dc=
|
16
|
+
refute @ldap.search(filter: "cn=operationsError", base: "ou=Retcodes,dc=example,dc=org")
|
9
17
|
assert result = @ldap.get_operation_result
|
10
18
|
|
11
19
|
assert_equal Net::LDAP::ResultCodeOperationsError, result.code
|
@@ -13,7 +21,7 @@ class TestReturnCodeIntegration < LDAPIntegrationTestCase
|
|
13
21
|
end
|
14
22
|
|
15
23
|
def test_protocol_error
|
16
|
-
refute @ldap.search(filter: "cn=protocolError", base: "ou=Retcodes,dc=
|
24
|
+
refute @ldap.search(filter: "cn=protocolError", base: "ou=Retcodes,dc=example,dc=org")
|
17
25
|
assert result = @ldap.get_operation_result
|
18
26
|
|
19
27
|
assert_equal Net::LDAP::ResultCodeProtocolError, result.code
|
@@ -21,7 +29,7 @@ class TestReturnCodeIntegration < LDAPIntegrationTestCase
|
|
21
29
|
end
|
22
30
|
|
23
31
|
def test_time_limit_exceeded
|
24
|
-
assert @ldap.search(filter: "cn=timeLimitExceeded", base: "ou=Retcodes,dc=
|
32
|
+
assert @ldap.search(filter: "cn=timeLimitExceeded", base: "ou=Retcodes,dc=example,dc=org")
|
25
33
|
assert result = @ldap.get_operation_result
|
26
34
|
|
27
35
|
assert_equal Net::LDAP::ResultCodeTimeLimitExceeded, result.code
|
@@ -29,7 +37,7 @@ class TestReturnCodeIntegration < LDAPIntegrationTestCase
|
|
29
37
|
end
|
30
38
|
|
31
39
|
def test_size_limit_exceeded
|
32
|
-
assert @ldap.search(filter: "cn=sizeLimitExceeded", base: "ou=Retcodes,dc=
|
40
|
+
assert @ldap.search(filter: "cn=sizeLimitExceeded", base: "ou=Retcodes,dc=example,dc=org")
|
33
41
|
assert result = @ldap.get_operation_result
|
34
42
|
|
35
43
|
assert_equal Net::LDAP::ResultCodeSizeLimitExceeded, result.code
|
@@ -4,7 +4,7 @@ class TestSearchIntegration < LDAPIntegrationTestCase
|
|
4
4
|
def test_search
|
5
5
|
entries = []
|
6
6
|
|
7
|
-
result = @ldap.search(base: "dc=
|
7
|
+
result = @ldap.search(base: "dc=example,dc=org") do |entry|
|
8
8
|
assert_kind_of Net::LDAP::Entry, entry
|
9
9
|
entries << entry
|
10
10
|
end
|
@@ -16,7 +16,7 @@ class TestSearchIntegration < LDAPIntegrationTestCase
|
|
16
16
|
def test_search_without_result
|
17
17
|
entries = []
|
18
18
|
|
19
|
-
result = @ldap.search(base: "dc=
|
19
|
+
result = @ldap.search(base: "dc=example,dc=org", return_result: false) do |entry|
|
20
20
|
assert_kind_of Net::LDAP::Entry, entry
|
21
21
|
entries << entry
|
22
22
|
end
|
@@ -26,24 +26,24 @@ class TestSearchIntegration < LDAPIntegrationTestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_search_filter_string
|
29
|
-
entries = @ldap.search(base: "dc=
|
29
|
+
entries = @ldap.search(base: "dc=example,dc=org", filter: "(uid=user1)")
|
30
30
|
assert_equal 1, entries.size
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_search_filter_object
|
34
34
|
filter = Net::LDAP::Filter.eq("uid", "user1") | Net::LDAP::Filter.eq("uid", "user2")
|
35
|
-
entries = @ldap.search(base: "dc=
|
35
|
+
entries = @ldap.search(base: "dc=example,dc=org", filter: filter)
|
36
36
|
assert_equal 2, entries.size
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_search_constrained_attributes
|
40
|
-
entry = @ldap.search(base: "uid=user1,ou=People,dc=
|
40
|
+
entry = @ldap.search(base: "uid=user1,ou=People,dc=example,dc=org", attributes: ["cn", "sn"]).first
|
41
41
|
assert_equal [:cn, :dn, :sn], entry.attribute_names.sort # :dn is always included
|
42
42
|
assert_empty entry[:mail]
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_search_attributes_only
|
46
|
-
entry = @ldap.search(base: "uid=user1,ou=People,dc=
|
46
|
+
entry = @ldap.search(base: "uid=user1,ou=People,dc=example,dc=org", attributes_only: true).first
|
47
47
|
|
48
48
|
assert_empty entry[:cn], "unexpected attribute value: #{entry[:cn]}"
|
49
49
|
end
|
@@ -52,7 +52,7 @@ class TestSearchIntegration < LDAPIntegrationTestCase
|
|
52
52
|
entries = []
|
53
53
|
events = @service.subscribe "search.net_ldap_connection"
|
54
54
|
|
55
|
-
result = @ldap.search(base: "dc=
|
55
|
+
result = @ldap.search(base: "dc=example,dc=org", time: 5) do |entry|
|
56
56
|
assert_kind_of Net::LDAP::Entry, entry
|
57
57
|
entries << entry
|
58
58
|
end
|
@@ -66,7 +66,7 @@ class TestSearchIntegration < LDAPIntegrationTestCase
|
|
66
66
|
def test_search_with_size
|
67
67
|
entries = []
|
68
68
|
|
69
|
-
result = @ldap.search(base: "dc=
|
69
|
+
result = @ldap.search(base: "dc=example,dc=org", size: 1) do |entry|
|
70
70
|
assert_kind_of Net::LDAP::Entry, entry
|
71
71
|
entries << entry
|
72
72
|
end
|
data/test/test_helper.rb
CHANGED
@@ -14,14 +14,14 @@ CA_FILE =
|
|
14
14
|
if File.exist?("/etc/ssl/certs/cacert.pem")
|
15
15
|
"/etc/ssl/certs/cacert.pem"
|
16
16
|
else
|
17
|
-
File.expand_path("fixtures/ca/
|
17
|
+
File.expand_path("fixtures/ca/docker-ca.pem", File.dirname(__FILE__))
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
BIND_CREDS = {
|
22
22
|
method: :simple,
|
23
|
-
username: "
|
24
|
-
password: "
|
23
|
+
username: "cn=admin,dc=example,dc=org",
|
24
|
+
password: "admin",
|
25
25
|
}.freeze
|
26
26
|
|
27
27
|
TLS_OPTS = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.merge({}).freeze
|
@@ -65,10 +65,9 @@ class LDAPIntegrationTestCase < Test::Unit::TestCase
|
|
65
65
|
@ldap = Net::LDAP.new \
|
66
66
|
host: ENV.fetch('INTEGRATION_HOST', 'localhost'),
|
67
67
|
port: ENV.fetch('INTEGRATION_PORT', 389),
|
68
|
-
|
69
|
-
admin_password: 'passworD1',
|
70
|
-
search_domains: %w(dc=rubyldap,dc=com),
|
68
|
+
search_domains: %w(dc=example,dc=org),
|
71
69
|
uid: 'uid',
|
72
70
|
instrumentation_service: @service
|
71
|
+
@ldap.authenticate "cn=admin,dc=example,dc=org", "admin"
|
73
72
|
end
|
74
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Cianfrocca
|
@@ -13,76 +13,76 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: flexmock
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - ~>
|
22
|
+
- - "~>"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '1.3'
|
25
25
|
type: :development
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- - ~>
|
29
|
+
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: '1.3'
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: rake
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- - ~>
|
36
|
+
- - "~>"
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '10.0'
|
39
39
|
type: :development
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- - ~>
|
43
|
+
- - "~>"
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '10.0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rubocop
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - ~>
|
50
|
+
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.42.0
|
53
53
|
type: :development
|
54
54
|
prerelease: false
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - ~>
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: 0.42.0
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: test-unit
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- -
|
64
|
+
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- -
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
- !ruby/object:Gem::Dependency
|
75
75
|
name: byebug
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
description: |-
|
@@ -112,10 +112,10 @@ extra_rdoc_files:
|
|
112
112
|
- License.rdoc
|
113
113
|
- README.rdoc
|
114
114
|
files:
|
115
|
-
- .gitignore
|
116
|
-
- .rubocop.yml
|
117
|
-
- .rubocop_todo.yml
|
118
|
-
- .travis.yml
|
115
|
+
- ".gitignore"
|
116
|
+
- ".rubocop.yml"
|
117
|
+
- ".rubocop_todo.yml"
|
118
|
+
- ".travis.yml"
|
119
119
|
- CONTRIBUTING.md
|
120
120
|
- Contributors.rdoc
|
121
121
|
- Gemfile
|
@@ -151,20 +151,15 @@ files:
|
|
151
151
|
- lib/net/snmp.rb
|
152
152
|
- net-ldap.gemspec
|
153
153
|
- script/changelog
|
154
|
-
- script/
|
155
|
-
- script/install-openldap
|
154
|
+
- script/ldap-docker
|
156
155
|
- script/package
|
157
156
|
- script/release
|
158
157
|
- test/ber/core_ext/test_array.rb
|
159
158
|
- test/ber/core_ext/test_string.rb
|
160
159
|
- test/ber/test_ber.rb
|
161
|
-
- test/fixtures/ca/ca.
|
162
|
-
- test/fixtures/
|
163
|
-
- test/fixtures/
|
164
|
-
- test/fixtures/openldap/memberof.ldif
|
165
|
-
- test/fixtures/openldap/retcode.ldif
|
166
|
-
- test/fixtures/openldap/slapd.conf.ldif
|
167
|
-
- test/fixtures/seed.ldif
|
160
|
+
- test/fixtures/ca/docker-ca.pem
|
161
|
+
- test/fixtures/ldif/06-retcode.ldif
|
162
|
+
- test/fixtures/ldif/50-seed.ldif
|
168
163
|
- test/integration/test_add.rb
|
169
164
|
- test/integration/test_ber.rb
|
170
165
|
- test/integration/test_bind.rb
|
@@ -174,8 +169,6 @@ files:
|
|
174
169
|
- test/integration/test_return_codes.rb
|
175
170
|
- test/integration/test_search.rb
|
176
171
|
- test/support/vm/openldap/.gitignore
|
177
|
-
- test/support/vm/openldap/README.md
|
178
|
-
- test/support/vm/openldap/Vagrantfile
|
179
172
|
- test/test_auth_adapter.rb
|
180
173
|
- test/test_dn.rb
|
181
174
|
- test/test_entry.rb
|
@@ -199,23 +192,22 @@ licenses:
|
|
199
192
|
metadata: {}
|
200
193
|
post_install_message:
|
201
194
|
rdoc_options:
|
202
|
-
- --main
|
195
|
+
- "--main"
|
203
196
|
- README.rdoc
|
204
197
|
require_paths:
|
205
198
|
- lib
|
206
199
|
required_ruby_version: !ruby/object:Gem::Requirement
|
207
200
|
requirements:
|
208
|
-
- -
|
201
|
+
- - ">="
|
209
202
|
- !ruby/object:Gem::Version
|
210
203
|
version: 2.0.0
|
211
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
205
|
requirements:
|
213
|
-
- -
|
206
|
+
- - ">="
|
214
207
|
- !ruby/object:Gem::Version
|
215
208
|
version: '0'
|
216
209
|
requirements: []
|
217
|
-
|
218
|
-
rubygems_version: 2.0.14.1
|
210
|
+
rubygems_version: 3.0.1
|
219
211
|
signing_key:
|
220
212
|
specification_version: 4
|
221
213
|
summary: Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
@@ -225,13 +217,9 @@ test_files:
|
|
225
217
|
- test/ber/core_ext/test_array.rb
|
226
218
|
- test/ber/core_ext/test_string.rb
|
227
219
|
- test/ber/test_ber.rb
|
228
|
-
- test/fixtures/ca/ca.
|
229
|
-
- test/fixtures/
|
230
|
-
- test/fixtures/
|
231
|
-
- test/fixtures/openldap/memberof.ldif
|
232
|
-
- test/fixtures/openldap/retcode.ldif
|
233
|
-
- test/fixtures/openldap/slapd.conf.ldif
|
234
|
-
- test/fixtures/seed.ldif
|
220
|
+
- test/fixtures/ca/docker-ca.pem
|
221
|
+
- test/fixtures/ldif/06-retcode.ldif
|
222
|
+
- test/fixtures/ldif/50-seed.ldif
|
235
223
|
- test/integration/test_add.rb
|
236
224
|
- test/integration/test_ber.rb
|
237
225
|
- test/integration/test_bind.rb
|
@@ -241,8 +229,6 @@ test_files:
|
|
241
229
|
- test/integration/test_return_codes.rb
|
242
230
|
- test/integration/test_search.rb
|
243
231
|
- test/support/vm/openldap/.gitignore
|
244
|
-
- test/support/vm/openldap/README.md
|
245
|
-
- test/support/vm/openldap/Vagrantfile
|
246
232
|
- test/test_auth_adapter.rb
|
247
233
|
- test/test_dn.rb
|
248
234
|
- test/test_entry.rb
|