32 lines
933 B
TypeScript
32 lines
933 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { assertProductionSecrets } from '../../src/config.js';
|
|
|
|
const good = {
|
|
accessSecret: 'a'.repeat(32),
|
|
refreshSecret: 'b'.repeat(32),
|
|
};
|
|
|
|
describe('assertProductionSecrets', () => {
|
|
it('akceptuje kompletne, niestandardowe sekrety', () => {
|
|
expect(() => assertProductionSecrets(good)).not.toThrow();
|
|
});
|
|
|
|
it('rzuca dla deweloperskiego sekretu access', () => {
|
|
expect(() =>
|
|
assertProductionSecrets({ ...good, accessSecret: 'dev-access-secret' }),
|
|
).toThrow(/JWT_ACCESS_SECRET/);
|
|
});
|
|
|
|
it('rzuca dla pustego sekretu refresh', () => {
|
|
expect(() => assertProductionSecrets({ ...good, refreshSecret: '' })).toThrow(
|
|
/JWT_REFRESH_SECRET/,
|
|
);
|
|
});
|
|
|
|
it('rzuca gdy access i refresh są identyczne', () => {
|
|
expect(() =>
|
|
assertProductionSecrets({ ...good, refreshSecret: good.accessSecret }),
|
|
).toThrow(/must differ/);
|
|
});
|
|
});
|