Test contexts
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user