Skip to content

Commit d30ce56

Browse files
author
Jerry Cheung
committed
convert to test/unit
1 parent fa89e22 commit d30ce56

File tree

2 files changed

+44
-80
lines changed

2 files changed

+44
-80
lines changed

spec/unit/ldap/dn_spec.rb

Lines changed: 0 additions & 80 deletions
This file was deleted.

test/test_dn.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
require 'common'
2+
require 'net/ldap/dn'
3+
4+
class TestDN < Test::Unit::TestCase
5+
def test_escape
6+
assert_equal '\\,\\+\\"\\\\\\<\\>\\;', Net::LDAP::DN.escape(',+"\\<>;')
7+
end
8+
9+
def test_escape_on_initialize
10+
dn = Net::LDAP::DN.new('cn', ',+"\\<>;', 'ou=company')
11+
assert_equal 'cn=\\,\\+\\"\\\\\\<\\>\\;,ou=company', dn.to_s
12+
end
13+
14+
def test_to_a
15+
dn = Net::LDAP::DN.new('cn=James, ou=Company\\,\\20LLC')
16+
assert_equal ['cn','James','ou','Company, LLC'], dn.to_a
17+
end
18+
19+
def test_to_a_parenthesis
20+
dn = Net::LDAP::DN.new('cn = \ James , ou = "Comp\28ny" ')
21+
assert_equal ['cn',' James','ou','Comp(ny'], dn.to_a
22+
end
23+
24+
def test_to_a_hash_symbol
25+
dn = Net::LDAP::DN.new('1.23.4= #A3B4D5 ,ou=Company')
26+
assert_equal ['1.23.4','#A3B4D5','ou','Company'], dn.to_a
27+
end
28+
29+
# TODO: raise a more specific exception than RuntimeError
30+
def test_bad_input_raises_error
31+
[
32+
'cn=James,',
33+
'cn=#aa aa',
34+
'cn="James',
35+
'cn=J\ames',
36+
'cn=\\',
37+
'1.2.d=Value',
38+
'd1.2=Value',
39+
].each do |input|
40+
dn = Net::LDAP::DN.new(input)
41+
assert_raises(RuntimeError) { dn.to_a }
42+
end
43+
end
44+
end

0 commit comments

Comments
 (0)