Skip to content

Commit 26ebfff

Browse files
committed
Override Test::Unit::TestCase#run for disabled integration tests
1 parent 6b6edac commit 26ebfff

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

test/test_integration.rb

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
require_relative 'test_helper'
22

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
184

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
219
end
10+
end
2211

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
2523

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
3327

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
3741
end
3842
end

0 commit comments

Comments
 (0)