feat: migration api keys to use kysely ()

This commit is contained in:
Jason Rasmussen 2025-01-10 14:02:12 -05:00 committed by GitHub
parent 3030e74fc3
commit 930f979960
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 151 additions and 107 deletions
server/src/services

View file

@ -405,7 +405,7 @@ describe('AuthService', () => {
describe('validate - api key', () => {
it('should throw an error if no api key is found', async () => {
keyMock.getKey.mockResolvedValue(null);
keyMock.getKey.mockResolvedValue(void 0);
await expect(
sut.authenticate({
headers: { 'x-api-key': 'auth_token' },
@ -417,7 +417,7 @@ describe('AuthService', () => {
});
it('should throw an error if api key has insufficient permissions', async () => {
keyMock.getKey.mockResolvedValue({ ...keyStub.admin, permissions: [] });
keyMock.getKey.mockResolvedValue(keyStub.authKey);
await expect(
sut.authenticate({
headers: { 'x-api-key': 'auth_token' },
@ -428,14 +428,14 @@ describe('AuthService', () => {
});
it('should return an auth dto', async () => {
keyMock.getKey.mockResolvedValue(keyStub.admin);
keyMock.getKey.mockResolvedValue(keyStub.authKey);
await expect(
sut.authenticate({
headers: { 'x-api-key': 'auth_token' },
queryParams: {},
metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' },
}),
).resolves.toEqual({ user: userStub.admin, apiKey: keyStub.admin });
).resolves.toEqual({ user: userStub.admin, apiKey: keyStub.authKey });
expect(keyMock.getKey).toHaveBeenCalledWith('auth_token (hashed)');
});
});