Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/KeePassExportProcessor.test.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/tests/tests/Clipperz/KeePassExportProcessor.test.js | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/KeePassExportProcessor.test.js b/frontend/gamma/tests/tests/Clipperz/KeePassExportProcessor.test.js new file mode 100644 index 0000000..0ce4c91 --- a/dev/null +++ b/frontend/gamma/tests/tests/Clipperz/KeePassExportProcessor.test.js | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | |||
29 | var tests = { | ||
30 | |||
31 | //------------------------------------------------------------------------- | ||
32 | |||
33 | 'test1_test': function (someTestArgs) { | ||
34 | var deferredResult; | ||
35 | varkeePassProcessor; | ||
36 | |||
37 | keePassProcessor = new Clipperz.KeePassExportProcessor(); | ||
38 | |||
39 | deferredResult = new Clipperz.Async.Deferred("test1_test", someTestArgs); | ||
40 | deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\n" }); | ||
41 | deferredResult.addMethod(keePassProcessor, 'deferredParse'); | ||
42 | deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\"}]", "first test"); }); | ||
43 | deferredResult.addErrback(function(anError) { is("ERROR", anError) }); | ||
44 | |||
45 | deferredResult.callback(); | ||
46 | |||
47 | return deferredResult; | ||
48 | }, | ||
49 | |||
50 | 'test2_test': function (someTestArgs) { | ||
51 | var deferredResult; | ||
52 | varkeePassProcessor; | ||
53 | |||
54 | keePassProcessor = new Clipperz.KeePassExportProcessor(); | ||
55 | |||
56 | deferredResult = new Clipperz.Async.Deferred("test2_test", someTestArgs); | ||
57 | deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" }); | ||
58 | deferredResult.addMethod(keePassProcessor, 'deferredParse'); | ||
59 | deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "second test"); }); | ||
60 | deferredResult.addErrback(function(anError) { is("ERROR", anError) }); | ||
61 | |||
62 | deferredResult.callback(); | ||
63 | |||
64 | return deferredResult; | ||
65 | }, | ||
66 | |||
67 | 'test3_test': function (someTestArgs) { | ||
68 | var deferredResult; | ||
69 | varkeePassProcessor; | ||
70 | |||
71 | keePassProcessor = new Clipperz.KeePassExportProcessor(); | ||
72 | |||
73 | deferredResult = new Clipperz.Async.Deferred("test3_test", someTestArgs); | ||
74 | deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\nwith some notes stored\non multiple lines\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" }); | ||
75 | deferredResult.addMethod(keePassProcessor, 'deferredParse'); | ||
76 | deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\\nwith some notes stored\\non multiple lines\\n\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "third test"); }); | ||
77 | deferredResult.addErrback(function(anError) { is("ERROR", anError) }); | ||
78 | |||
79 | deferredResult.callback(); | ||
80 | |||
81 | return deferredResult; | ||
82 | }, | ||
83 | |||
84 | //------------------------------------------------------------------------- | ||
85 | |||
86 | 'Barb_Newman_test': function (someTestArgs) { | ||
87 | var deferredResult; | ||
88 | varkeePassProcessor; | ||
89 | |||
90 | keePassProcessor = new Clipperz.KeePassExportProcessor(); | ||
91 | |||
92 | deferredResult = new Clipperz.Async.Deferred("Barb_Newman_test", someTestArgs); | ||
93 | // deferredResult.addCallback(function () { return testData['Barb_Newman_data']; }); | ||
94 | deferredResult.addMethod(keePassProcessor, 'deferredParse'); | ||
95 | deferredResult.addBoth(function(aResult) { | ||
96 | SimpleTest.is(aResult.length, 121, "Barb's data contains 121 records"); | ||
97 | return aResult; | ||
98 | }); | ||
99 | deferredResult.addBoth(function(aResult) { | ||
100 | SimpleTest.is(MochiKit.Base.serializeJSON(aResult[0]), "{\"Title\":\"Domain Administration Account\", \"Group\":\"Windows\", \"User Name\":\"_ABC\", \"URL\":\"\", \"Password\":\"123456\", \"Notes\":\"\"}", "Barb's first record data matches"); | ||
101 | return aResult; | ||
102 | }); | ||
103 | // deferredResult.callback(); | ||
104 | deferredResult.callback(testData['Barb_Newman_data']); | ||
105 | |||
106 | return deferredResult; | ||
107 | }, | ||
108 | |||
109 | //------------------------------------------------------------------------- | ||
110 | /* | ||
111 | 'Jordan_Curzon_test': function (someTestArgs) { | ||
112 | var deferredResult; | ||
113 | varkeePassProcessor; | ||
114 | |||
115 | keePassProcessor = new Clipperz.KeePassExportProcessor(); | ||
116 | |||
117 | deferredResult = new Clipperz.Async.Deferred("Jordan_Curzon_test", someTestArgs); | ||
118 | deferredResult.addCallback(function () { return testData['Jordan_Curzon_data']; }); | ||
119 | deferredResult.addMethod(keePassProcessor, 'deferredParse'); | ||
120 | deferredResult.addBoth(function(aResult) { | ||
121 | SimpleTest.is(aResult.length, 2, "Jordarn's data contains 2 records"); | ||
122 | return aResult; | ||
123 | }); | ||
124 | deferredResult.addBoth(function(aResult) { | ||
125 | SimpleTest.is(MochiKit.Base.serializeJSON(aResult[0]), "{\"Title\":\"Allstate\", \"Username\":\"jones\", \"Url\":\"allstate.com\", \"Password\":\"bobfred\", \"Comment\":\"\"}", "Barb's first record data matches"); | ||
126 | return aResult; | ||
127 | }); | ||
128 | deferredResult.callback(); | ||
129 | |||
130 | return deferredResult; | ||
131 | }, | ||
132 | */ | ||
133 | //------------------------------------------------------------------------- | ||
134 | 'syntaxFix': MochiKit.Base.noop | ||
135 | }; | ||
136 | |||
137 | |||
138 | |||
139 | //############################################################################# | ||
140 | |||
141 | SimpleTest.runDeferredTests("Clipperz.KeyPassExportProcessor", tests, {trace:false}); | ||