Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Alice can share with Bob who has a revoked device', async () => {
const aliceIdentity = await args.appHelper.generateIdentity();
const aliceLaptop = args.makeTanker();
await aliceLaptop.start(aliceIdentity);
await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });
await bobLaptop.revokeDevice(bobPhone.deviceId);
const message = 'I love you';
const encrypted = await aliceLaptop.encrypt(message, { shareWithUsers: [bobPublicIdentity] });
const clear = await bobLaptop.decrypt(encrypted);
expect(clear).to.eq(message);
await expect(bobPhone.decrypt(encrypted)).to.be.rejectedWith(errors.DeviceRevoked);
await aliceLaptop.stop();
});
});
it('fires a revoked event on the revoked device only', async () => {
bobLaptop.on('deviceRevoked', () => {
expect(false).to.be.true;
});
await bobLaptop.revokeDevice(bobPhone.deviceId);
let eventCalled = false;
bobPhone.on('deviceRevoked', () => {
eventCalled = true;
});
await expect(bobPhone.encrypt('message')).to.be.rejectedWith(errors.DeviceRevoked);
await expect(eventCalled).to.be.true;
});