Test contexts

This commit is contained in:
2024-09-14 14:24:53 +02:00
parent 76cf4632e4
commit f2f39fd318
5 changed files with 80 additions and 1 deletions
+15
View File
@@ -23,6 +23,21 @@ test("Different key can't decrypt", async () => {
const unboxed = await box!.decrypt(k2)
expect(unboxed).toBeNull()
})
test("Encryption works with context", async () => {
const c1 = 'context1'
const box = await PwdBox.encrypt(message, k1, c1)
expect(box).not.toBeNull()
const unboxed = await box!.decrypt(k1, c1)
expect(unboxed).not.toBeNull()
})
test("Encryption doesn't work with different context", async () => {
const c1 = 'context1'
const c2 = 'context2'
const box = await PwdBox.encrypt(message, k1, c1)
expect(box).not.toBeNull()
const unboxed = await box!.decrypt(k1, c2)
expect(unboxed).toBeNull()
})
test('serialization', async () => {
const box = await PwdBox.encrypt(message, k1)