@@ -33,18 +33,23 @@ class TestIsLDAPUrl(unittest.TestCase):
3333 'ldap://host.com:6666/o=University%20of%20Michigan,' :1 ,
3434 'ldap://ldap.itd.umich.edu/c=GB?objectClass?one' :1 ,
3535 'ldap://ldap.question.com/o=Question%3f,c=US?mail' :1 ,
36- 'ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04)' :1 ,
36+ 'ldap://ldap.netscape.com/o=Babsco,c=US??? (int=%5c00%5c00%5c00%5c04)' :1 ,
3737 'ldap:///??sub??bindname=cn=Manager%2co=Foo' :1 ,
3838 'ldap:///??sub??!bindname=cn=Manager%2co=Foo' :1 ,
3939 # More examples from various sources
4040 'ldap://ldap.nameflow.net:1389/c%3dDE' :1 ,
4141 'ldap://root.openldap.org/dc=openldap,dc=org' :1 ,
42- 'ldap ://root.openldap.org/dc=openldap,dc=org' :1 ,
42+ 'ldaps ://root.openldap.org/dc=openldap,dc=org' :1 ,
4343 'ldap://x500.mh.se/o=Mitthogskolan,c=se????1.2.752.58.10.2=T.61' :1 ,
4444 'ldp://root.openldap.org/dc=openldap,dc=org' :0 ,
4545 'ldap://localhost:1389/ou%3DUnstructured%20testing%20tree%2Cdc%3Dstroeder%2Cdc%3Dcom??one' :1 ,
4646 'ldaps://ldap.example.com/c%3dDE' :1 ,
4747 'ldapi:///dc=stroeder,dc=de????x-saslmech=EXTERNAL' :1 ,
48+ 'LDAP://localhost' : True ,
49+ 'LDAPS://localhost' : True ,
50+ 'LDAPI://%2Frun%2Fldap.sock' : True ,
51+ ' ldap://space.example' : False ,
52+ 'ldap ://space.example' : False ,
4853 }
4954
5055 def test_isLDAPUrl (self ):
@@ -56,6 +61,11 @@ def test_isLDAPUrl(self):
5661 ldap_url , result , expected ,
5762 )
5863 )
64+ if expected :
65+ LDAPUrl (ldapUrl = ldap_url )
66+ else :
67+ with self .assertRaises (ValueError ):
68+ LDAPUrl (ldapUrl = ldap_url )
5969
6070
6171class TestParseLDAPUrl (unittest .TestCase ):
@@ -144,6 +154,22 @@ class TestParseLDAPUrl(unittest.TestCase):
144154 dn = 'dc=stroeder,dc=com' ,
145155 ),
146156 ),
157+ (
158+ 'LDAPS://localhost:12345/dc=stroeder,dc=com' ,
159+ LDAPUrl (
160+ urlscheme = 'ldaps' ,
161+ hostport = 'localhost:12345' ,
162+ dn = 'dc=stroeder,dc=com' ,
163+ ),
164+ ),
165+ (
166+ 'ldaps://localhost:12345/dc=stroeder,dc=com' ,
167+ LDAPUrl (
168+ urlscheme = 'LDAPS' ,
169+ hostport = 'localhost:12345' ,
170+ dn = 'dc=stroeder,dc=com' ,
171+ ),
172+ ),
147173 (
148174 'ldapi://%2ftmp%2fopenldap2-1389/dc=stroeder,dc=com' ,
149175 LDAPUrl (
0 commit comments