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
+16
View File
@@ -36,6 +36,22 @@ test('Key generation', async () => {
expect(k2.publicKey.extractable).toBeTrue()
})
test("Encryption works with context", async () => {
const context = 'Super context !'
const box = await PrivateWrap.wrap(message, k1.publicKey, context)
expect(box).not.toBeNull()
const unboxed = await box!.unwrap(k1.privateKey, context)
expect(unboxed).not.toBeNull()
})
test("Encryption doesn't work with different context", async () => {
const context1 = 'Super context !'
const context2 = 'Awesome context !'
const box = await PrivateWrap.wrap(message, k1.publicKey, context1)
expect(box).not.toBeNull()
const unboxed = await box!.unwrap(k1.privateKey, context2)
expect(unboxed).toBeNull()
})
test('serialization', async () => {
const box = await PrivateWrap.wrap(message, k1.publicKey)
expect(box).not.toBeNull()