10 $uri = URI->new("ldap://host/dn=base?cn,sn?sub?objectClass=*");
12 print "not " unless $uri->host eq "host";
15 print "not " unless $uri->dn eq "dn=base";
18 print "not " unless join("-",$uri->attributes) eq "cn-sn";
21 print "not " unless $uri->scope eq "sub";
24 print "not " unless $uri->filter eq "objectClass=*";
27 $uri = URI->new("ldap:");
28 $uri->dn("o=University of Michigan,c=US");
30 print "not " unless "$uri" eq "ldap:o=University%20of%20Michigan,c=US" &&
31 $uri->dn eq "o=University of Michigan,c=US";
34 $uri->host("ldap.itd.umich.edu");
35 print "not " unless $uri->as_string eq "ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US";
39 print "not " unless $uri->_scope eq "" &&
40 $uri->scope eq "base" &&
41 $uri->_filter eq "" &&
42 $uri->filter eq "(objectClass=*)";
46 $uri->attributes("postalAddress");
47 print "not " unless $uri eq "ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress";
50 # does attribute escapeing work as it should
51 $uri->attributes($uri->attributes, "foo", ",", "*", "?", "#", "\0");
53 print "not " unless $uri->attributes eq "postalAddress,foo,%2C,*,%3F,%23,%00" &&
54 join("-", $uri->attributes) eq "postalAddress-foo-,-*-?-#-\0";
59 print "not " unless $uri->query eq "?sub%3F%23" &&
60 $uri->scope eq "sub?#";
64 $uri->filter("f=?,#");
65 print "not " unless $uri->query eq "??f=%3F,%23" &&
66 $uri->filter eq "f=?,#";
68 $uri->filter("(int=\\00\\00\\00\\04)");
69 print "not " unless $uri->query eq "??(int=%5C00%5C00%5C00%5C04)";
76 $uri->extensions("!bindname" => "cn=Manager,co=Foo");
77 my %ext = $uri->extensions;
79 print "not " unless $uri->query eq "???!bindname=cn=Manager%2Cco=Foo" &&
81 $ext{"!bindname"} eq "cn=Manager,co=Foo";
84 $uri = URI->new("ldap://LDAP-HOST:389/o=University%20of%20Michigan,c=US?postalAddress?base?ObjectClass=*?FOO=Bar,bindname=CN%3DManager%CO%3dFoo");
86 print "not " unless $uri->canonical eq "ldap://ldap-host/o=University%20of%20Michigan,c=US?postaladdress???foo=Bar,bindname=CN=Manager%CO=Foo";
90 print $uri->canonical, "\n";
92 $uri = URI->new("ldaps://host/dn=base?cn,sn?sub?objectClass=*");
94 print "not " unless $uri->host eq "host";
96 print "not " unless $uri->port eq 636;
98 print "not " unless $uri->dn eq "dn=base";
101 $uri = URI->new("ldapi://%2Ftmp%2Fldap.sock/????x-mod=-w--w----");
102 print "not " unless $uri->authority eq "%2Ftmp%2Fldap.sock";
104 print "not " unless $uri->un_path eq "/tmp/ldap.sock";
107 $uri->un_path("/var/x\@foo:bar/");
108 print "not " unless $uri eq "ldapi://%2Fvar%2Fx%40foo%3Abar%2F/????x-mod=-w--w----";
111 %ext = $uri->extensions;
112 print "not " unless $ext{"x-mod"} eq "-w--w----";