Skip to content

Commit

Permalink
r9813: Conver testsuite for samba3sam module to EJS
Browse files Browse the repository at this point in the history
(This used to be commit 77f24ed)
  • Loading branch information
jelmer authored and Gerald (Jerry) Carter committed Oct 10, 2007
1 parent 34305d7 commit 40f85ac
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 69 deletions.
61 changes: 0 additions & 61 deletions source4/lib/ldb/tests/test-samba3sam.sh

This file was deleted.

10 changes: 5 additions & 5 deletions source4/script/tests/selftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cat >$CONFFILE<<EOF
ncalrpc dir = $NCALRPCDIR
lock dir = $LOCKDIR
setup directory = $SRCDIR/setup
js include = $SRCDIR/scripting/libjs
js include = $SRCDIR/scripting/libjs
name resolve order = bcast
interfaces = lo*
tls enabled = $TLS_ENABLED
Expand All @@ -107,10 +107,10 @@ cat >$CONFFILE<<EOF
[cifs]
read only = no
ntvfs handler = cifs
cifs:server = localhost
cifs:user = $USERNAME
cifs:password = $PASSWORD
cifs:domain = $DOMAIN
cifs:server = localhost
cifs:user = $USERNAME
cifs:password = $PASSWORD
cifs:domain = $DOMAIN
cifs:share = tmp
EOF

Expand Down
6 changes: 3 additions & 3 deletions source4/scripting/ejs/smbcalls_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static int ejs_sys_httptime(MprVarHandle eid, int argc, struct MprVar **argv)

/*
unlink a file
ok = unlink(fname);
ok = sys.unlink(fname);
*/
static int ejs_sys_unlink(MprVarHandle eid, int argc, char **argv)
{
Expand All @@ -154,7 +154,7 @@ static int ejs_sys_unlink(MprVarHandle eid, int argc, char **argv)
/*
load a file as a string
usage:
string = sys_file_load(filename);
string = sys.file_load(filename);
*/
static int ejs_sys_file_load(MprVarHandle eid, int argc, char **argv)
{
Expand All @@ -173,7 +173,7 @@ static int ejs_sys_file_load(MprVarHandle eid, int argc, char **argv)
/*
save a file from a string
usage:
ok = sys_file_save(filename, str);
ok = sys.file_save(filename, str);
*/
static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv)
{
Expand Down
3 changes: 3 additions & 0 deletions testdata/samba3/smbpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nobodypw:65534:B28BD20B0D3770EBAAD3B435B51404EE:B123AB4EC733F895B1260A3A08D9C69B:[NU ]:LCT-43148525:
rootpw:0:552902031BEDE9EFAAD3B435B51404EE:878D8014606CDA29677A44EFA1353FC7:[U ]:LCT-4314851B:
jelmerpw:1000:193130B61A7F81C0AAD3B435B51404EE:C2AE1FE6E648846352453E816F2AEB93:[U ]:LCT-4314850D:
78 changes: 78 additions & 0 deletions testprogs/ejs/samba3sam
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env smbscript

libinclude("base.js");
var sys = sys_init();
var s3url;
var s3 = ldb_init();
var ok;

if (ARGV.length == 2) {
s3url = ARGV[1];
ok = s3.connect(s3url);
assert(ok);
} else {
s3url = "tdb://samba3.ldb";
sys.unlink("samba3.ldb");
println("Adding samba3 LDIF...");
var s3 = ldb_init();
ok = s3.connect(s3url);
assert(ok);
var ldif = sys.file_load("../../testdata/samba3/samba3.ldif");
assert(ldif != undefined);
ok = s3.add(ldif);
assert(ok);
}

println("Initial samba4 LDIF...");
var s4 = ldb_init();
ok = s4.connect("tdb://samba4.ldb");
assert(ok);
ok = s4.add(sprintf("
dn: @MODULES
@LIST: samba3sam

dn: @MAP=samba3sam
@MAP_URL: %s", s3url));
assert(ok);

println("Looking up by non-mapped attribute");
msg = s4.search("(cn=Administrator)");
assert(msg.length == 1);

println("Looking up by mapped attribute");
msg = s4.search("(name=Backup Operators)");
assert(msg.length == 1);

println("Looking up by old name of renamed attribute");
msg = s4.search("(displayName=Backup Operators)");
assert(msg.length == 1);

println("Adding a record");
ok = s4.add("
dn: cn=Foo,dc=idealx,dc=org
unixName: root
lastLogon: 20000
cn: Foo
showInAdvancedViewOnly: TRUE
");
assert(ok);

println("Checking for existance of record");
msg = s4.search("(cn=Foo)", new Array('unixName','lastLogon','cn','showInAdvancedViewOnly'));
assert(msg.length == 1);

println("Checking for persistence of non-mappable attribute");
msg = s4.search("(cn=Foo)", new Array('showInAdvancedViewOnly'));
assert(msg.length == 1);

println("Adding record with mapped attribute in dn");
ok = s4.add("
dn: unixName=nobody,dc=idealx,dc=org
unixName: nobody
cn: Niemand
");
assert(ok);

println("Checking for existance of record (mapped)");
msg = s4.search("(unixName=nobody)", new Array('unixName','cn','dn'));
assert(msg.length == 1);

0 comments on commit 40f85ac

Please sign in to comment.