2015-10-25 18:49:35 +01:00
|
|
|
/*global converse */
|
2013-12-16 19:00:21 +01:00
|
|
|
(function (root, factory) {
|
|
|
|
define([
|
2014-10-15 19:16:02 +02:00
|
|
|
"jquery",
|
2013-12-16 19:00:21 +01:00
|
|
|
"mock",
|
2014-08-08 22:06:01 +02:00
|
|
|
"test_utils"
|
2014-10-15 19:16:02 +02:00
|
|
|
], function ($, mock, test_utils) {
|
|
|
|
return factory($, mock, test_utils);
|
2013-12-16 19:00:21 +01:00
|
|
|
}
|
|
|
|
);
|
2014-10-15 19:16:02 +02:00
|
|
|
} (this, function ($, mock, test_utils) {
|
2015-02-01 16:15:34 +01:00
|
|
|
var b64_sha1 = converse_api.env.b64_sha1;
|
|
|
|
|
2016-04-13 17:11:04 +02:00
|
|
|
return describe("The OTR module", function() {
|
2013-12-18 15:30:19 +01:00
|
|
|
|
2016-04-13 17:11:04 +02:00
|
|
|
it("can store a session passphrase in session storage", function () {
|
2014-02-12 01:02:45 +01:00
|
|
|
// With no prebind, the user's XMPP password is used and nothing is
|
|
|
|
// stored in session storage.
|
2016-04-13 17:11:04 +02:00
|
|
|
var auth = converse.authentication;
|
|
|
|
var pass = converse.connection.pass;
|
|
|
|
converse.authentication = "manual";
|
|
|
|
converse.connection.pass = 's3cr3t!';
|
|
|
|
expect(converse.otr.getSessionPassphrase()).toBe(converse.connection.pass);
|
2014-02-12 01:02:45 +01:00
|
|
|
|
|
|
|
// With prebind, a random passphrase is generated and stored in
|
|
|
|
// session storage.
|
2016-04-13 17:11:04 +02:00
|
|
|
converse.authentication = "prebind";
|
|
|
|
var pp = converse.otr.getSessionPassphrase();
|
|
|
|
expect(pp).not.toBe(converse.connection.pass);
|
2014-04-19 05:12:24 +02:00
|
|
|
expect(pp).toBe(window.sessionStorage[b64_sha1(converse.connection.jid)]);
|
2014-02-12 01:02:45 +01:00
|
|
|
|
|
|
|
// Clean up
|
2016-04-13 17:11:04 +02:00
|
|
|
converse.authentication = auth;
|
|
|
|
converse.connection.pass = pass;
|
|
|
|
});
|
|
|
|
});
|
2013-12-16 19:00:21 +01:00
|
|
|
}));
|