diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-09-11 16:47:45 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-09-12 08:51:07 +0200 |
commit | 7e671ae37f6c951d4db18c446eed52685200b2e0 (patch) | |
tree | c9c3713d27ac0374c08d2b99f7968969bd67c69e /swat2/esptest | |
parent | acf11ddd5fbb9e4b0b780f4f95957d79fcc6fcf1 (diff) | |
download | samba-7e671ae37f6c951d4db18c446eed52685200b2e0.tar.gz samba-7e671ae37f6c951d4db18c446eed52685200b2e0.tar.bz2 samba-7e671ae37f6c951d4db18c446eed52685200b2e0.zip |
rename swat => swat2, so that we don't conflict with samba3
metze
(This used to be commit bf852a3dbeee8900fa36978f08a5cdceabcbd926)
Diffstat (limited to 'swat2/esptest')
-rw-r--r-- | swat2/esptest/exception.esp | 32 | ||||
-rw-r--r-- | swat2/esptest/formtest.esp | 35 | ||||
-rw-r--r-- | swat2/esptest/include.esp | 14 | ||||
-rw-r--r-- | swat2/esptest/index.esp | 7 | ||||
-rw-r--r-- | swat2/esptest/ldb.esp | 36 | ||||
-rw-r--r-- | swat2/esptest/loadparm.esp | 75 | ||||
-rw-r--r-- | swat2/esptest/qooxdoo.esp | 133 | ||||
-rw-r--r-- | swat2/esptest/registry.esp | 50 | ||||
-rw-r--r-- | swat2/esptest/samr.esp | 36 | ||||
-rw-r--r-- | swat2/esptest/session.esp | 53 | ||||
-rw-r--r-- | swat2/esptest/showvars.esp | 24 |
11 files changed, 495 insertions, 0 deletions
diff --git a/swat2/esptest/exception.esp b/swat2/esptest/exception.esp new file mode 100644 index 0000000000..ff28d6318e --- /dev/null +++ b/swat2/esptest/exception.esp @@ -0,0 +1,32 @@ +<% page_header("columns", "ESP Exception test", "esptest"); + include("/scripting/forms.js"); +%> + +<h1>Samba4 exception test</h1> + + +<% +var f = FormObj("ExceptionTest", 0, 2); +f.submit[0] = "Generate Exception"; +f.submit[1] = "No Exception"; + +f.display(); + +if (request['REQUEST_METHOD'] == "POST") { + function TestFunction(arg1, arg2) { + return "OK"; + } + + if (form['submit'] == "Generate Exception") { + write("I expect you to die Mr Bond!<br>\n"); + TestFunction("foo"); + } else { + write("no exception<br>\n"); + TestFunction("foo", "bar"); + } +} +%> + +and here is some filler text ... + +<% page_footer(); %> diff --git a/swat2/esptest/formtest.esp b/swat2/esptest/formtest.esp new file mode 100644 index 0000000000..2310849895 --- /dev/null +++ b/swat2/esptest/formtest.esp @@ -0,0 +1,35 @@ +<% page_header("columns", "ESP Form Test", "esptest"); + include("/scripting/forms.js"); +%> + +<% +var f = FormObj("FormTest", 3, 2); +f.element[0].label = "First Name"; +f.element[0].name = "firstName"; +f.element[0].value = form['firstName']; +f.element[1].label = "Last Name"; +f.element[1].name = "lastName"; +f.element[1].value = form['lastName']; +f.element[2].label = "Color"; +f.element[2].type = "select"; +f.element[2].list = new Array("Red", "Green", "Blue", "Yellow"); +f.element[2].value = form['Color']; +f.submit[0] = "OK"; +f.submit[1] = "Cancel"; + +f.display(); + +<% + /* if its a post then the user has filled in the form, so + report the values + */ + if (form['submit'] == "OK") { +%> + You chose firstName=@@form['firstName'] lastName=@@form['lastName']<p> + +<% + simple_table(form); + } +%> + +<% page_footer(); %> diff --git a/swat2/esptest/include.esp b/swat2/esptest/include.esp new file mode 100644 index 0000000000..5d558d59dc --- /dev/null +++ b/swat2/esptest/include.esp @@ -0,0 +1,14 @@ +<% page_header("columns", "ESP Include Test", "esptest"); %> + +including /scripting/test.ejs<p/> +<% include("/scripting/test.ejs"); %> +calling a function from test.ejs ...<p/> +<% showArray("request", request); %> + +including /scripting/test.esp<p/> +<% include /scripting/test.esp %> +calling a function from test.esp ...<p/> +<% res = testfn('foo'); %> +result is: @@res + +<% page_footer(); %> diff --git a/swat2/esptest/index.esp b/swat2/esptest/index.esp new file mode 100644 index 0000000000..663f82c599 --- /dev/null +++ b/swat2/esptest/index.esp @@ -0,0 +1,7 @@ +<% page_header("columns", "ESP Tests", "esptest"); %> + +<h1>ESP Test functions</h1> + +Please select a menu item from the selection on the left + +<% page_footer(); %> diff --git a/swat2/esptest/ldb.esp b/swat2/esptest/ldb.esp new file mode 100644 index 0000000000..cf2725fbcf --- /dev/null +++ b/swat2/esptest/ldb.esp @@ -0,0 +1,36 @@ +<% page_header("columns", "ESP ldb test", "esptest"); %> + +<h1>Samba4 ldb test</h1> + +<h3>An attribute constrained search</h3> + +<% +var lp = loadparm_init(); +var dbfile = lp.get("sam database"); +var attrs = new Array("name", "dnsDomain", "objectSid", "dn"); +var ldb = ldb_init(); +ldb.session_info = session.authinfo.session_info; + +var ok = ldb.connect(dbfile); +assert(ok); + +res = ldb.search("(objectClass=domain)", NULL, ldb.SCOPE_DEFAULT, attrs); +multi_table(res, "dn"); +%> + +<h3>An unconstrained search</h3> + +<% +res = ldb.search("(objectClass=user)"); +multi_table(res, "dn"); +%> + +<h3>A search with bad arguments</h3> + +<% +res = ldb.search("=blah", "foo"); +%> + +all done + +<% page_footer() %> diff --git a/swat2/esptest/loadparm.esp b/swat2/esptest/loadparm.esp new file mode 100644 index 0000000000..9581af0262 --- /dev/null +++ b/swat2/esptest/loadparm.esp @@ -0,0 +1,75 @@ +<% page_header("columns", "ESP loadparm test", "esptest" ); + include("/scripting/forms.js"); +%> + +<h1>Samba4 loadparm test</h1> + +<% +lp = loadparm_init(); + +var f = FormObj("LoadparmTest", 2, 1); +f.element[0].label = "Share"; +f.element[1].label = "Parameter"; +f.submit[0] = "OK"; + +f.display(); + +function stringVar(v) { + var type = typeof(v); + var ret = ""; + if (type == "object") { + for (val in v) { + ret = ret + " " + v[val]; + } + } else { + ret = ret + v; + } + return ret; +} + +function showValue(name, v) { + write("parameter:" + name + "<br>\n"); + write("Type is: " + typeof(v) + "<br>\n"); + write("Value is: " + stringVar(v) + "<p>\n"); +} + + +if (request['REQUEST_METHOD'] == "POST") { + /* if they cancelled then take them back to the list of tests */ + if (form['submit'] == "Cancel") { + redirect("/"); + } + + var v; + + share = form['Share']; + name = form['Parameter']; + if (share && name) { + v = lp.get(share, name); + } else if (name) { + v = lp.get(name); + } + + showValue(name, v); +} +%> + +Here are some commonly used parameters:<p> + +<% +showValue("defined services", lp.services()); + +function showParameter(name) { + showValue(name, lp.get(name)); +} + +showParameter("server services"); +showParameter("netbios name"); +showParameter("security"); +showParameter("workgroup"); +showParameter("log level"); +showParameter("server signing"); +showParameter("interfaces"); +%> + +<% page_footer(); %> diff --git a/swat2/esptest/qooxdoo.esp b/swat2/esptest/qooxdoo.esp new file mode 100644 index 0000000000..554a4e90d5 --- /dev/null +++ b/swat2/esptest/qooxdoo.esp @@ -0,0 +1,133 @@ +<% +/******************************/ +/* server side AJAJ functions */ +libinclude("server_call.js"); + +/* this is a call that the client js code can make - it just adds + some more elements to the passed object, then returns the object */ +function testfunc(x) { + var sys = sys_init(); + x.nttime = sys.nttime(); + x.timestring = sys.httptime(x.nttime); + return x; +} + +/* register a call for clients to make */ +var call = servCallObj(); +call.add('testfunc', testfunc); + +/* run the function that was asked for */ +call.run(); + + /***********************/ + /* now the main page */ + page_header("columns", "ESP qooxdoo test", "esptest"); +%> + +<script type="text/javascript" src="/scripting/client/encoder.js"></script> +<script type="text/javascript" src="/scripting/client/call.js"></script> + +<h1>Samba4 qooxdoo test</h1> + + <script type="text/javascript"> + + window.application.main = function() + { + var inlineWidget = new QxInline; + var fieldSet = new QxFieldSet("thefieldset"); + + with(fieldSet) + { + setWidth("40%"); + setMinHeight(400); + setBottom(48); + setMinWidth(500); + }; + + var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%"); + gl.setEdge(0); + gl.setCellPaddingTop(3); + gl.setCellPaddingBottom(3); + + inlineWidget.add(fieldSet); + + var d = this.getClientWindow().getDocument(); + + var stopit = 0; + var shared = new Object(); + + function callback(o) { + shared = o; + var r = "Response:\\n"; + for (var i in shared) { + r = r + "\\t" + i + " : " + shared[i] + "\\n"; + } + ta.setText(r); + if (shared.start_time == 0) { + shared.start_time = shared.nttime; + } + shared.time_diff = shared.nttime - shared.start_time; + shared.rate = shared.counter / (shared.time_diff * 0.0000001); + shared.counter++; + if (stopit == 0) { + server_call_url("@@request.REQUEST_URI", 'testfunc', callback, shared); + } + } + + function start_call() { + srv_printf("Starting calls ... (stopit=%d)\\n", stopit); + stopit = 0; + shared.counter = 0; + shared.start_time = 0; + server_call_url("@@request.REQUEST_URI", 'testfunc', callback, shared); + }; + + function stop_call() { + srv_printf("Stopping calls\\n"); + stopit = 1; + }; + + function myButton(name, label, call) { + var b = new QxButton(label); + b.setWidth("25%"); + b.addEventListener("click", call); + return b; + }; + + function myCheckBox(label, name, value) { + var w = new QxCheckBox(label, value, name, value); + w.setWidth("100%"); + return w; + } + + var c1 = myCheckBox("Enable The Server", 'checkbox1', false); + var c2 = myCheckBox("Another Server", 'checkbox2', true); + var t3 = new QxTextField("hello"); + var b1 = myButton("send", "Make Call", start_call); + var b2 = myButton("stop", "Stop Call", stop_call); + var ta = new QxTextArea; + ta.setText("initial text"); + ta.setWidth("80%"); + ta.setHeight(150); + ta.setVerticalAlign("top"); + + gl.add(c1, { row : 1, col : 1 }); + gl.add(c2, { row : 2, col : 1 }); + gl.add(t3, { row : 3, col : 1, scaleHorizontal: true }); + gl.add(b1, { row : 4, col : 1 }); + gl.add(ta, { row : 5, col : 1 }); + gl.add(b2, { row : 6, col : 1 }); + + fieldSet.add(gl); + + inlineWidget.add(fieldSet); + + d.add(inlineWidget, "canvas"); + }; + + </script> + + + <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div> + +<% page_footer(); %> diff --git a/swat2/esptest/registry.esp b/swat2/esptest/registry.esp new file mode 100644 index 0000000000..efdfefc37e --- /dev/null +++ b/swat2/esptest/registry.esp @@ -0,0 +1,50 @@ +<% + page_header("columns", "ESP registry edit", "esptest"); +%> + +<script type="text/javascript" src="/scripting/client/encoder.js"></script> +<script type="text/javascript" src="/scripting/client/call.js"></script> +<script type="text/javascript" src="/scripting/client/regedit.js"></script> + +<h1>Registry Editor</h1> + +<script type="text/javascript"> + +/*** init the page for qooxdoo ***/ +window.application.main = function() +{ + var doc = this.getClientWindow().getDocument(); + var inlineWidget = new QxInline; + var qwidget = new QxWidget; + qwidget.setHeight(800); + qwidget.setWidth("100%"); + qwidget.setBorder(QxBorder.presets.groove); + + var btn1 = new QxButton("Registry Editor"); + btn1.set({ top: 20, left : 30 }); + btn1.addEventListener("click", function() { + var regWindow = new QxWindow("Registry Editor"); + with(regWindow) { + setTop(50); + setLeft(50); + setMinWidth(600); + setMinHeight(600); + setResizeMethod("frame"); + } + + var regedit = regedit_widget("ncalrpc:"); + regWindow.add(regedit); + qwidget.add(regWindow); + regWindow.setVisible(true); + + }); + qwidget.add(btn1); + inlineWidget.add(qwidget); + doc.add(inlineWidget, "canvas"); +} + +</script> + +<div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div> + +<% page_footer(); %> diff --git a/swat2/esptest/samr.esp b/swat2/esptest/samr.esp new file mode 100644 index 0000000000..a60a02e7c8 --- /dev/null +++ b/swat2/esptest/samr.esp @@ -0,0 +1,36 @@ +<% page_header("columns", "ESP samr test", "esptest"); + + libinclude("base.js"); + libinclude("samr.js"); +%> + +<h1>Samba4 samr rpc test</h1> + +<% +var conn = samr_init(); +var binding = "ncalrpc:"; +status = conn.connect(binding); +check_status_ok(status); + +handle = samrConnect(conn); + +domains = samrEnumDomains(conn, handle); + +for (i=0;i<domains.length;i++) { + write("<h2>Domain " + domains[i].name + "</h2>\n"); + sid = samrLookupDomain(conn, handle, domains[i].name); + dom_handle = samrOpenDomain(conn, handle, sid); + users = samrEnumDomainUsers(conn, dom_handle); + samrFillUserInfo(conn, dom_handle, users, 3); + if (users.length == 0) { + write("no users in domain<br>\n"); + } else { + multi_table(users, "name"); + } + samrClose(conn, dom_handle); +} + +%> + + +<% page_footer(); %> diff --git a/swat2/esptest/session.esp b/swat2/esptest/session.esp new file mode 100644 index 0000000000..6213dde62f --- /dev/null +++ b/swat2/esptest/session.esp @@ -0,0 +1,53 @@ +<% page_header("columns", "ESP session test", "esptest"); + include("/scripting/forms.js"); +%> + +<h1>Samba4 session test</h1> + +<% +var f = FormObj("SessionTest", 3, 4); +f.element[0].label = "Name"; +f.element[1].label = "Value"; +f.element[2].label = "Timeout"; +f.submit[0] = "Append"; +f.submit[1] = "Reset"; +f.submit[2] = "Destroy"; +f.submit[3] = "Cancel"; + +f.display(); + + /* if its a post then the user has filled in the form, so + report the values + */ +if (request['REQUEST_METHOD'] == "POST") { + /* if they cancelled then take them back to the list of tests */ + if (form['submit'] == "Cancel") { + redirect("/"); + } + + name = form['Name']; + value = form['Value']; + timeout = form['Timeout']; + + if (timeout) { + useSession(timeout); + } + + if (form['submit'] == "Reset" && name) { + session[name] = null; + } + + if (form['submit'] == "Append" && name) { + session[name] = "" + session[name] + value; + } + + if (form['submit'] == "Destroy") { + destroySession(); + } +} + +simple_table(session); +write("SessionId=" + request['SESSION_ID'] + "<br/>\n"); +%> + +<% page_footer(); %> diff --git a/swat2/esptest/showvars.esp b/swat2/esptest/showvars.esp new file mode 100644 index 0000000000..dc55b1e58b --- /dev/null +++ b/swat2/esptest/showvars.esp @@ -0,0 +1,24 @@ +<% page_header("columns", "ESP standard variables test", "esptest"); %> + +<h1>Samba4 showvars test</h1> + +<% + function showArray(name, array) { + write("<h3>Array: " + name + "</h3>\n"); + if (array == undefined) { + write("undefined<br>\n"); + } else { + simple_table(array); + } + } + + showArray("headers", headers); + showArray("application", application); + showArray("cookies", cookies); + showArray("files", files); + showArray("request", request); + showArray("server", server); + showArray("session", session); +%> + +<% page_footer(); %> |