You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-09 23:17:29 +02:00
refactor(server): narrow auth types (#16066)
This commit is contained in:
66
server/test/fixtures/auth.stub.ts
vendored
66
server/test/fixtures/auth.stub.ts
vendored
@ -1,25 +1,30 @@
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { SessionEntity } from 'src/entities/session.entity';
|
||||
import { SharedLinkEntity } from 'src/entities/shared-link.entity';
|
||||
import { UserMetadataEntity } from 'src/entities/user-metadata.entity';
|
||||
import { UserEntity } from 'src/entities/user.entity';
|
||||
|
||||
const authUser = {
|
||||
admin: {
|
||||
id: 'admin_id',
|
||||
name: 'admin',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
quotaSizeInBytes: null,
|
||||
quotaUsageInBytes: 0,
|
||||
},
|
||||
user1: {
|
||||
id: 'user-id',
|
||||
name: 'User 1',
|
||||
email: 'immich@test.com',
|
||||
isAdmin: false,
|
||||
quotaSizeInBytes: null,
|
||||
quotaUsageInBytes: 0,
|
||||
},
|
||||
};
|
||||
|
||||
export const authStub = {
|
||||
admin: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
metadata: [] as UserMetadataEntity[],
|
||||
} as UserEntity,
|
||||
}),
|
||||
admin: Object.freeze<AuthDto>({ user: authUser.admin }),
|
||||
user1: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'user-id',
|
||||
email: 'immich@test.com',
|
||||
isAdmin: false,
|
||||
metadata: [] as UserMetadataEntity[],
|
||||
} as UserEntity,
|
||||
user: authUser.user1,
|
||||
session: {
|
||||
id: 'token-id',
|
||||
} as SessionEntity,
|
||||
@ -27,21 +32,18 @@ export const authStub = {
|
||||
user2: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'user-2',
|
||||
email: 'user2@immich.app',
|
||||
name: 'User 2',
|
||||
email: 'user2@immich.cloud',
|
||||
isAdmin: false,
|
||||
metadata: [] as UserMetadataEntity[],
|
||||
} as UserEntity,
|
||||
quotaSizeInBytes: null,
|
||||
quotaUsageInBytes: 0,
|
||||
},
|
||||
session: {
|
||||
id: 'token-id',
|
||||
} as SessionEntity,
|
||||
}),
|
||||
adminSharedLink: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
metadata: [] as UserMetadataEntity[],
|
||||
} as UserEntity,
|
||||
user: authUser.admin,
|
||||
sharedLink: {
|
||||
id: '123',
|
||||
showExif: true,
|
||||
@ -51,12 +53,7 @@ export const authStub = {
|
||||
} as SharedLinkEntity,
|
||||
}),
|
||||
adminSharedLinkNoExif: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
metadata: [] as UserMetadataEntity[],
|
||||
} as UserEntity,
|
||||
user: authUser.admin,
|
||||
sharedLink: {
|
||||
id: '123',
|
||||
showExif: false,
|
||||
@ -66,12 +63,7 @@ export const authStub = {
|
||||
} as SharedLinkEntity,
|
||||
}),
|
||||
passwordSharedLink: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
metadata: [] as UserMetadataEntity[],
|
||||
} as UserEntity,
|
||||
user: authUser.admin,
|
||||
sharedLink: {
|
||||
id: '123',
|
||||
allowUpload: false,
|
||||
|
Reference in New Issue
Block a user