Skip to content

Commit 683d660

Browse files
committed
change test DSN and authenticate with the right user
anonymous access is not enabled in this setup, so every test needs to perform authentication first
1 parent 3caf85b commit 683d660

File tree

8 files changed

+39
-45
lines changed

8 files changed

+39
-45
lines changed

test/integration/test_add.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
class TestAddIntegration < LDAPIntegrationTestCase
44
def setup
55
super
6-
@ldap.authenticate "cn=admin,dc=rubyldap,dc=com", "passworD1"
7-
8-
@dn = "uid=added-user1,ou=People,dc=rubyldap,dc=com"
6+
@dn = "uid=added-user1,ou=People,dc=example,dc=org"
97
end
108

119
def test_add

test/integration/test_ber.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_true_ber_encoding
88
attrs = [:dn, :uid, :cn, :mail]
99

1010
assert types_entry = @ldap.search(
11-
base: "dc=rubyldap,dc=com",
11+
base: "dc=example,dc=org",
1212
filter: "(uid=user1)",
1313
size: 1,
1414
attributes: attrs,

test/integration/test_delete.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
class TestDeleteIntegration < LDAPIntegrationTestCase
44
def setup
55
super
6-
@ldap.authenticate "cn=admin,dc=rubyldap,dc=com", "passworD1"
7-
8-
@dn = "uid=delete-user1,ou=People,dc=rubyldap,dc=com"
6+
@dn = "uid=delete-user1,ou=People,dc=example,dc=org"
97

108
attrs = {
119
objectclass: %w(top inetOrgPerson organizationalPerson person),

test/integration/test_open.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class TestBindIntegration < LDAPIntegrationTestCase
44
def test_binds_without_open
55
events = @service.subscribe "bind.net_ldap_connection"
66

7-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true)
8-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true)
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)
99

1010
assert_equal 2, events.size
1111
end
@@ -14,8 +14,8 @@ def test_binds_with_open
1414
events = @service.subscribe "bind.net_ldap_connection"
1515

1616
@ldap.open do
17-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true)
18-
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true)
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)
1919
end
2020

2121
assert_equal 1, events.size
@@ -29,9 +29,9 @@ def test_nested_search_without_open
2929
entries = []
3030
nested_entry = nil
3131

32-
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=rubyldap,dc=com") do |entry|
32+
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=example,dc=org") do |entry|
3333
entries << entry.uid.first
34-
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=rubyldap,dc=com").first
34+
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=example,dc=org").first
3535
end
3636

3737
assert_equal "user3", nested_entry.uid.first
@@ -43,9 +43,9 @@ def test_nested_search_with_open
4343
nested_entry = nil
4444

4545
@ldap.open do
46-
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=rubyldap,dc=com") do |entry|
46+
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=example,dc=org") do |entry|
4747
entries << entry.uid.first
48-
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=rubyldap,dc=com").first
48+
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=example,dc=org").first
4949
end
5050
end
5151

@@ -57,7 +57,7 @@ def test_nested_add_with_open
5757
entries = []
5858
nested_entry = nil
5959

60-
dn = "uid=nested-open-added-user1,ou=People,dc=rubyldap,dc=com"
60+
dn = "uid=nested-open-added-user1,ou=People,dc=example,dc=org"
6161
attrs = {
6262
objectclass: %w(top inetOrgPerson organizationalPerson person),
6363
uid: "nested-open-added-user1",
@@ -66,11 +66,10 @@ def test_nested_add_with_open
6666
6767
}
6868

69-
@ldap.authenticate "cn=admin,dc=rubyldap,dc=com", "passworD1"
7069
@ldap.delete dn: dn
7170

7271
@ldap.open do
73-
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=rubyldap,dc=com") do |entry|
72+
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=example,dc=org") do |entry|
7473
entries << entry.uid.first
7574

7675
nested_entry ||= begin

test/integration/test_password_modify.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
class TestPasswordModifyIntegration < LDAPIntegrationTestCase
44
def setup
55
super
6-
@admin_account = {dn: 'cn=admin,dc=rubyldap,dc=com', password: 'passworD1', method: :simple}
6+
@admin_account = {dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple}
77
@ldap.authenticate @admin_account[:dn], @admin_account[:password]
88

9-
@dn = 'uid=modify-password-user1,ou=People,dc=rubyldap,dc=com'
9+
@dn = 'uid=modify-password-user1,ou=People,dc=example,dc=org'
1010

1111
attrs = {
1212
objectclass: %w(top inetOrgPerson organizationalPerson person),
1313
uid: 'modify-password-user1',
1414
cn: 'modify-password-user1',
1515
sn: 'modify-password-user1',
1616
17-
userPassword: 'passworD1',
17+
userPassword: 'admin',
1818
}
1919
unless @ldap.search(base: @dn, scope: Net::LDAP::SearchScope_BaseObject)
2020
assert @ldap.add(dn: @dn, attributes: attrs), @ldap.get_operation_result.inspect
@@ -24,20 +24,20 @@ def setup
2424
@auth = {
2525
method: :simple,
2626
username: @dn,
27-
password: 'passworD1',
27+
password: 'admin',
2828
}
2929
end
3030

3131
def test_password_modify
3232
assert @ldap.password_modify(dn: @dn,
3333
auth: @auth,
34-
old_password: 'passworD1',
34+
old_password: 'admin',
3535
new_password: 'passworD2')
3636

3737
assert @ldap.get_operation_result.extended_response.nil?,
3838
'Should not have generated a new password'
3939

40-
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple),
40+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
4141
'Old password should no longer be valid'
4242

4343
assert @ldap.bind(username: @dn, password: 'passworD2', method: :simple),
@@ -47,13 +47,13 @@ def test_password_modify
4747
def test_password_modify_generate
4848
assert @ldap.password_modify(dn: @dn,
4949
auth: @auth,
50-
old_password: 'passworD1')
50+
old_password: 'admin')
5151

5252
generated_password = @ldap.get_operation_result.extended_response[0][0]
5353

5454
assert generated_password, 'Should have generated a password'
5555

56-
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple),
56+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
5757
'Old password should no longer be valid'
5858

5959
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
@@ -68,7 +68,7 @@ def test_password_modify_generate_no_old_password
6868

6969
assert generated_password, 'Should have generated a password'
7070

71-
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple),
71+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
7272
'Old password should no longer be valid'
7373

7474
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
@@ -80,7 +80,7 @@ def test_password_modify_overwrite_old_password
8080
auth: @admin_account,
8181
new_password: 'passworD3')
8282

83-
refute @ldap.bind(username: @dn, password: 'passworD1', method: :simple),
83+
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
8484
'Old password should no longer be valid'
8585

8686
assert @ldap.bind(username: @dn, password: 'passworD3', method: :simple),

test/integration/test_return_codes.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55

66
class TestReturnCodeIntegration < LDAPIntegrationTestCase
77
def test_operations_error
8-
refute @ldap.search(filter: "cn=operationsError", base: "ou=Retcodes,dc=rubyldap,dc=com")
8+
refute @ldap.search(filter: "cn=operationsError", base: "ou=Retcodes,dc=example,dc=org")
99
assert result = @ldap.get_operation_result
1010

1111
assert_equal Net::LDAP::ResultCodeOperationsError, result.code
1212
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeOperationsError], result.message
1313
end
1414

1515
def test_protocol_error
16-
refute @ldap.search(filter: "cn=protocolError", base: "ou=Retcodes,dc=rubyldap,dc=com")
16+
refute @ldap.search(filter: "cn=protocolError", base: "ou=Retcodes,dc=example,dc=org")
1717
assert result = @ldap.get_operation_result
1818

1919
assert_equal Net::LDAP::ResultCodeProtocolError, result.code
2020
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeProtocolError], result.message
2121
end
2222

2323
def test_time_limit_exceeded
24-
assert @ldap.search(filter: "cn=timeLimitExceeded", base: "ou=Retcodes,dc=rubyldap,dc=com")
24+
assert @ldap.search(filter: "cn=timeLimitExceeded", base: "ou=Retcodes,dc=example,dc=org")
2525
assert result = @ldap.get_operation_result
2626

2727
assert_equal Net::LDAP::ResultCodeTimeLimitExceeded, result.code
2828
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeTimeLimitExceeded], result.message
2929
end
3030

3131
def test_size_limit_exceeded
32-
assert @ldap.search(filter: "cn=sizeLimitExceeded", base: "ou=Retcodes,dc=rubyldap,dc=com")
32+
assert @ldap.search(filter: "cn=sizeLimitExceeded", base: "ou=Retcodes,dc=example,dc=org")
3333
assert result = @ldap.get_operation_result
3434

3535
assert_equal Net::LDAP::ResultCodeSizeLimitExceeded, result.code

test/integration/test_search.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class TestSearchIntegration < LDAPIntegrationTestCase
44
def test_search
55
entries = []
66

7-
result = @ldap.search(base: "dc=rubyldap,dc=com") do |entry|
7+
result = @ldap.search(base: "dc=example,dc=org") do |entry|
88
assert_kind_of Net::LDAP::Entry, entry
99
entries << entry
1010
end
@@ -16,7 +16,7 @@ def test_search
1616
def test_search_without_result
1717
entries = []
1818

19-
result = @ldap.search(base: "dc=rubyldap,dc=com", return_result: false) do |entry|
19+
result = @ldap.search(base: "dc=example,dc=org", return_result: false) do |entry|
2020
assert_kind_of Net::LDAP::Entry, entry
2121
entries << entry
2222
end
@@ -26,24 +26,24 @@ def test_search_without_result
2626
end
2727

2828
def test_search_filter_string
29-
entries = @ldap.search(base: "dc=rubyldap,dc=com", filter: "(uid=user1)")
29+
entries = @ldap.search(base: "dc=example,dc=org", filter: "(uid=user1)")
3030
assert_equal 1, entries.size
3131
end
3232

3333
def test_search_filter_object
3434
filter = Net::LDAP::Filter.eq("uid", "user1") | Net::LDAP::Filter.eq("uid", "user2")
35-
entries = @ldap.search(base: "dc=rubyldap,dc=com", filter: filter)
35+
entries = @ldap.search(base: "dc=example,dc=org", filter: filter)
3636
assert_equal 2, entries.size
3737
end
3838

3939
def test_search_constrained_attributes
40-
entry = @ldap.search(base: "uid=user1,ou=People,dc=rubyldap,dc=com", attributes: ["cn", "sn"]).first
40+
entry = @ldap.search(base: "uid=user1,ou=People,dc=example,dc=org", attributes: ["cn", "sn"]).first
4141
assert_equal [:cn, :dn, :sn], entry.attribute_names.sort # :dn is always included
4242
assert_empty entry[:mail]
4343
end
4444

4545
def test_search_attributes_only
46-
entry = @ldap.search(base: "uid=user1,ou=People,dc=rubyldap,dc=com", attributes_only: true).first
46+
entry = @ldap.search(base: "uid=user1,ou=People,dc=example,dc=org", attributes_only: true).first
4747

4848
assert_empty entry[:cn], "unexpected attribute value: #{entry[:cn]}"
4949
end
@@ -52,7 +52,7 @@ def test_search_timeout
5252
entries = []
5353
events = @service.subscribe "search.net_ldap_connection"
5454

55-
result = @ldap.search(base: "dc=rubyldap,dc=com", time: 5) do |entry|
55+
result = @ldap.search(base: "dc=example,dc=org", time: 5) do |entry|
5656
assert_kind_of Net::LDAP::Entry, entry
5757
entries << entry
5858
end
@@ -66,7 +66,7 @@ def test_search_timeout
6666
def test_search_with_size
6767
entries = []
6868

69-
result = @ldap.search(base: "dc=rubyldap,dc=com", size: 1) do |entry|
69+
result = @ldap.search(base: "dc=example,dc=org", size: 1) do |entry|
7070
assert_kind_of Net::LDAP::Entry, entry
7171
entries << entry
7272
end

test/test_helper.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
BIND_CREDS = {
2222
method: :simple,
23-
username: "uid=user1,ou=People,dc=rubyldap,dc=com",
24-
password: "passworD1",
23+
username: "cn=admin,dc=example,dc=org",
24+
password: "admin",
2525
}.freeze
2626

2727
TLS_OPTS = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.merge({}).freeze
@@ -65,10 +65,9 @@ def setup
6565
@ldap = Net::LDAP.new \
6666
host: ENV.fetch('INTEGRATION_HOST', 'localhost'),
6767
port: ENV.fetch('INTEGRATION_PORT', 389),
68-
admin_user: 'uid=admin,dc=rubyldap,dc=com',
69-
admin_password: 'passworD1',
70-
search_domains: %w(dc=rubyldap,dc=com),
68+
search_domains: %w(dc=example,dc=org),
7169
uid: 'uid',
7270
instrumentation_service: @service
71+
@ldap.authenticate "cn=admin,dc=example,dc=org", "admin"
7372
end
7473
end

0 commit comments

Comments
 (0)