Sha256: 5c277f1286c494665883a6152ea96a4c0b55fcb139cc3c924819df2bd5d14a37
Contents?: true
Size: 1.96 KB
Versions: 3
Compression:
Stored size: 1.96 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".force_encoding('ascii-8bit') }], res) # Just for fun, let's try parsing it as UTF8 chars = res[0]["sn"].force_encoding('utf-8').scan(/./u) assert_equal(["L", "u", "\u010d", "i", "\u0107"], chars) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-ldapserver-0.7.0 | test/util_test.rb |
ruby-ldapserver-0.5.3 | test/util_test.rb |
ruby-ldapserver-0.5.2 | test/util_test.rb |