Files
mtusi2026lab2/student-tests/credentials.test.mjs
T

10 lines
516 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {basic} from '../dist/basic.js';
test('Basic preserves UTF-8 and colons in the password',()=>{
assert.deepEqual(basic('Basic '+Buffer.from('alice:пароль:extra').toString('base64')),['alice','пароль:extra']);
});
test('malformed Basic and invalid UTF-8 fail before the KDF',()=>{
for(const h of [undefined,'Bearer abc','Basic YQ==','Basic YQA=','Basic ////','Basic Zg'])assert.throws(()=>basic(h),e=>e.statusCode===401);
});