Sha256: 6dc314509d443c4650a119b6d9ac8b4ec0e852896d4f301b889eefe9644cda4f
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require File.dirname(__FILE__) + '/test_helper' require 'ldap/server/util' class TestLdapUtil < Test::Unit::TestCase def test_split_dn # examples from RFC 2253 assert_equal( [{"cn"=>"Steve Kille"},{"o"=>"Isode Limited"},{"c"=>"GB"}], LDAP::Server::Operation.split_dn("CN=Steve Kille , O=Isode Limited;C=GB") ) assert_equal( [{"ou"=>"Sales","cn"=>"J. Smith"},{"o"=>"Widget Inc."},{"c"=>"US"}], LDAP::Server::Operation.split_dn("OU=Sales+CN=J. Smith,O=Widget Inc.,C=US") ) assert_equal( [{"cn"=>"L. Eagle"},{"o"=>"Sue, Grabbit and Runn"},{"c"=>"GB"}], LDAP::Server::Operation.split_dn("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB") ) assert_equal( [{"cn"=>"Before\rAfter"},{"o"=>"Test"},{"c"=>"GB"}], LDAP::Server::Operation.split_dn("CN=Before\\0DAfter,O=Test,C=GB") ) res = LDAP::Server::Operation.split_dn("SN=Lu\\C4\\8Di\\C4\\87") assert_equal([{"sn"=>"Lu\xc4\x8di\xc4\x87"}], res) end def test_join_dn # examples from RFC 2253 assert_equal( "cn=Steve Kille,o=Isode Limited,c=GB", LDAP::Server::Operation.join_dn([{"cn"=>"Steve Kille"},{"o"=>"Isode Limited"},{"c"=>"GB"}]) ) # These are equivalent d1 = "ou=Sales+cn=J. Smith,o=Widget Inc.,c=US" d2 = "cn=J. Smith+ou=Sales,o=Widget Inc.,c=US" assert_equal(d1, LDAP::Server::Operation.join_dn([[["ou","Sales"],["cn","J. Smith"]],[["o","Widget Inc."]],["c","US"]]) ) r = LDAP::Server::Operation.join_dn([{"ou"=>"Sales","cn"=>"J. Smith"},{"o"=>"Widget Inc."},{"c"=>"US"}]) assert(r == d1 || r == d2, "got #{r.inspect}, expected #{d1.inspect} or #{d2.inspect}") assert_equal( "cn=L. Eagle,o=Sue\\, Grabbit and Runn,c=GB", LDAP::Server::Operation.join_dn([{"cn"=>"L. Eagle"},{"o"=>"Sue, Grabbit and Runn"},{"c"=>"GB"}]) ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
deveo-ruby-ldapserver-0.5.2 | test/util_test.rb |