From: Ardis Lu Date: Sat, 5 Sep 2026 05:34:00 +0000 (-0700) Subject: Add test for base64 padding X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=8a2abcfeea4bf2b8e52a27493e6c275711254ada;p=envpass Add test for base64 padding --- diff --git a/test/crypto.test.js b/test/crypto.test.js index 8479abd..a87b37f 100644 --- a/test/crypto.test.js +++ b/test/crypto.test.js @@ -1,5 +1,5 @@ import { suite, test } from 'node:test'; -import { deepStrictEqual, rejects } from 'node:assert/strict'; +import { deepStrictEqual, notDeepStrictEqual, rejects } from 'node:assert/strict'; import { encryptRaw, decryptRaw } from '#src/crypto.js'; @@ -27,6 +27,12 @@ suite('encryptRaw', { concurrency: true }, () => { // @ts-expect-error await rejects(encryptRaw({ version, prf, value: {} }), { name: 'TypeError', message: 'Value "{}" is not a string.' }); }); + test('output value does not have base64 padding', { concurrency: true }, async () => { + for (const value of ['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa']) { + const output = await encryptRaw({ version, prf, value }); + notDeepStrictEqual(output.at(-1), '='); + } + }); }); suite('decryptRaw', { concurrency: true }, () => {