keychain-tests.js 853 B

12345678910111213141516171819202122232425262728
  1. import assert from 'assert';
  2. import Keychain from '../../../app/keychain';
  3. describe('Keychain', function() {
  4. describe('setPassword', function() {
  5. it('changes the authKey', async function() {
  6. const k = new Keychain();
  7. const original = await k.authKeyB64();
  8. k.setPassword('foo', 'some://url');
  9. const pwd = await k.authKeyB64();
  10. assert.notEqual(pwd, original);
  11. });
  12. });
  13. describe('encrypt / decrypt metadata', function() {
  14. it('can decrypt metadata it encrypts', async function() {
  15. const k = new Keychain();
  16. const meta = {
  17. name: 'foo',
  18. type: 'bar/baz'
  19. };
  20. const ciphertext = await k.encryptMetadata(meta);
  21. const result = await k.decryptMetadata(ciphertext);
  22. assert.equal(result.name, meta.name);
  23. assert.equal(result.type, meta.type);
  24. });
  25. });
  26. });