]> git.ardis.lu - envpass/commitdiff
Add test for base64 padding
authorArdis Lu <ardisglu@gmail.com>
Sat, 5 Sep 2026 05:34:00 +0000 (22:34 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 5 Sep 2026 05:34:00 +0000 (22:34 -0700)
test/crypto.test.js

index 8479abd48ad7f5f546642d9ca8eb9439295047c0..a87b37f0c565b5d401a3ae09a2312614ecd7b70e 100644 (file)
@@ -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 }, () => {
This page took 0.035193 seconds and 4 git commands to generate.