refactor(server): auth dtos (#4881)

* refactor: auth dtos

* chore: open api
This commit is contained in:
Jason Rasmussen
2023-11-09 10:14:15 -05:00
committed by GitHub
parent 5c602bf4d4
commit 5423f1c25b
38 changed files with 187 additions and 657 deletions

View File

@@ -1,5 +1,5 @@
import { AdminSignupResponseDto, AuthDeviceResponseDto, LoginCredentialDto, LoginResponseDto } from '@app/domain';
import { adminSignupStub, loginResponseStub, loginStub, signupResponseStub } from '@test';
import { AuthDeviceResponseDto, LoginCredentialDto, LoginResponseDto, UserResponseDto } from '@app/domain';
import { adminSignupStub, loginResponseStub, loginStub } from '@test';
import request from 'supertest';
export const authApi = {
@@ -7,9 +7,8 @@ export const authApi = {
const { status, body } = await request(server).post('/auth/admin-sign-up').send(adminSignupStub);
expect(status).toBe(201);
expect(body).toEqual(signupResponseStub);
return body as AdminSignupResponseDto;
return body as UserResponseDto;
},
adminLogin: async (server: any) => {
const { status, body } = await request(server).post('/auth/login').send(loginStub.admin);

View File

@@ -8,7 +8,6 @@ import {
errorStub,
loginResponseStub,
loginStub,
signupResponseStub,
uuidStub,
} from '@test/fixtures';
import { testApp } from '@test/test-utils';
@@ -19,6 +18,24 @@ const lastName = 'Admin';
const password = 'Password123';
const email = 'admin@immich.app';
const adminSignupResponse = {
id: expect.any(String),
firstName: 'Immich',
lastName: 'Admin',
email: 'admin@immich.app',
storageLabel: 'admin',
externalPath: null,
profileImagePath: '',
// why? lol
shouldChangePassword: true,
isAdmin: true,
createdAt: expect.any(String),
updatedAt: expect.any(String),
deletedAt: null,
oauthId: '',
memoriesEnabled: true,
};
describe(`${AuthController.name} (e2e)`, () => {
let server: any;
let accessToken: string;
@@ -84,7 +101,7 @@ describe(`${AuthController.name} (e2e)`, () => {
.post('/auth/admin-sign-up')
.send({ ...adminSignupStub, email: 'admin@local' });
expect(status).toEqual(201);
expect(body).toEqual({ ...signupResponseStub, email: 'admin@local' });
expect(body).toEqual({ ...adminSignupResponse, email: 'admin@local' });
});
it('should transform email to lower case', async () => {
@@ -92,7 +109,7 @@ describe(`${AuthController.name} (e2e)`, () => {
.post('/auth/admin-sign-up')
.send({ ...adminSignupStub, email: 'aDmIn@IMMICH.app' });
expect(status).toEqual(201);
expect(body).toEqual(signupResponseStub);
expect(body).toEqual(adminSignupResponse);
});
it('should not allow a second admin to sign up', async () => {

View File

@@ -12,14 +12,6 @@ export const userSignupStub = {
memoriesEnabled: true,
};
export const signupResponseStub = {
id: expect.any(String),
email: 'admin@immich.app',
firstName: 'Immich',
lastName: 'Admin',
createdAt: expect.any(String),
};
export const loginStub = {
admin: {
email: 'admin@immich.app',