otr.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function (root, factory) {
  2. define([
  3. "mock",
  4. "utils"
  5. ], function (mock, utils) {
  6. return factory(mock, utils);
  7. }
  8. );
  9. } (this, function (mock, utils) {
  10. return describe("The OTR module", $.proxy(function(mock, utils) {
  11. beforeEach($.proxy(function () {
  12. window.localStorage.clear();
  13. window.sessionStorage.clear();
  14. }, converse));
  15. it("can store a session passphrase in session storage", $.proxy(function () {
  16. var pp;
  17. // With no prebind, the user's XMPP password is used and nothing is
  18. // stored in session storage.
  19. this.prebind = false;
  20. this.connection.pass = 's3cr3t!';
  21. expect(this.otr.getSessionPassphrase()).toBe(this.connection.pass);
  22. expect(window.sessionStorage.length).toBe(0);
  23. expect(window.localStorage.length).toBe(0);
  24. // With prebind, a random passphrase is generated and stored in
  25. // session storage.
  26. this.prebind = true;
  27. pp = this.otr.getSessionPassphrase();
  28. expect(pp).not.toBe(this.connection.pass);
  29. expect(window.sessionStorage.length).toBe(1);
  30. expect(window.localStorage.length).toBe(0);
  31. expect(pp).toBe(window.sessionStorage[b64_sha1(converse.connection.jid)]);
  32. // Clean up
  33. this.prebind = false;
  34. }, converse));
  35. }, converse, mock, utils));
  36. }));