diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-11 00:23:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:19:33 -0500 |
commit | f9ff72cbda6b4e59448fd79ef9e12f264d48015f (patch) | |
tree | d0bff5e1f6ae70bb9ba3ec563c7ed03cf0cc5fa2 | |
parent | b2f132182174d13c8bcb535f62522687675947c2 (diff) | |
download | samba-f9ff72cbda6b4e59448fd79ef9e12f264d48015f.tar.gz samba-f9ff72cbda6b4e59448fd79ef9e12f264d48015f.tar.xz samba-f9ff72cbda6b4e59448fd79ef9e12f264d48015f.zip |
r8298: - started building a library of js routines in scripting/libjs/
- switched the existing test programs over to using the library
- added install of js lib
(This used to be commit 2a444dedbe44347268affc6458196f93ca7d372b)
-rw-r--r-- | source4/build/smb_build/makefile.pm | 2 | ||||
-rw-r--r-- | source4/script/installswat.sh | 7 | ||||
-rwxr-xr-x | source4/script/tests/selftest.sh | 1 | ||||
-rw-r--r-- | source4/scripting/libjs/base.js | 53 | ||||
-rw-r--r-- | source4/scripting/libjs/samr.js (renamed from swat/scripting/samr.js) | 41 | ||||
-rwxr-xr-x | testprogs/ejs/echo.js | 43 | ||||
-rwxr-xr-x | testprogs/ejs/samr.js | 122 |
7 files changed, 111 insertions, 158 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index a32a93af0ae..2edda7408e5 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -696,7 +696,7 @@ installdat: installdirs @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir) installswat: installdirs - @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) + @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) $(DESTDIR)$(LIBDIR) installman: installdirs @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES) diff --git a/source4/script/installswat.sh b/source4/script/installswat.sh index 1d89c2e86c8..05245d8f06f 100644 --- a/source4/script/installswat.sh +++ b/source4/script/installswat.sh @@ -2,6 +2,7 @@ SWATDIR=$1 SRCDIR=$2 +LIBDIR=$3 echo Installing swat files in $SWATDIR @@ -26,6 +27,12 @@ installdir scripting/*.ejs scripting/*.esp scripting/*.js installdir style/*.css installdir docs/*.js + +echo "Installing js libs" +cd ../source/scripting || exit 1 +mkdir -p $LIBDIR/js +cp libjs/*.js $LIBDIR/js + cat << EOF ====================================================================== The swat files have been installed. diff --git a/source4/script/tests/selftest.sh b/source4/script/tests/selftest.sh index 2993b0590e5..5e94ea13e24 100755 --- a/source4/script/tests/selftest.sh +++ b/source4/script/tests/selftest.sh @@ -68,6 +68,7 @@ cat >$CONFFILE<<EOF pid directory = $PIDDIR ncalrpc dir = $NCALRPCDIR lock dir = $LOCKDIR + js include = $LIBDIR/js name resolve order = bcast interfaces = lo* diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js new file mode 100644 index 00000000000..504cd822597 --- /dev/null +++ b/source4/scripting/libjs/base.js @@ -0,0 +1,53 @@ +/* + base js library functions + Copyright Andrew Tridgell 2005 + released under the GNU GPL v2 or later +*/ + +if (global["HAVE_BASE_JS"] != undefined) { + return; +} +HAVE_BASE_JS=1 + +/* + helper function to setup a rpc io object, ready for input +*/ +function irpcObj() +{ + var o = new Object(); + o.input = new Object(); + return o; +} + +/* + check that a status result is OK +*/ +function check_status_ok(status) +{ + if (status.is_ok != true) { + printVars(status); + } + assert(status.is_ok == true); +} + +/* + check that two arrays are equal +*/ +function check_array_equal(a1, a2) +{ + assert(a1.length == a2.length); + for (i=0; i<a1.length; i++) { + assert(a1[i] == a2[i]); + } +} + +/* + check that an array is all zeros +*/ +function check_array_zero(a) +{ + for (i=0; i<a.length; i++) { + assert(a[i] == 0); + } +} + diff --git a/swat/scripting/samr.js b/source4/scripting/libjs/samr.js index 474e7045503..a1f79b541a4 100644 --- a/swat/scripting/samr.js +++ b/source4/scripting/libjs/samr.js @@ -1,27 +1,13 @@ /* samr rpc utility functions + Copyright Andrew Tridgell 2005 + released under the GNU GPL v2 or later */ -/* - helper function to setup a rpc io object, ready for input -*/ -function irpcObj() -{ - var o = new Object(); - o.input = new Object(); - return o; -} - -/* - check that a status result is OK -*/ -function check_status_ok(status) -{ - if (status.is_ok != true) { - printVars(status); - } - assert(status.is_ok == true); +if (global["HAVE_SAMR_JS"] != undefined) { + return; } +HAVE_SAMR_JS=1 /* return a list of names and indexes from a samArray @@ -122,6 +108,21 @@ function samrEnumDomainUsers(conn, dom_handle) } /* + return a list of all groups +*/ +function samrEnumDomainGroups(conn, dom_handle) +{ + var io = irpcObj(); + io.input.domain_handle = dom_handle; + io.input.resume_handle = 0; + io.input.acct_flags = 0; + io.input.max_size = -1; + status = dcerpc_samr_EnumDomainGroups(conn, io); + check_status_ok(status); + return samArray(io.output); +} + +/* return a list of domains */ function samrEnumDomains(conn, handle) @@ -165,3 +166,5 @@ function samrFillUserInfo(conn, dom_handle, users, level) samrClose(conn, user_handle); } } + + diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js index 4f0fc79f9ac..312e599d50b 100755 --- a/testprogs/ejs/echo.js +++ b/testprogs/ejs/echo.js @@ -3,16 +3,7 @@ test echo pipe calls from ejs */ - -/* - helper function to setup a rpc io object, ready for input -*/ -function irpcObj() -{ - var o = new Object(); - o.input = new Object(); - return o; -} +libinclude("base.js"); /* generate a ramp as an integer array @@ -28,38 +19,6 @@ function ramp_array(N) /* - check that a status result is OK -*/ -function check_status_ok(status) -{ - if (status.is_ok != true) { - printVars(status); - } - assert(status.is_ok == true); -} - -/* - check that two arrays are equal -*/ -function check_array_equal(a1, a2) -{ - assert(a1.length == a2.length); - for (i=0; i<a1.length; i++) { - assert(a1[i] == a2[i]); - } -} - -/* - check that an array is all zeros -*/ -function check_array_zero(a) -{ - for (i=0; i<a.length; i++) { - assert(a[i] == 0); - } -} - -/* test the echo_AddOne interface */ function test_AddOne(conn) diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js index ec2096b8180..1c613d56197 100755 --- a/testprogs/ejs/samr.js +++ b/testprogs/ejs/samr.js @@ -3,65 +3,28 @@ test samr calls from ejs */ +libinclude("base.js"); +libinclude("samr.js"); +libinclude("samr.js"); -/* - helper function to setup a rpc io object, ready for input -*/ -function irpcObj() -{ - var o = new Object(); - o.input = new Object(); - return o; -} - -/* - check that a status result is OK -*/ -function check_status_ok(status) -{ - if (status.is_ok != true) { - printVars(status); - } - assert(status.is_ok == true); -} /* test the samr_Connect interface */ function test_Connect(conn) { - var io = irpcObj(); print("Testing samr_Connect\n"); - io.input.system_name = NULL; - io.input.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - status = dcerpc_samr_Connect(conn, io); - check_status_ok(status); - return io.output.connect_handle; + return samrConnect(conn); } -/* - test the samr_Close interface -*/ -function test_Close(conn, handle) -{ - var io = irpcObj(); - io.input.handle = handle; - status = dcerpc_samr_Close(conn, io); - check_status_ok(status); -} /* test the samr_LookupDomain interface */ function test_LookupDomain(conn, handle, domain) { - var io = irpcObj(); print("Testing samr_LookupDomain\n"); - io.input.connect_handle = handle; - io.input.domain_name = domain; - status = dcerpc_samr_LookupDomain(conn, io); - check_status_ok(status); - return io.output.sid; + return samrLookupDomain(conn, handle, domain); } /* @@ -69,14 +32,8 @@ function test_LookupDomain(conn, handle, domain) */ function test_OpenDomain(conn, handle, sid) { - var io = irpcObj(); print("Testing samr_OpenDomain\n"); - io.input.connect_handle = handle; - io.input.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - io.input.sid = sid; - status = dcerpc_samr_OpenDomain(conn, io); - check_status_ok(status); - return io.output.domain_handle; + return samrOpenDomain(conn, handle, sid); } /* @@ -84,21 +41,12 @@ function test_OpenDomain(conn, handle, sid) */ function test_EnumDomainUsers(conn, dom_handle) { - var i, io = irpcObj(); + var i, users; print("Testing samr_EnumDomainUsers\n"); - io.input.domain_handle = dom_handle; - io.input.resume_handle = 0; - io.input.acct_flags = 0; - io.input.max_size = -1; - status = dcerpc_samr_EnumDomainUsers(conn, io); - check_status_ok(status); - print("Found " + io.output.num_entries + " users\n"); - if (io.output.sam == NULL) { - return; - } - var entries = io.output.sam.entries; - for (i=0;i<io.output.num_entries;i++) { - print("\t" + entries[i].name + "\n"); + users = samrEnumDomainUsers(conn, dom_handle); + print("Found " + users.length + " users\n"); + for (i=0;i<users.length;i++) { + println("\t" + users[i].name + "\t(" + users[i].idx + ")"); } } @@ -107,21 +55,11 @@ function test_EnumDomainUsers(conn, dom_handle) */ function test_EnumDomainGroups(conn, dom_handle) { - var i, io = irpcObj(); print("Testing samr_EnumDomainGroups\n"); - io.input.domain_handle = dom_handle; - io.input.resume_handle = 0; - io.input.acct_flags = 0; - io.input.max_size = -1; - status = dcerpc_samr_EnumDomainGroups(conn, io); - check_status_ok(status); - print("Found " + io.output.num_entries + " groups\n"); - if (io.output.sam == NULL) { - return; - } - var entries = io.output.sam.entries; - for (i=0;i<io.output.num_entries;i++) { - print("\t" + entries[i].name + "\n"); + var i, groups = samrEnumDomainGroups(conn, dom_handle); + print("Found " + groups.length + " groups\n"); + for (i=0;i<groups.length;i++) { + println("\t" + groups[i].name + "\t(" + groups[i].idx + ")"); } } @@ -141,28 +79,20 @@ function test_domain_ops(conn, dom_handle) */ function test_EnumDomains(conn, handle) { - var i, io = irpcObj(); + var i, domains; print("Testing samr_EnumDomains\n"); - io.input.connect_handle = handle; - io.input.resume_handle = 0; - io.input.buf_size = -1; - status = dcerpc_samr_EnumDomains(conn, io); - check_status_ok(status); - print("Found " + io.output.num_entries + " domains\n"); - if (io.output.sam == NULL) { - return; - } - var entries = io.output.sam.entries; - for (i=0;i<io.output.num_entries;i++) { - print("\t" + entries[i].name + "\n"); + + domains = samrEnumDomains(conn, handle); + print("Found " + domains.length + " domains\n"); + for (i=0;i<domains.length;i++) { + print("\t" + domains[i].name + "\n"); } - for (i=0;i<io.output.num_entries;i++) { - domain = entries[i].name; - print("Testing domain " + domain + "\n"); - sid = test_LookupDomain(conn, handle, domain); + for (i=0;i<domains.length;i++) { + print("Testing domain " + domains[i].name + "\n"); + sid = samrLookupDomain(conn, handle, domains[i].name); dom_handle = test_OpenDomain(conn, handle, sid); test_domain_ops(conn, dom_handle); - test_Close(conn, dom_handle); + samrClose(conn, dom_handle); } } @@ -185,7 +115,7 @@ if (status.is_ok != true) { handle = test_Connect(conn); test_EnumDomains(conn, handle); -test_Close(conn, handle); +samrClose(conn, handle); print("All OK\n"); return 0; |