Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
17
frontend/tests/apiKey.test.ts
Normal file
17
frontend/tests/apiKey.test.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { describe, expect, test } from 'vitest';
|
||||
import { generateSecureApiKey } from '../src/utils/apiKey';
|
||||
|
||||
describe('API key generation', () => {
|
||||
test('generates a 51-character key with the expected prefix and charset', () => {
|
||||
const apiKey = generateSecureApiKey();
|
||||
|
||||
expect(apiKey).toHaveLength(51);
|
||||
expect(apiKey).toMatch(/^sk-[A-Za-z0-9]{48}$/);
|
||||
});
|
||||
|
||||
test('generates distinct keys', () => {
|
||||
const apiKeys = Array.from({ length: 100 }, () => generateSecureApiKey());
|
||||
|
||||
expect(new Set(apiKeys).size).toBe(apiKeys.length);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue