|
1 | 1 | require_relative 'test_helper'
|
2 | 2 |
|
3 |
| -if !INTEGRATION |
4 |
| - puts "Skipping integration tests..." |
5 |
| -else |
6 |
| - class TestLDAPIntegration < Test::Unit::TestCase |
7 |
| - def setup |
8 |
| - @service = MockInstrumentationService.new |
9 |
| - @ldap = Net::LDAP.new \ |
10 |
| - host: 'localhost', |
11 |
| - port: 389, |
12 |
| - admin_user: 'uid=admin,dc=rubyldap,dc=com', |
13 |
| - admin_password: 'passworD1', |
14 |
| - search_domains: %w(dc=rubyldap,dc=com), |
15 |
| - uid: 'uid', |
16 |
| - instrumentation_service: @service |
17 |
| - end |
| 3 | +class TestLDAPIntegration < Test::Unit::TestCase |
18 | 4 |
|
19 |
| - def test_bind_success |
20 |
| - assert @ldap.bind(method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", password: "passworD1"), @ldap.get_operation_result.inspect |
| 5 | + # If integration tests aren't enabled, noop these tests. |
| 6 | + if !INTEGRATION |
| 7 | + def run(*) |
| 8 | + self |
21 | 9 | end
|
| 10 | + end |
22 | 11 |
|
23 |
| - def test_bind_anonymous_fail |
24 |
| - refute @ldap.bind(method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", password: ""), @ldap.get_operation_result.inspect |
| 12 | + def setup |
| 13 | + @service = MockInstrumentationService.new |
| 14 | + @ldap = Net::LDAP.new \ |
| 15 | + host: 'localhost', |
| 16 | + port: 389, |
| 17 | + admin_user: 'uid=admin,dc=rubyldap,dc=com', |
| 18 | + admin_password: 'passworD1', |
| 19 | + search_domains: %w(dc=rubyldap,dc=com), |
| 20 | + uid: 'uid', |
| 21 | + instrumentation_service: @service |
| 22 | + end |
25 | 23 |
|
26 |
| - result = @ldap.get_operation_result |
27 |
| - assert_equal 53, result.code |
28 |
| - assert_equal "Unwilling to perform", result.message |
29 |
| - assert_equal "unauthenticated bind (DN with no password) disallowed", |
30 |
| - result.error_message |
31 |
| - assert_equal "", result.matched_dn |
32 |
| - end |
| 24 | + def test_bind_success |
| 25 | + assert @ldap.bind(method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", password: "passworD1"), @ldap.get_operation_result.inspect |
| 26 | + end |
33 | 27 |
|
34 |
| - def test_bind_fail |
35 |
| - refute @ldap.bind(method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", password: "not my password"), @ldap.get_operation_result.inspect |
36 |
| - end |
| 28 | + def test_bind_anonymous_fail |
| 29 | + refute @ldap.bind(method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", password: ""), @ldap.get_operation_result.inspect |
| 30 | + |
| 31 | + result = @ldap.get_operation_result |
| 32 | + assert_equal 53, result.code |
| 33 | + assert_equal "Unwilling to perform", result.message |
| 34 | + assert_equal "unauthenticated bind (DN with no password) disallowed", |
| 35 | + result.error_message |
| 36 | + assert_equal "", result.matched_dn |
| 37 | + end |
| 38 | + |
| 39 | + def test_bind_fail |
| 40 | + refute @ldap.bind(method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", password: "not my password"), @ldap.get_operation_result.inspect |
37 | 41 | end
|
38 | 42 | end
|
0 commit comments