import { describe, it } from 'bun:test'; import { expect } from 'chai'; import { CookiesSecurityCheck } from './cookies-security-check'; function codes(keys?: unknown[]): string[] { return Object.assign(new CookiesSecurityCheck(), { keys }).check().map(warning => warning.code); } describe('CookiesSecurityCheck', () => { it('warns about missing, default and short keys', () => { expect(codes(undefined)).to.deep.equal(['CELL_SECURITY_COOKIE_KEYS_MISSING']); expect(codes([])).to.deep.equal(['CELL_SECURITY_COOKIE_KEYS_MISSING']); expect(codes(['abcdef'])).to.deep.equal(['CELL_SECURITY_DEFAULT_COOKIE_KEYS']); expect(codes(['a-new-random-key-of-32-chars-xyz', 'abcdef'])).to.deep.equal(['CELL_SECURITY_DEFAULT_COOKIE_KEYS']); expect(codes(['short'])).to.deep.equal(['CELL_SECURITY_WEAK_COOKIE_KEYS']); }); it('accepts long random keys', () => { expect(codes(['q8Yx0lJr6S1v4m3Wz7Nc2Bp9Kd5Hf0Ta'])).to.deep.equal([]); }); });