summaryrefslogtreecommitdiff
path: root/frontend/gamma/tests/tests/Clipperz/PM
Side-by-side diff
Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/PM') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/PIN.html66
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/PIN.test.js97
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/index.html1
3 files changed, 164 insertions, 0 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/PIN.html b/frontend/gamma/tests/tests/Clipperz/PM/PIN.html
new file mode 100644
index 0000000..a08b286
--- a/dev/null
+++ b/frontend/gamma/tests/tests/Clipperz/PM/PIN.html
@@ -0,0 +1,66 @@
+<!--
+
+Copyright 2008-2011 Clipperz Srl
+
+This file is part of Clipperz Community Edition.
+Clipperz Community Edition is an online password manager.
+For further information about its features and functionalities please
+refer to http://www.clipperz.com.
+
+* Clipperz Community Edition is free software: you can redistribute
+ it and/or modify it under the terms of the GNU Affero General Public
+ License as published by the Free Software Foundation, either version
+ 3 of the License, or (at your option) any later version.
+
+* Clipperz Community Edition is distributed in the hope that it will
+ be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU Affero General Public License for more details.
+
+* You should have received a copy of the GNU Affero General Public
+ License along with Clipperz Community Edition. If not, see
+ <http://www.gnu.org/licenses/>.
+
+-->
+
+<html>
+<head>
+ <title>Clipperz.PM.Proxy - TEST</title>
+
+ <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
+
+ <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
+
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
+<!--
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
+
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
+-->
+
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/PIN.js'></script>
+
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
+
+</head>
+<body>
+<pre id="test">
+ <script type="text/javascript" src="PIN.test.js"></script>
+</pre>
+</body>
+</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/PIN.test.js b/frontend/gamma/tests/tests/Clipperz/PM/PIN.test.js
new file mode 100644
index 0000000..ed795dd
--- a/dev/null
+++ b/frontend/gamma/tests/tests/Clipperz/PM/PIN.test.js
@@ -0,0 +1,97 @@
+/*
+
+Copyright 2008-2011 Clipperz Srl
+
+This file is part of Clipperz Community Edition.
+Clipperz Community Edition is an online password manager.
+For further information about its features and functionalities please
+refer to http://www.clipperz.com.
+
+* Clipperz Community Edition is free software: you can redistribute
+ it and/or modify it under the terms of the GNU Affero General Public
+ License as published by the Free Software Foundation, either version
+ 3 of the License, or (at your option) any later version.
+
+* Clipperz Community Edition is distributed in the hope that it will
+ be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU Affero General Public License for more details.
+
+* You should have received a copy of the GNU Affero General Public
+ License along with Clipperz Community Edition. If not, see
+ <http://www.gnu.org/licenses/>.
+
+*/
+
+Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
+
+Clipperz.PM.PIN['CREDENTIALS'] = 'TEST.CLIPPERZ.CREDENTIALS';
+Clipperz.PM.PIN['FAILURE_COUNT'] = 'TEST.CLIPPERZ.FAILED_LOGIN_COUNT';
+
+
+var tests = {
+
+ //-------------------------------------------------------------------------
+
+ 'clearCredentials': function () {
+ localStorage.removeItem(Clipperz.PM.PIN['CREDENTIALS']);
+ localStorage.removeItem(Clipperz.PM.PIN['FAILURE_COUNT']);
+ },
+
+ //-------------------------------------------------------------------------
+
+ 'isSet': function () {
+ tests.clearCredentials();
+
+ is(false, Clipperz.PM.PIN.isSet(), "after cleaning all values, credentials should not be set");
+
+ Clipperz.PM.PIN.setCredentialsWithPIN("1234", {'username':'joe', 'passphrase':'eoj'});
+ is(true, Clipperz.PM.PIN.isSet(), "once saved, they should be found");
+ },
+
+ 'recordFailedAttempt': function () {
+ tests.clearCredentials();
+
+ Clipperz.PM.PIN.setCredentialsWithPIN("1234", {'username':'joe', 'passphrase':'eoj'});
+ is(true, Clipperz.PM.PIN.isSet(), "once saved, they should be found");
+ Clipperz.PM.PIN.recordFailedAttempt();
+ is(true, Clipperz.PM.PIN.isSet(), "1st wrong PIN -> keep credentials");
+ Clipperz.PM.PIN.recordFailedAttempt();
+ is(true, Clipperz.PM.PIN.isSet(), "2nd wrong PIN -> keep credentials");
+ Clipperz.PM.PIN.recordFailedAttempt();
+ is(false, Clipperz.PM.PIN.isSet(), "3rd wrong PIN -> REMOVE credentials");
+
+ Clipperz.PM.PIN.setCredentialsWithPIN("1234", {'username':'joe', 'passphrase':'eoj'});
+ is(true, Clipperz.PM.PIN.isSet(), "once saved, they should be found");
+ Clipperz.PM.PIN.recordFailedAttempt();
+ is(true, Clipperz.PM.PIN.isSet(), "1st wrong PIN -> keep credentials");
+ Clipperz.PM.PIN.recordFailedAttempt();
+ is(true, Clipperz.PM.PIN.isSet(), "2nd wrong PIN -> keep credentials");
+ Clipperz.PM.PIN.resetFailedAttemptCount();
+ Clipperz.PM.PIN.recordFailedAttempt();
+ is(true, Clipperz.PM.PIN.isSet(), "3rd wrong PIN, but with a successful use in between -> keep credentials");
+ },
+
+ 'credentialsWithPIN': function () {
+ var credentials;
+ var pin;
+ var decryptedCredentials;
+
+ tests.clearCredentials();
+
+ credentials = {'username': 'joe', 'passphrase':'foobar'};
+ pin = '1234';
+ Clipperz.PM.PIN.setCredentialsWithPIN(pin, credentials);
+ decryptedCredentials = Clipperz.PM.PIN.credentialsWithPIN(pin);
+
+ is(decryptedCredentials['username'], credentials['username']);
+ is(decryptedCredentials['passphrase'], credentials['passphrase']);
+ },
+
+ //-------------------------------------------------------------------------
+ 'syntaxFix': MochiKit.Base.noop
+};
+
+//#############################################################################
+
+SimpleTest.runDeferredTests("Clipperz.PM.PIN", tests, {trace:false});
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/index.html b/frontend/gamma/tests/tests/Clipperz/PM/index.html
index b9bede1..c3df56a 100644
--- a/frontend/gamma/tests/tests/Clipperz/PM/index.html
+++ b/frontend/gamma/tests/tests/Clipperz/PM/index.html
@@ -45,6 +45,7 @@ TestRunner.runTests(
// 'CryptoPerformance_ByteArrayHex.html',
// 'CryptoPerformance_ByteArrayString.html',
'Date.html',
+ 'PIN.html',
'Proxy.html',
'Toll.html'
);