2013-12-16 19:00:21 +01:00
|
|
|
(function (root, factory) {
|
|
|
|
define([
|
|
|
|
"mock",
|
|
|
|
"utils"
|
|
|
|
], function (mock, utils) {
|
|
|
|
return factory(mock, utils);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} (this, function (mock, utils) {
|
2014-02-12 06:12:00 +01:00
|
|
|
return describe("The OTR module", $.proxy(function(mock, utils) {
|
2013-12-18 15:30:19 +01:00
|
|
|
|
2014-02-12 01:02:45 +01:00
|
|
|
beforeEach($.proxy(function () {
|
|
|
|
window.localStorage.clear();
|
|
|
|
window.sessionStorage.clear();
|
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("can store a session passphrase in session storage", $.proxy(function () {
|
|
|
|
var pp;
|
|
|
|
// With no prebind, the user's XMPP password is used and nothing is
|
|
|
|
// stored in session storage.
|
|
|
|
this.prebind = false;
|
|
|
|
this.connection.pass = 's3cr3t!';
|
2014-02-12 06:12:00 +01:00
|
|
|
expect(this.otr.getSessionPassphrase()).toBe(this.connection.pass);
|
2014-04-18 17:42:11 +02:00
|
|
|
expect(window.sessionStorage.length).toBe(0);
|
|
|
|
expect(window.localStorage.length).toBe(0);
|
2014-02-12 01:02:45 +01:00
|
|
|
|
|
|
|
// With prebind, a random passphrase is generated and stored in
|
|
|
|
// session storage.
|
|
|
|
this.prebind = true;
|
2014-02-12 06:12:00 +01:00
|
|
|
pp = this.otr.getSessionPassphrase();
|
2014-02-12 01:02:45 +01:00
|
|
|
expect(pp).not.toBe(this.connection.pass);
|
|
|
|
expect(window.sessionStorage.length).toBe(1);
|
2014-04-18 17:42:11 +02:00
|
|
|
expect(window.localStorage.length).toBe(0);
|
2014-02-12 01:02:45 +01:00
|
|
|
expect(pp).toBe(window.sessionStorage[hex_sha1(converse.connection.jid)]);
|
|
|
|
|
|
|
|
// Clean up
|
|
|
|
this.prebind = false;
|
|
|
|
}, converse));
|
2013-12-16 19:00:21 +01:00
|
|
|
}, converse, mock, utils));
|
|
|
|
}));
|