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
+17
View File
@@ -24,6 +24,23 @@ test("Different key can't decrypt", async () => {
expect(unboxed).toBeNull()
})
test('Encryption works with context', async () => {
const context = 'awesome context !'
const box = await PwdWrap.wrap(message, k1, context)
expect(box).not.toBeNull()
const unboxed = await box!.unwrap(k1, context)
expect(unboxed).toEqual(message)
})
test("Encryption doesn't work with different context", async () => {
const c1 = 'super context !'
const c2 = 'awesome context !'
const box = await PwdWrap.wrap(message, k1, c1)
expect(box).not.toBeNull()
const unboxed = await box!.unwrap(k1,c2)
expect(unboxed).toBeNull()
expect(unboxed).not.toEqual(message)
})
test('serialization', async () => {
const box = await PwdWrap.wrap(message, k1)
expect(box).not.toBeNull()