summaryrefslogtreecommitdiff
path: root/testprogs
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-12-17 05:56:42 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:50:45 +0100
commitdfc27ff863baa7fff6f0c039f48c9a336a0632fc (patch)
treebd7c62c5f5016633ab7b7f649ff21c6a6f3e8473 /testprogs
parent70cea01a9ec0be4ef9fd141a16b52e8141a1c94a (diff)
downloadsamba-dfc27ff863baa7fff6f0c039f48c9a336a0632fc.tar.gz
samba-dfc27ff863baa7fff6f0c039f48c9a336a0632fc.tar.bz2
samba-dfc27ff863baa7fff6f0c039f48c9a336a0632fc.zip
r26488: Implement tests for the ranged_results module.
Untested code is broken code, so rework the module until it passes... It turns out that AD puts search attributes onto the wire in the reverse order to what Samba does. This complicates exact value matching, so this is skipped for now. Andrew Bartlett (This used to be commit 91bcb60d31d54e52128d5bd107df4ceb87389889)
Diffstat (limited to 'testprogs')
-rwxr-xr-xtestprogs/ejs/ldap.js160
1 files changed, 152 insertions, 8 deletions
diff --git a/testprogs/ejs/ldap.js b/testprogs/ejs/ldap.js
index 6af70971eb..c03dbe9ce2 100755
--- a/testprogs/ejs/ldap.js
+++ b/testprogs/ejs/ldap.js
@@ -161,10 +161,10 @@ servicePrincipalName: host/ldaptest2computer
servicePrincipalName: cifs/ldaptest2computer
");
- if (ok.error != 0) {
- println("Failed to replace servicePrincpalName:" + ok.errstr);
- assert(ok.error == 20);
- }
+ if (ok.error != 0) {
+ println("Failed to replace servicePrincpalName:" + ok.errstr);
+ assert(ok.error == 20);
+ }
ok = ldb.modify("
dn: cn=ldaptest2computer,cn=computers," + base_dn + "
@@ -174,12 +174,156 @@ servicePrincipalName: host/ldaptest2computer
");
//LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
- if (ok.error != 20) {
- println("Expected error LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS, got :" + ok.errstr);
+ if (ok.error != 20) {
+ println("Expected error LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS, got :" + ok.errstr);
assert(ok.error == 20);
- }
+ }
+
+ println("Testing ranged results");
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+replace: servicePrincipalName
+");
+ if (ok.error != 0) {
+ println("Failed to replace servicePrincpalName:" + ok.errstr);
+ assert(ok.error == 0);
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+add: servicePrincipalName
+servicePrincipalName: host/ldaptest2computer0
+servicePrincipalName: host/ldaptest2computer1
+servicePrincipalName: host/ldaptest2computer2
+servicePrincipalName: host/ldaptest2computer3
+servicePrincipalName: host/ldaptest2computer4
+servicePrincipalName: host/ldaptest2computer5
+servicePrincipalName: host/ldaptest2computer6
+servicePrincipalName: host/ldaptest2computer7
+servicePrincipalName: host/ldaptest2computer8
+servicePrincipalName: host/ldaptest2computer9
+servicePrincipalName: host/ldaptest2computer10
+servicePrincipalName: host/ldaptest2computer11
+servicePrincipalName: host/ldaptest2computer12
+servicePrincipalName: host/ldaptest2computer13
+servicePrincipalName: host/ldaptest2computer14
+servicePrincipalName: host/ldaptest2computer15
+servicePrincipalName: host/ldaptest2computer16
+servicePrincipalName: host/ldaptest2computer17
+servicePrincipalName: host/ldaptest2computer18
+servicePrincipalName: host/ldaptest2computer19
+servicePrincipalName: host/ldaptest2computer20
+servicePrincipalName: host/ldaptest2computer21
+servicePrincipalName: host/ldaptest2computer22
+servicePrincipalName: host/ldaptest2computer23
+servicePrincipalName: host/ldaptest2computer24
+servicePrincipalName: host/ldaptest2computer25
+servicePrincipalName: host/ldaptest2computer26
+servicePrincipalName: host/ldaptest2computer27
+servicePrincipalName: host/ldaptest2computer28
+servicePrincipalName: host/ldaptest2computer29
+");
- ok = ldb.add("
+ if (ok.error != 0) {
+ println("Failed to replace servicePrincpalName:" + ok.errstr);
+ assert(ok.error == 0);
+ }
+
+
+ var attrs = new Array("servicePrincipalName;range=0-*");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+// println(res.msgs[0]["servicePrincipalName;range=0-*"].length);
+ assert(res.msgs[0]["servicePrincipalName;range=0-*"].length == 30);
+
+ var attrs = new Array("servicePrincipalName;range=0-19");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+// println(res.msgs[0]["servicePrincipalName;range=0-19"].length);
+ assert(res.msgs[0]["servicePrincipalName;range=0-19"].length == 20);
+
+ var attrs = new Array("servicePrincipalName;range=0-30");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+ assert(res.msgs[0]["servicePrincipalName;range=0-*"].length == 30);
+
+ var attrs = new Array("servicePrincipalName;range=0-40");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+ assert(res.msgs[0]["servicePrincipalName;range=0-*"].length == 30);
+
+ var attrs = new Array("servicePrincipalName;range=30-40");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+ assert(res.msgs[0]["servicePrincipalName;range=30-*"].length == 0);
+
+ var attrs = new Array("servicePrincipalName;range=10-40");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+ assert(res.msgs[0]["servicePrincipalName;range=10-*"].length == 20);
+// var pos_11 = res.msgs[0]["servicePrincipalName;range=10-*"][18];
+
+ var attrs = new Array("servicePrincipalName;range=11-40");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+ assert(res.msgs[0]["servicePrincipalName;range=11-*"].length == 19);
+// println(res.msgs[0]["servicePrincipalName;range=11-*"][18]);
+// println(pos_11);
+// assert((res.msgs[0]["servicePrincipalName;range=11-*"][18]) == pos_11);
+
+ var attrs = new Array("servicePrincipalName;range=11-15");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+ assert(res.msgs[0]["servicePrincipalName;range=11-15"].length == 5);
+// assert(res.msgs[0]["servicePrincipalName;range=11-15"][4] == pos_11);
+
+ var attrs = new Array("servicePrincipalName");
+ var res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs);
+ if (res.error != 0 || res.msgs.length != 1) {
+ println("Could not find (cn=ldaptest2computer)");
+ assert(res.error == 0);
+ assert(res.msgs.length == 1);
+ }
+// println(res.msgs[0]["servicePrincipalName"][18]);
+// println(pos_11);
+ assert(res.msgs[0]["servicePrincipalName"].length == 30);
+// assert(res.msgs[0]["servicePrincipalName"][18] == pos_11);
+
+ ok = ldb.add("
dn: cn=ldaptestuser2,cn=useRs," + base_dn + "
objectClass: person
objectClass: user