From 7841e975395430f6ae32c8e33e7f44d7614c08be Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 8 May 2004 21:34:20 +0000 Subject: [PATCH] more tests; test026 now works regardless of the backend; test027 is disabled for bdb/hdb because of a bug in handling empty DN... --- tests/data/dn.out | 117 +++++----- tests/data/emptydn.out | 28 +++ tests/data/slapd-dn.conf | 4 +- tests/data/slapd-emptydn.conf | 71 ++++++ tests/data/test-dn.ldif | 413 +++++++++++++++++++--------------- tests/data/test-emptydn1.ldif | 29 +++ tests/data/test-emptydn2.ldif | 14 ++ tests/scripts/defines.sh | 6 +- tests/scripts/test026-dn | 14 +- tests/scripts/test027-emptydn | 160 +++++++++++++ 10 files changed, 603 insertions(+), 253 deletions(-) create mode 100644 tests/data/emptydn.out create mode 100644 tests/data/slapd-emptydn.conf create mode 100644 tests/data/test-emptydn1.ldif create mode 100644 tests/data/test-emptydn2.ldif create mode 100755 tests/scripts/test027-emptydn diff --git a/tests/data/dn.out b/tests/data/dn.out index 6933a32d57..ec9d2cbb1f 100644 --- a/tests/data/dn.out +++ b/tests/data/dn.out @@ -1,83 +1,72 @@ -dn: dc=net -objectClass: domain -dc: net -seeAlso: - -dn: dc=example,dc=net +dn: dc=example,dc=com objectClass: domain objectClass: domainRelatedObject dc: example -associatedDomain: example.net - -dn: uid=jsmith,dc=example,dc=net -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: jsmith -description: UID=jsmith,DC=example,DC=net +associatedDomain: example.com -dn: cn=J. Smith+ou=Sales,dc=example,dc=net -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -ou: Sales -description: OU=Sales+CN=J. Smith,DC=example,DC=net +dn: ou=LDAPv3,dc=example,dc=com +objectClass: organizationalUnit +ou: LDAPv3 +description: RFC 2253 compliant DN string representation -dn: cn=John Smith\2C III,dc=example,dc=net -objectClass: inetOrgPerson -cn: John Smith, III -sn: Smith +dn: cn=Must Succeed,ou=LDAPv3,dc=example,dc=com +objectClass: groupOfNames +cn: Must Succeed +member: cn=Must Succeed,ou=LDAPv3,dc=example,dc=com +member: +member: uid=jsmith,dc=example,dc=net +member: cn=J. Smith+ou=Sales,dc=example,dc=net +member: cn=John Smith\2C III,dc=example,dc=net +member: ou=Sales\3B Data\2BAlgorithms,dc=example,dc=net +member:: Y249QmVmb3JlDUFmdGVyLGRjPWV4YW1wbGUsZGM9bmV0 +member: cn=\23John Smith\20,dc=example,dc=net +member:: Y249THXEjWnEhw== seeAlso: cn=John Smith\2C III,dc=example,dc=net +seeAlso: ou=Sales\3B Data\2BAlgorithms,dc=example,dc=net +seeAlso: cn=\23John Smith\20,dc=example,dc=net +description: "member" values contain specific DN forms; +description: "seeAlso" values contain DN forms already defined as "member", +description: but in a different string representation; +description: the following "description" values contain the "member" and +description: "seeAlso" DN string representations used above. +description: "" +description: UID=jsmith,DC=example,DC=net +description: OU=Sales+CN=J. Smith,DC=example,DC=net description: CN=John Smith\, III,DC=example,DC=net description: CN=John Smith\2C III,DC=example,DC=net - -dn: ou=Sales\3B Data\2BAlgorithms,dc=example,dc=net -objectClass: organizationalUnit -ou: Sales; Data+Algorithms -seeAlso: ou=Sales\3B Data\2BAlgorithms,dc=example,dc=net description: OU=Sales\; Data\+Algorithms,DC=example,DC=net description: OU=Sales\3B Data\2BAlgorithms,DC=example,DC=net - -dn:: Y249QmVmb3JlDUFmdGVyLGRjPWV4YW1wbGUsZGM9bmV0 -objectClass: groupOfNames -cn:: QmVmb3JlDUFmdGVy -member:: Y249QmVmb3JlDUFmdGVyLGRjPWV4YW1wbGUsZGM9bmV0 description: CN=Before\0dAfter,DC=example,DC=net - -dn: cn=\23John Smith\20,dc=example,dc=net -objectClass: inetOrgPerson -cn:: I0pvaG4gU21pdGgg -sn: Smith -seeAlso: cn=\23John Smith\20,dc=example,dc=net description: CN=\23John Smith\20,DC=example,DC=net description: CN=\#John Smith\ ,DC=example,DC=net - -dn:: Y249THXEjWnEhw== -objectClass: inetOrgPerson -cn:: THXEjWnEhw== -sn:: THXEjWnEhw== description: CN=Lu\C4\8Di\C4\87 -dn: c=US -objectClass: country -c: US +dn: ou=LDAPv2,dc=example,dc=com +objectClass: organizationalUnit +ou: LDAPv2 +description: RFC 1777 compliant DN string representation + +dn: cn=May Succeed 1,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 1 +member: +description: " " // space, quote characters (") are not part of the string -dn: o=example,c=US -objectClass: organization -o: example +dn: cn=May Succeed 3,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 3 +member: uid=jsmith,o=example,c=US +description: UID=jsmith, O=example, C=US // spaces -dn: uid=jsmith,o=example,c=US -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: jsmith -seeAlso: uid=jsmith,o=example,c=US -description: UID=jsmith, O=example, C=US -description: UID=jsmith;O=example;C=US +dn: cn=May Succeed 4,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 4 +member: uid=jsmith,o=example,c=US +description: UID=jsmith;O=example;C=US // semi-colons -dn: cn=John Smith,o=example,c=US -objectClass: inetOrgPerson -cn: John Smith -sn: Smith -description: CN="John Smith",O=example,C=US +dn: cn=May Succeed 6,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 6 +member: cn=John Smith,o=example,c=US +description: CN="John Smith",O=example,C=US // quotes diff --git a/tests/data/emptydn.out b/tests/data/emptydn.out new file mode 100644 index 0000000000..608c92dcef --- /dev/null +++ b/tests/data/emptydn.out @@ -0,0 +1,28 @@ +dn: c=US +objectClass: country +c: US + +dn: o=Example,c=US +objectClass: organization +o: Example +o: Example, Inc. + +dn: c=UK +objectClass: country +c: UK + +dn: o=Example,c=UK +objectClass: organization +o: Example +o: Example, Ltd. + +dn: c=IT +objectClass: country +c: IT + +dn: o=Esempio,c=IT +objectClass: organization +o: Esempio +o: Esempio S.p.A. +o: Example + diff --git a/tests/data/slapd-dn.conf b/tests/data/slapd-dn.conf index 1357b2ad78..28648049e7 100644 --- a/tests/data/slapd-dn.conf +++ b/tests/data/slapd-dn.conf @@ -32,9 +32,9 @@ argsfile ./testrun/slapd.1.args ####################################################################### database @BACKEND@ -suffix "" +suffix "dc=example,dc=com" directory ./testrun/db.1.a -rootdn "cn=Manager" +rootdn "cn=Manager,dc=example,dc=com" rootpw secret index objectClass eq index cn,sn,uid pres,eq,sub diff --git a/tests/data/slapd-emptydn.conf b/tests/data/slapd-emptydn.conf new file mode 100644 index 0000000000..2cad25b720 --- /dev/null +++ b/tests/data/slapd-emptydn.conf @@ -0,0 +1,71 @@ +# stand-alone slapd config -- for testing (with refint overlay) +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 2004 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## . + +ucdata-path ./ucdata +include ./schema/core.schema +include ./schema/cosine.schema +include ./schema/inetorgperson.schema +include ./schema/openldap.schema +include ./schema/nis.schema + +# +pidfile ./testrun/slapd.1.pid +argsfile ./testrun/slapd.1.args + +access to dn.exact="" + by * read + +access to dn.exact="cn=Subschema" + by * read + +#mod#modulepath ../servers/slapd/back-@BACKEND@/ +#mod#moduleload back_@BACKEND@.la + +####################################################################### +# database definitions +####################################################################### + +database @BACKEND@ +suffix "dc=example,dc=com" +directory ./testrun/db.1.a +rootdn "cn=Manager,dc=example,dc=com" +rootpw secret +index objectClass eq +index cn,sn,uid pres,eq,sub + +access to attrs=userPassword + by dn.exact="cn=Manager,c=US" write + by self =wx + by * =x + +access to dn.subtree="dc=example,dc=com" + by dn.exact="cn=Manager,c=US" write + by * read + +database @BACKEND@ +suffix "" +directory ./testrun/db.2.a +rootdn "cn=Manager,c=US" +rootpw secret +index objectClass eq +index cn,sn,uid pres,eq,sub + +access to attrs=userPassword + by self =wx + by * =x + +access to dn.subtree="" + by * read + diff --git a/tests/data/test-dn.ldif b/tests/data/test-dn.ldif index 752900f87d..320e1b6b7c 100644 --- a/tests/data/test-dn.ldif +++ b/tests/data/test-dn.ldif @@ -1,249 +1,310 @@ -# Regular DNs -dn: dc=net -objectClass: domain -dc: net -seeAlso: - -dn: dc=example,dc=net +# Tree Structure +dn: dc=example,dc=com objectClass: domain objectClass: domainRelatedObject dc: example -associatedDomain: example.net +associatedDomain: example.com + +dn: ou=LDAPv3,dc=example,dc=com +objectClass: organizationalUnit +ou: LDAPv3 +description: RFC 2253 compliant DN string representation + +dn: cn=Must Succeed,ou=LDAPv3,dc=example,dc=com +objectClass: groupOfNames +cn: Must Succeed +# at least one member must be present; thus we use the entry's DN +member: cn=Must Succeed,ou=LDAPv3,dc=example,dc=com +# specific DN forms +member: +member: UID=jsmith,DC=example,DC=net +member: OU=Sales+CN=J. Smith,DC=example,DC=net +member: CN=John Smith\, III,DC=example,DC=net +member: OU=Sales\; Data\+Algorithms,DC=example,DC=net +member: CN=Before\0dAfter,DC=example,DC=net +member: CN=\23John Smith\20,DC=example,DC=net +member: CN=Lu\C4\8Di\C4\87 +# DN forms already defined as "member" in a different string representation +seeAlso: CN=John Smith\2C III,DC=example,DC=net +seeAlso: OU=Sales\3B Data\2BAlgorithms,DC=example,DC=net +seeAlso: CN=\#John Smith\ ,DC=example,DC=net +# comment +description: "member" values contain specific DN forms; +description: "seeAlso" values contain DN forms already defined as "member", +description: but in a different string representation; +description: the following "description" values contain the "member" and +description: "seeAlso" DN string representations used above. +# list here all string representations used above in "member" and "seeAlso" +description: "" +description: UID=jsmith,DC=example,DC=net +description: OU=Sales+CN=J. Smith,DC=example,DC=net +description: CN=John Smith\, III,DC=example,DC=net +description: CN=John Smith\2C III,DC=example,DC=net +description: OU=Sales\; Data\+Algorithms,DC=example,DC=net +description: OU=Sales\3B Data\2BAlgorithms,DC=example,DC=net +description: CN=Before\0dAfter,DC=example,DC=net +description: CN=\23John Smith\20,DC=example,DC=net +description: CN=\#John Smith\ ,DC=example,DC=net +description: CN=Lu\C4\8Di\C4\87 + +dn: cn=Should Succeed,ou=LDAPv3,dc=example,dc=com +objectClass: groupOfNames +cn: Should Succeed +member: cn=Should Succeed,ou=LDAPv3,dc=example,dc=com +member: 1.3.6.1.4.1.1466.0=#04024869,DC=example,DC=com +member: 1.1.1= +description: 1.3.6.1.4.1.1466.0=#04024869,DC=example,DC=com +description: 1.1.1= + +dn: cn=Must Fail 1,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 1 +member: uid;x-option=jsmith +description: uid;x-option=jsmith // option + +dn: cn=Must Fail 2,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 2 +member: at_tr=jsmith +description: at_tr=jsmith // invalid attribute type name + +dn: cn=Must Fail 3,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 3 +member: -attr=jsmith +description: -attr=jsmith // invalid attribute type name + +dn: cn=Must Fail 4,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 4 + +dn: cn=Must Fail 5,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 5 +member: 1..1=jsmith +description: 1..1=jsmith // invalid numeric OID + +dn: cn=Must Fail 6,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 6 +member: 1.1.=jsmith +description: 1.1.=jsmith // invalid numeric OID + +dn: cn=Must Fail 7,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 7 +member: 01.1=jsmith +description: 01.1=jsmith // invalid numeric OID + +dn: cn=Must Fail 8,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 8 +member: 1.ff=jsmith +description: 1.ff=jsmith // invalid numeric OID + +dn: cn=Must Fail 9,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 9 +member: 1.1.1=#GG +description: 1.1.1=#GG // invalid HEX form + +dn: cn=Must Fail 10,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 10 +member: 1.1.1=#000 +description: 1.1.1=#000 // invalid HEX form + +dn: cn=Must Fail 11,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 11 +member: 1.1.1=#F +description: 1.1.1=#F // invalid HEX form + +dn: cn=Must Fail 12,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 12 +member: 1.1.1=# +description: 1.1.1=# // invalid HEX form + +dn: cn=Must Fail 13,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 13 +member: UID=jsmith,,DC=example,DC=net +description: UID=jsmith,,DC=example,DC=net // extra comma + +dn: cn=Must Fail 14,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 14 +member: UID=john,smith +description: UID=john,smith // unescaped , + +dn: cn=Must Fail 15,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 15 +member: UID=john+smith +description: UID=john+smith // unescaped + + +dn: cn=Must Fail 16,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 16 +member: UID=john\?smith +description: UID=john\?smith // invalid escape of ? or unescaped \ + +dn: cn=Must Fail 17,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 17 +member: UID=john\Fsmith +description: UID=john\Fsmith // invalid HEX escape + +dn: cn=Must Fail 18,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Must Fail 18 +member: UID=john\GGsmith +description: UID=john\GGsmith // invalid HEX escape + +dn: ou=LDAPv2,dc=example,dc=com +objectClass: organizationalUnit +ou: LDAPv2 +description: RFC 1777 compliant DN string representation + +dn: cn=May Succeed 1,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 1 +member: +description: " " // space, quote characters (") are not part of the string + +dn: cn=May Succeed 2,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 2 +member: OID.0.9.2342.19200300.100.1.1=jsmith +description: OID.0.9.2342.19200300.100.1.1=jsmith // invalid attribute type name + +dn: cn=May Succeed 3,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 3 +member: UID=jsmith, O=example, C=US +description: UID=jsmith, O=example, C=US // spaces + +dn: cn=May Succeed 4,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 4 +member: UID=jsmith;O=example;C=US +description: UID=jsmith;O=example;C=US // semi-colons + +dn: cn=May Succeed 5,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 5 +member: +description: // brackets + +dn: cn=May Succeed 6,ou=LDAPv2,dc=example,dc=com +objectClass: groupOfNames +cn: May Succeed 6 +member: CN="John Smith",O=example,C=US +description: CN="John Smith",O=example,C=US // quotes # UID=jsmith,DC=example,DC=net [AoOn] # 304631133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 31163014060A0992268993F22C64010113066A736D697468 -dn: UID=jsmith,DC=example,DC=net -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: jsmith -description: UID=jsmith,DC=example,DC=net - +# # OU=Sales+CN=J. Smith,DC=example,DC=net [AoOn] # 304F31133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 311F300C060355040B130553616C6573300F060355040313 # 084A2E20536D697468 -dn: OU=Sales+CN=J. Smith,DC=example,DC=net -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -ou: Sales -description: OU=Sales+CN=J. Smith,DC=example,DC=net - +# # CN=John Smith\, III,DC=example,DC=net [AoOn] # 304831133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 311830160603550403130F4A6F686E20536D6974682C2049 # 4949 - +# # CN=John Smith\2C III,DC=example,DC=net [AoOn] # 304831133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 311830160603550403130F4A6F686E20536D6974682C2049 # 4949 -dn: CN=John Smith\, III,DC=example,DC=net -objectClass: inetOrgPerson -cn: John Smith, III -sn: Smith -seeAlso: CN=John Smith\2C III,DC=example,DC=net -description: CN=John Smith\, III,DC=example,DC=net -description: CN=John Smith\2C III,DC=example,DC=net - -dn: OU=Sales\; Data\+Algorithms,DC=example,DC=net -objectClass: organizationalUnit -ou: Sales; Data+Algorithms -seeAlso: OU=Sales\3B Data\2BAlgorithms,DC=example,DC=net -description: OU=Sales\; Data\+Algorithms,DC=example,DC=net -description: OU=Sales\3B Data\2BAlgorithms,DC=example,DC=net - +# # CN=Before\0dAfter,DC=example,DC=net [AoOn] # 304531133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 3115301306035504030C0C4265666F72650D4166746572 -dn: CN=Before\0dAfter,DC=example,DC=net -objectClass: groupOfNames -cn:: QmVmb3JlDUFmdGVy -member: CN=Before\0dAfter,DC=example,DC=net -description: CN=Before\0dAfter,DC=example,DC=net - +# # CN=\23John Smith\20,DC=example,DC=net [AoOn] # 304531133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 311530130603550403140C234A6F686E20536D69746820 - +# # CN=\#John Smith\ ,DC=example,DC=net [AoOn] # 304531133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 311530130603550403140C234A6F686E20536D69746820 -dn: CN=\23John Smith\20,DC=example,DC=net -objectClass: inetOrgPerson -cn:: I0pvaG4gU21pdGgg -sn: Smith -seeAlso: CN=\#John Smith\ ,DC=example,DC=net -description: CN=\23John Smith\20,DC=example,DC=net -description: CN=\#John Smith\ ,DC=example,DC=net - +# +# FIXME: currently doesn't work # 1.3.6.1.4.1.1466.0=#04024869,DC=example,DC=com [AoOn] # 304031133011060A0992268993F22C64011916036E657431 [AoO] # 173015060A0992268993F22C64011916076578616D706C65 # 3110300E06082B060104018B3A0004024869 -# FIXME -dn: 1.3.6.1.4.1.1466.0=#04024869,DC=example,DC=com -objectClass: top - +# # CN=Lu\C4\8Di\C4\87 [AoOn] # 30123110300E06035504030C074C75C48D69C487 [AoO] -dn: CN=Lu\C4\8Di\C4\87 -objectClass: inetOrgPerson -cn:: THXEjWnEhw== -sn:: THXEjWnEhw== -description: CN=Lu\C4\8Di\C4\87 - +# +# FIXME: currently doesn't work # 1.1.1= // empty value [AoO] # 300A31083006060229011300 [AoO] -# FIXME -dn: 1.1.1= -objectClass: top - +# #Invalid DNs # // some implementations may be liberal in what they accept # // but should strict in what they produce. - +# # uid;x-option=jsmith // option [oOn] -dn: uid;x-option=jsmith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid;x-option: jsmith - +# # at_tr=jsmith // invalid attribute type name [AoOn] -dn: at_tr=jsmith -objectClass: top - +# # -attr=jsmith // invalid attribute type name [AoOn] -dn: -attr=jsmith -objectClass: top - +# # 1..1=jsmith // invalid numeric OID [AoO] -dn: 1..1=jsmith -objectClass: top - +# # 1.1.=jsmith // invalid numeric OID [AoO] -dn: 1.1.=jsmith -objectClass: top - +# # 01.1=jsmith // invalid numeric OID [oO] -dn: 01.1=jsmith -objectClass: top - +# # 1.ff=jsmith // invalid numeric OID [AoOn] -dn: 1.ff=jsmith -objectClass: top - +# # 1.1.1=#GG // invalid HEX form [AoOn] -dn: 1.1.1=#GG -objectClass: top - +# # 1.1.1=#000 // invalid HEX form [AoO] -dn: 1.1.1=#000 -objectClass: top - +# # 1.1.1=#F // invalid HEX form [AoO] -dn: 1.1.1=#F -objectClass: top - +# # 1.1.1=# // invalid HEX form [AoO] -dn: 1.1.1=# -objectClass: top - +# # UID=jsmith,,DC=example,DC=net // extra comma [AoOn] -dn: UID=jsmith,,DC=example,DC=net -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: jsmith - +# # UID=john,smith // unescaped , [AoOn] -dn: UID=john,smith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: john - +# # UID=john+smith // unescaped + [AoOn] -dn: UID=john+smith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: john - +# # UID=john\?smith // invalid escape of ? or unescaped \ [oOn] -dn: UID=john\?smith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: john?smith - +# # UID=john\Fsmith // invalid hex escape [AoOn] -dn: UID=john\Fsmith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith - +# # UID=john\GGsmith // invalid hex escape [oOn] -dn: UID=john\GGsmith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith - - +# #The following strings are invalid for use in LDAPv3, but were #legal in LDAPv2 (RFC 1779). Some LDAPv3 implementations are #liberal in accepting these but should not generate them. - +# # " " // space, quote characters (") are not part of the string - +# # OID.1.1=jsmith // invalid attribute type name -dn: OID.0.9.2342.19200300.100.1.1=jsmith -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: jsmith -description: OID.0.9.2342.19200300.100.1.1=jsmith - -dn: C=US -objectClass: country -c: US - -dn: O=example, C=US -objectClass: organization -o: example - +# # UID=jsmith, O=example, C=US // spaces +# # UID=jsmith;O=example;C=US // semi-colons -dn: UID=jsmith, O=example, C=US -objectClass: inetOrgPerson -cn: J. Smith -sn: Smith -uid: jsmith -seeAlso: UID=jsmith;O=example;C=US -description: UID=jsmith, O=example, C=US -description: UID=jsmith;O=example;C=US - +# # // brackets [AoOn] -dn: cn=LDAPv2,O=example,C=US -objectClass: groupOfNames -cn: LDAPv2 -member: -description: - +# # CN="John Smith",O=example,C=US // quotes -dn: CN="John Smith",O=example,C=US -objectClass: inetOrgPerson -cn: John Smith -sn: Smith -description: CN="John Smith",O=example,C=US diff --git a/tests/data/test-emptydn1.ldif b/tests/data/test-emptydn1.ldif new file mode 100644 index 0000000000..0fb5500b7e --- /dev/null +++ b/tests/data/test-emptydn1.ldif @@ -0,0 +1,29 @@ +# geographical naming contexts +dn: c=US +objectClass: country +c: US + +dn: o=Example,c=US +objectClass: organization +o: Example +o: Example, Inc. + +dn: c=UK +objectClass: country +c: UK + +dn: o=Example,c=UK +objectClass: organization +o: Example +o: Example, Ltd. + +dn: c=IT +objectClass: country +c: IT + +dn: o=Esempio,c=IT +objectClass: organization +o: Esempio +o: Esempio S.p.A. +o: Example + diff --git a/tests/data/test-emptydn2.ldif b/tests/data/test-emptydn2.ldif new file mode 100644 index 0000000000..166dca5175 --- /dev/null +++ b/tests/data/test-emptydn2.ldif @@ -0,0 +1,14 @@ +# dc=example,dc=com naming context +dn: dc=example,dc=com +objectClass: domain +objectClass: domainRelatedObject +dc: example +associatedDomain: example.com + +dn: cn=Geographical Naming Contexts,dc=example,dc=com +objectClass: groupOfNames +cn: Geographical Naming Contexts +member: o=Example,c=US +member: o=Example,c=UK +member: o=Esempio,c=IT + diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index df8b999d85..43fc8f7843 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -59,6 +59,7 @@ REFINTCONF=$DATADIR/slapd-refint.conf UNIQUECONF=$DATADIR/slapd-unique.conf LIMITSCONF=$DATADIR/slapd-limits.conf DNCONF=$DATADIR/slapd-dn.conf +EMPTYDNCONF=$DATADIR/slapd-emptydn.conf CONF1=$TESTDIR/slapd.1.conf CONF2=$TESTDIR/slapd.2.conf @@ -129,6 +130,8 @@ LDIFREFINT=$DATADIR/test-refint.ldif LDIFUNIQUE=$DATADIR/test-unique.ldif LDIFLIMITS=$DATADIR/test-limits.ldif LDIFDN=$DATADIR/test-dn.ldif +LDIFEMPTYDN2=$DATADIR/test-emptydn1.ldif +LDIFEMPTYDN1=$DATADIR/test-emptydn2.ldif MONITOR="" REFDN="c=US" BASEDN="dc=example,dc=com" @@ -140,7 +143,7 @@ BJORNSDN="cn=Bjorn Jensen,ou=Information Technology DivisioN,OU=People,dc=exampl JAJDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com" REFINTDN="cn=Manager,o=refint" UNIQUEDN="cn=Manager,o=unique" -DNDN="cn=Manager" +EMPTYDNDN="cn=Manager,c=US" LOG1=$TESTDIR/slapd.1.log LOG2=$TESTDIR/slapd.2.log @@ -190,6 +193,7 @@ MODSRCHFILTERS=$DATADIR/modify.search.filters CERTIFICATETLS=$DATADIR/certificate.tls CERTIFICATEOUT=$DATADIR/certificate.out DNOUT=$DATADIR/dn.out +EMPTYDNOUT=$DATADIR/emptydn.out # Just in case we linked the binaries dynamically LD_LIBRARY_PATH=`pwd`/../libraries:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH diff --git a/tests/scripts/test026-dn b/tests/scripts/test026-dn index c8146f8bc9..1365cff369 100755 --- a/tests/scripts/test026-dn +++ b/tests/scripts/test026-dn @@ -12,12 +12,6 @@ ## top-level directory of the distribution or, alternatively, at ## . -# FIXME: temporary! bdb doesn't work -if test "$BACKEND" != "ldbm" ; then - echo "Test does not support $BACKEND" - exit 0 -fi - echo "running defines.sh" . $SRCDIR/scripts/defines.sh @@ -52,12 +46,12 @@ if test $RC != 0 ; then fi echo "Loading database..." -$LDAPADD -D "$DNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD -c -f $LDIFDN > \ +$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD -c -f $LDIFDN > \ /dev/null 2>&1 echo "Searching database..." -$LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 +$LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 RC=$? if test $RC != 0 ; then @@ -66,6 +60,8 @@ if test $RC != 0 ; then exit $RC fi +test $KILLSERVERS != no && kill -HUP $KILLPIDS + LDIFOUT=$DNOUT echo "Comparing ldapsearch results against original..." @@ -78,7 +74,5 @@ fi ##### -test $KILLSERVERS != no && kill -HUP $KILLPIDS - echo ">>>>> Test succeeded" exit 0 diff --git a/tests/scripts/test027-emptydn b/tests/scripts/test027-emptydn new file mode 100755 index 0000000000..fa38b5727d --- /dev/null +++ b/tests/scripts/test027-emptydn @@ -0,0 +1,160 @@ +#! /bin/sh +## This work is part of OpenLDAP Software . +## +## Copyright 2004 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## . + +# FIXME: temporary! bdb doesn't work +if test "$BACKEND" != "ldbm" ; then + echo "Test does not support $BACKEND" + exit 0 +fi + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +mkdir -p $TESTDIR $DBDIR1 $DBDIR2 + +. $CONFFILTER $BACKEND $MONITORDB < $EMPTYDNCONF > $CONF1 + +echo "Running slapadd to build \"dc=example,dc=com\" slapd database..." +$SLAPADD -f $CONF1 -n 1 -l $LDIFEMPTYDN1 +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Running slapadd to build empty DN slapd database..." +$SLAPADD -f $CONF1 -n 2 -l $LDIFEMPTYDN2 +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Starting slapd on TCP/IP port $PORT1..." +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +echo "Testing slapd empty DN handling..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Searching database..." + +$LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +LDIFOUT=$EMPTYDNOUT + +echo "Comparing ldapsearch results against original..." +$CMP $SEARCHOUT $LDIFOUT > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - empty DN write operations did not complete correctly" + exit 1 +fi + +echo "Comparison of database generated via slapadd succeeded" + +echo "Cleaning up database directories..." +/bin/rm -rf testrun/db.* + +mkdir -p $TESTDIR $DBDIR1 $DBDIR2 + +echo "Starting slapd on TCP/IP port $PORT1..." +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +echo "Testing slapd empty DN handling..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Loading database..." +$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ + -f $LDIFEMPTYDN1 > /dev/null 2>&1 +$LDAPADD -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ + -f $LDIFEMPTYDN2 > /dev/null 2>&1 + +echo "Searching database..." + +$LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +LDIFOUT=$EMPTYDNOUT + +echo "Comparing ldapsearch results against original..." +$CMP $SEARCHOUT $LDIFOUT > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - empty DN write operations did not complete correctly" + exit 1 +fi + +##### + +echo ">>>>> Test succeeded" +exit 0 -- 2.39.5