mirror of
https://github.com/immich-app/immich.git
synced 2025-12-28 01:11:47 +03:00
refactor(server): auth dtos (#4881)
* refactor: auth dtos * chore: open api
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
8
server/test/fixtures/auth.stub.ts
vendored
8
server/test/fixtures/auth.stub.ts
vendored
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user