ServerInteraction.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. require('../common');
  3. describe('ServerInteraction', function () {
  4. describe('prepare', function () {
  5. afterEach(async function () {
  6. // pause to let async functions conclude
  7. await new Promise(resolve => setTimeout(resolve, 1900));
  8. });
  9. this.timeout(30000);
  10. it('can prepare an encrypted document', function () {
  11. jsc.assert(jsc.forall(
  12. 'string',
  13. 'string',
  14. 'string',
  15. async function (key, password, message) {
  16. // pause to let async functions conclude
  17. await new Promise(resolve => setTimeout(resolve, 300));
  18. let clean = jsdom();
  19. window.crypto = new WebCrypto();
  20. message = message.trim();
  21. $.PrivateBin.ServerInteraction.prepare();
  22. $.PrivateBin.ServerInteraction.setCryptParameters(password, key);
  23. $.PrivateBin.ServerInteraction.setUnencryptedData('adata', [
  24. // encryption parameters defined by CryptTool, format, discussion, burn after reading
  25. null, 'plaintext', 0, 0
  26. ]);
  27. $.PrivateBin.ServerInteraction.setUnencryptedData('meta', {'expire': '5min'});
  28. await $.PrivateBin.ServerInteraction.setCipherMessage({'paste': message});
  29. //console.log($.PrivateBin.ServerInteraction.getData());
  30. clean();
  31. // TODO currently not testing anything and just used to generate v2 pastes for starting development of server side v2 implementation
  32. return true;
  33. }
  34. ),
  35. {tests: 3});
  36. });
  37. });
  38. });