mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
874d8459ce
* refactor: remove unused API definition routes * feat: embed proxy endpoints * feat: check token metadata for alias if none is found * fix: rename param * feat: add test for retrieving token by alias * fix: update schema * fix: refactor to alias * fix: refactor to null * fix: update snapshot * fix: update openapi snapshot * fix: add check to getUserForToken * refactor: add more token alias tests * refactor: use timingSafeEqual for token comparisons Co-authored-by: olav <mail@olav.io>
30 lines
789 B
TypeScript
30 lines
789 B
TypeScript
import { ApiTokenType } from '../../types/models/api-token';
|
|
import { validateSchema } from '../validate';
|
|
import { ApiTokenSchema } from './api-token-schema';
|
|
|
|
const defaultData: ApiTokenSchema = {
|
|
secret: '',
|
|
username: '',
|
|
type: ApiTokenType.CLIENT,
|
|
environment: '',
|
|
projects: [],
|
|
expiresAt: '2022-01-01T00:00:00.000Z',
|
|
createdAt: '2022-01-01T00:00:00.000Z',
|
|
seenAt: '2022-01-01T00:00:00.000Z',
|
|
project: '',
|
|
};
|
|
|
|
test('apiTokenSchema', () => {
|
|
const data: ApiTokenSchema = { ...defaultData };
|
|
|
|
expect(
|
|
validateSchema('#/components/schemas/apiTokenSchema', data),
|
|
).toBeUndefined();
|
|
});
|
|
|
|
test('apiTokenSchema empty', () => {
|
|
expect(
|
|
validateSchema('#/components/schemas/apiTokenSchema', {}),
|
|
).toMatchSnapshot();
|
|
});
|