summaryrefslogtreecommitdiff
path: root/frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js
Unidiff
Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js b/frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js
new file mode 100644
index 0000000..8a16a5b
--- a/dev/null
+++ b/frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js
@@ -0,0 +1,117 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
30
31var tests = {
32
33 //-------------------------------------------------------------------------
34
35 'simple_tests': function() {
36 vardeferredResult;
37
38 deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
39 deferredResult.addCallback(function() {
40 var proxy;
41
42 proxy = new Clipperz.PM.Proxy();
43 ok(proxy != null, "can create instances of the Proxy class");
44 is(proxy.shouldPayTolls(), false, "proxy is set to NOT pay tolls by default");
45 });
46
47 deferredResult.callback();
48
49 return deferredResult;
50 },
51
52 //-------------------------------------------------------------------------
53
54 'simpleTestsWithTolls_tests': function() {
55 vardeferredResult;
56
57 deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
58 deferredResult.addCallback(function() {
59 var proxy;
60
61 proxy = new Clipperz.PM.Proxy({shouldPayTolls:true});
62 is(proxy.shouldPayTolls(), true, "I can set Proxy to pays tolls");
63 });
64
65 deferredResult.callback();
66
67 return deferredResult;
68 },
69
70 //-------------------------------------------------------------------------
71 'syntaxFix': MochiKit.Base.noop
72};
73
74//#############################################################################
75
76runTests = function(aClassName) {
77 try {
78 var deferredTests;
79 var aTestName;
80
81 deferredTests = new Clipperz.Async.Deferred(aClassName + ".test", {trace:false});
82
83 aTestName = window.location.href.match(/#.*/);
84 if (aTestName && (aTestName != '#')) {
85 aTestName = aTestName[0].slice(1);
86 if (aTestName in tests) {
87 //Clipperz.log("single test execution, via fragment identifier", aTestName);
88 deferredTests.addCallback(tests[aTestName]);
89 deferredTests.addErrback(SimpleTest.ok, false, aTestName);
90 } else {
91 deferredTests.addBoth(is, aTestName, null, "Wrong test name selected to run");
92 }
93 } else {
94 for (aTestName in tests) {
95 deferredTests.addCallback(tests[aTestName]);
96 deferredTests.addErrback(SimpleTest.ok, false, aTestName);
97 }
98 deferredTests.addBoth(is, true, true, "FINISH: completed the full stack of tests");
99 }
100 deferredTests.addBoth(SimpleTest.finish);
101 deferredTests.callback();
102
103 SimpleTest.waitForExplicitFinish();
104 } catch (err) {
105 var s = "test suite failure!\n";
106 var o = {};
107 var k = null;
108 for (k in err) {
109 // ensure unique keys?!
110 if (!o[k]) {
111 s += k + ": " + err[k] + "\n";
112 o[k] = err[k];
113 }
114 }
115 ok ( false, s );
116 }
117}("Clipperz.PM.Proxy");