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