aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/form/tests/test_PasswordValidator.html
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/form/tests/test_PasswordValidator.html
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/form/tests/test_PasswordValidator.html')
-rw-r--r--includes/js/dojox/form/tests/test_PasswordValidator.html216
1 files changed, 216 insertions, 0 deletions
diff --git a/includes/js/dojox/form/tests/test_PasswordValidator.html b/includes/js/dojox/form/tests/test_PasswordValidator.html
new file mode 100644
index 0000000..e3b1e63
--- /dev/null
+++ b/includes/js/dojox/form/tests/test_PasswordValidator.html
@@ -0,0 +1,216 @@
+<html>
+ <head>
+ <script type="text/javascript"
+ src="../../../dojo/dojo.js"
+ djConfig="isDebug: true, parseOnLoad: true">
+ </script>
+ <script type="text/javascript">
+ dojo.require("doh.runner");
+ dojo.require("dojo.parser");
+ dojo.require("dojox.form.PasswordValidator");
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.Form");
+
+ dojo.addOnLoad(function(){
+ doh.register("tests",
+ [
+ function test_setDisabled(t){
+ valid1.setAttribute("disabled", true);
+ t.t(dojo.every(dojo.query("[widgetId]",
+ valid1.domNode).map(function(i){
+ return dijit.byNode(i);
+ }), function(i){return i.disabled;}));
+ valid1.setAttribute("disabled", false);
+ t.t(dojo.every(dojo.query("[widgetId]",
+ valid1.domNode).map(function(i){
+ return dijit.byNode(i);
+ }), function(i){return !i.disabled;}));
+ },
+ function test_isValid(t){
+ t.f(form1.isValid());
+ dijit.byId("nv1").setValue("test");
+ dijit.byId("vv1").setValue("Test");
+ t.f(form1.isValid());
+ dijit.byId("vv1").setValue("test");
+ t.t(form1.isValid());
+ t.t(form6.isValid());
+ t.is({password: ""}, form6.getValues());
+ dijit.byId("nv6").setValue("test");
+ t.f(form6.isValid());
+ t.is({password: ""}, form6.getValues());
+ dijit.byId("vv6").setValue("test");
+ t.t(form6.isValid());
+ t.is({password: "test"}, form6.getValues());
+ },
+ function test_getValue(t){
+ dijit.byId("nv1").setValue("test");
+ dijit.byId("vv1").setValue("Test");
+ t.is({password: ""}, form1.getValues());
+ dijit.byId("vv1").setValue("test123");
+ dijit.byId("nv1").setValue("test123");
+ t.is({password: "test123"}, form1.getValues());
+ },
+ function test_oldPW(t){
+ dijit.byId("nv2").setValue("test");
+ dijit.byId("vv2").setValue("test");
+ t.f(form2.isValid());
+ dijit.byId("ov2").setValue("oldpw4");
+ t.f(form2.isValid());
+ dijit.byId("ov2").setValue("oldpw2");
+ t.t(form2.isValid());
+ },
+ function test_getOldValue(t){
+ t.is({password: "test"}, form2.getValues());
+ dijit.byId("nv3").setValue("test");
+ dijit.byId("vv3").setValue("test");
+ dijit.byId("ov3").setValue("oldpw4");
+ t.is({password: "", oldPassword: ""}, form3.getValues());
+ dijit.byId("ov3").setValue("oldpw3");
+ dijit.byId("vv3").setValue("Test");
+ t.is({password: "", oldPassword: ""}, form3.getValues());
+ dijit.byId("vv3").setValue("test");
+ t.is({password: "test", oldPassword: "oldpw3"}, form3.getValues());
+ },
+ function test_getValuesInTable(t){
+ dijit.byId("nv4").setValue("test");
+ dijit.byId("vv4").setValue("test");
+ dijit.byId("ov4").setValue("oldpw4");
+ t.is({password: "test"}, form4.getValues());
+ dijit.byId("nv5").setValue("test");
+ dijit.byId("vv5").setValue("test");
+ dijit.byId("ov5").setValue("oldpw5");
+ t.is({password: "test", oldPassword: "oldpw5"}, form5.getValues());
+ }
+ ]
+ );
+ doh.run();
+ });
+ </script>
+ <link rel="stylesheet" type="text/css" href="../../../dijit/themes/tundra/tundra.css">
+ <link rel="stylesheet" type="text/css" href="../../../dijit/tests/css/dijitTests.css">
+ </head>
+ <body class="tundra">
+ <h1 class="testTitle">Test: dojox.form.PasswordValidator</h1>
+ <h2>Automated test</h2>
+ <h4 class="testSubtitle">No old password</h4>
+ <form dojoType="dijit.form.Form" jsId="form1">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid1" name="password">
+ <label>Password: <input type="password" id="nv1" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv1" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">Old password (hard-coded to "oldpw2") - not passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form2">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid2" name="password">
+ <script type="dojo/method" event="pwCheck" args="password">
+ /*
+ NOTE: Do NOT EVER EVER EVER do this sort of a check!!!
+
+ This is only as an example. You will probably want to
+ override the pwCheck function to callback to a server to
+ verify the password (the callback will need to be
+ syncronous) - and it's probably a good idea to validate
+ it again on form submission before actually doing
+ anything destructive - that's why the "oldName" value
+ is there.
+
+ And don't just fetch the password from the server
+ either :) Send the test password (probably hashed, for
+ security) and return from the server a status instead.
+
+ Again - DON'T DO THIS - it is HORRIBLY INSECURE!!!!
+
+ Security is left as an exercise to the reader :)
+ */
+ return password === "oldpw2";
+ </script>
+ <label>Old Password: <input type="password" id="ov2" pwType="old" /></label><br>
+ <label>Password: <input type="password" id="nv2" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv2" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">Old password (hard-coded to "oldpw3") - passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form3">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid3" name="password" oldName="oldPassword">
+ <script type="dojo/method" event="pwCheck" args="password">
+ console.log("Checking " + password);
+ return password === "oldpw3";
+ </script>
+ <label>Old Password: <input type="password" id="ov3" pwType="old" /></label><br>
+ <label>Password: <input type="password" id="nv3" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv3" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">In Table, Old password (hard-coded to "oldpw4") - not passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form4">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid4" name="password">
+ <script type="dojo/method" event="pwCheck" args="password">
+ return password === "oldpw4";
+ </script>
+ <table>
+ <tr>
+ <td><label for="ov4">Old Password:</label></td>
+ <td><input type="password" id="ov4" pwType="old" /></td>
+ </tr>
+ <tr>
+ <td><label for="nv4">Password:</label></td>
+ <td><input type="password" id="nv4" pwType="new" /></td>
+ </tr>
+ <tr>
+ <td><label for="vv4">Validate:</label></td>
+ <td><input type="password" id="vv4" pwType="verify" /></td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">In Table, Old password (hard-coded to "oldpw5") - passed to getValues</h4>
+ <form dojoType="dijit.form.Form" jsId="form5">
+ <div dojoType="dojox.form.PasswordValidator" jsId="valid5" name="password" oldName="oldPassword">
+ <script type="dojo/method" event="pwCheck" args="password">
+ return password === "oldpw5";
+ </script>
+ <table>
+ <tr>
+ <td><label for="ov5">Old Password:</label></td>
+ <td><input type="password" id="ov5" pwType="old" /></td>
+ </tr>
+ <tr>
+ <td><label for="nv5">Password:</label></td>
+ <td><input type="password" id="nv5" pwType="new" /></td>
+ </tr>
+ <tr>
+ <td><label for="vv5">Validate:</label></td>
+ <td><input type="password" id="vv5" pwType="verify" /></td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ <hr>
+ <h4 class="testSubtitle">No old password, not required</h4>
+ <form dojoType="dijit.form.Form" jsId="form6">
+ <div dojoType="dojox.form.PasswordValidator" required="false" jsId="valid6" name="password">
+ <label>Password: <input type="password" id="nv6" pwType="new" /></label><br>
+ <label>Validate: <input type="password" id="vv6" pwType="verify" /></label><br>
+ </div>
+ </form>
+ <hr>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ dojo.forEach([form1, form2, form3, form4, form5, form6], function(i){
+ console.dir(i.getValues());
+ });
+ </script>
+ Get Values
+ </button>
+ <button dojoType="dijit.form.Button">
+ <script type="dojo/method" event="onClick">
+ valid5.setAttribute("disabled", !valid5.disabled);
+ </script>
+ Toggle Disabled
+ </button>
+ </body>
+</html>