refactor(server): auth dto (#5593)
* refactor: AuthUserDto => AuthDto * refactor: reorganize auth-dto * refactor: AuthUser() => Auth()
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ export const activityStub = {
|
||||
id: 'activity-1',
|
||||
comment: 'comment',
|
||||
isLiked: false,
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
assetId: assetStub.image.id,
|
||||
asset: assetStub.image,
|
||||
@@ -22,7 +22,7 @@ export const activityStub = {
|
||||
id: 'activity-2',
|
||||
comment: null,
|
||||
isLiked: true,
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
assetId: assetStub.image.id,
|
||||
asset: assetStub.image,
|
||||
|
||||
Vendored
+10
-10
@@ -8,7 +8,7 @@ export const albumStub = {
|
||||
id: 'album-1',
|
||||
albumName: 'Empty album',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
albumThumbnailAsset: null,
|
||||
@@ -24,7 +24,7 @@ export const albumStub = {
|
||||
id: 'album-2',
|
||||
albumName: 'Empty album shared with user',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
albumThumbnailAsset: null,
|
||||
@@ -40,7 +40,7 @@ export const albumStub = {
|
||||
id: 'album-3',
|
||||
albumName: 'Empty album shared with users',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
albumThumbnailAsset: null,
|
||||
@@ -56,7 +56,7 @@ export const albumStub = {
|
||||
id: 'album-3',
|
||||
albumName: 'Empty album shared with admin',
|
||||
description: '',
|
||||
ownerId: authStub.user1.id,
|
||||
ownerId: authStub.user1.user.id,
|
||||
owner: userStub.user1,
|
||||
assets: [],
|
||||
albumThumbnailAsset: null,
|
||||
@@ -72,7 +72,7 @@ export const albumStub = {
|
||||
id: 'album-4',
|
||||
albumName: 'Album with one asset',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image],
|
||||
albumThumbnailAsset: null,
|
||||
@@ -88,7 +88,7 @@ export const albumStub = {
|
||||
id: 'album-4a',
|
||||
albumName: 'Album with two assets',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image, assetStub.withLocation],
|
||||
albumThumbnailAsset: assetStub.image,
|
||||
@@ -104,7 +104,7 @@ export const albumStub = {
|
||||
id: 'album-5',
|
||||
albumName: 'Empty album with invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
albumThumbnailAsset: assetStub.image,
|
||||
@@ -120,7 +120,7 @@ export const albumStub = {
|
||||
id: 'album-5',
|
||||
albumName: 'Empty album with invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [],
|
||||
albumThumbnailAsset: null,
|
||||
@@ -136,7 +136,7 @@ export const albumStub = {
|
||||
id: 'album-6',
|
||||
albumName: 'Album with one asset and invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image],
|
||||
albumThumbnailAsset: assetStub.livePhotoMotionAsset,
|
||||
@@ -152,7 +152,7 @@ export const albumStub = {
|
||||
id: 'album-6',
|
||||
albumName: 'Album with one asset and invalid thumbnail',
|
||||
description: '',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
assets: [assetStub.image],
|
||||
albumThumbnailAsset: assetStub.image,
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ export const keyStub = {
|
||||
id: 'my-random-guid',
|
||||
name: 'My Key',
|
||||
key: 'my-api-key (hashed)',
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
} as APIKeyEntity),
|
||||
};
|
||||
|
||||
Vendored
+2
-2
@@ -403,7 +403,7 @@ export const assetStub = {
|
||||
livePhotoMotionAsset: Object.freeze({
|
||||
id: 'live-photo-motion-asset',
|
||||
originalPath: fileStub.livePhotoMotion.originalPath,
|
||||
ownerId: authStub.user1.id,
|
||||
ownerId: authStub.user1.user.id,
|
||||
type: AssetType.VIDEO,
|
||||
isVisible: false,
|
||||
fileModifiedAt: new Date('2022-06-19T23:41:36.910Z'),
|
||||
@@ -418,7 +418,7 @@ export const assetStub = {
|
||||
livePhotoStillAsset: Object.freeze({
|
||||
id: 'live-photo-still-asset',
|
||||
originalPath: fileStub.livePhotoStill.originalPath,
|
||||
ownerId: authStub.user1.id,
|
||||
ownerId: authStub.user1.user.id,
|
||||
type: AssetType.IMAGE,
|
||||
livePhotoVideoId: 'live-photo-motion-asset',
|
||||
isVisible: true,
|
||||
|
||||
Vendored
+3
-3
@@ -7,7 +7,7 @@ export const auditStub = {
|
||||
entityId: 'asset-created',
|
||||
action: DatabaseAction.CREATE,
|
||||
entityType: EntityType.ASSET,
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
createdAt: new Date(),
|
||||
}),
|
||||
update: Object.freeze<AuditEntity>({
|
||||
@@ -15,7 +15,7 @@ export const auditStub = {
|
||||
entityId: 'asset-updated',
|
||||
action: DatabaseAction.UPDATE,
|
||||
entityType: EntityType.ASSET,
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
createdAt: new Date(),
|
||||
}),
|
||||
delete: Object.freeze<AuditEntity>({
|
||||
@@ -23,7 +23,7 @@ export const auditStub = {
|
||||
entityId: 'asset-deleted',
|
||||
action: DatabaseAction.DELETE,
|
||||
entityType: EntityType.ASSET,
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
createdAt: new Date(),
|
||||
}),
|
||||
};
|
||||
|
||||
Vendored
+74
-66
@@ -1,4 +1,5 @@
|
||||
import { AuthUserDto } from '@app/domain';
|
||||
import { AuthDto } from '@app/domain';
|
||||
import { SharedLinkEntity, UserEntity, UserTokenEntity } from '../../src/infra/entities';
|
||||
|
||||
export const adminSignupStub = {
|
||||
name: 'Immich Admin',
|
||||
@@ -24,77 +25,84 @@ export const changePasswordStub = {
|
||||
};
|
||||
|
||||
export const authStub = {
|
||||
admin: Object.freeze<AuthUserDto>({
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
isPublicUser: false,
|
||||
isAllowUpload: true,
|
||||
externalPath: null,
|
||||
admin: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
} as UserEntity,
|
||||
}),
|
||||
user1: Object.freeze<AuthUserDto>({
|
||||
id: 'user-id',
|
||||
email: 'immich@test.com',
|
||||
isAdmin: false,
|
||||
isPublicUser: false,
|
||||
isAllowUpload: true,
|
||||
isAllowDownload: true,
|
||||
isShowMetadata: true,
|
||||
accessTokenId: 'token-id',
|
||||
externalPath: null,
|
||||
user1: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'user-id',
|
||||
email: 'immich@test.com',
|
||||
isAdmin: false,
|
||||
} as UserEntity,
|
||||
userToken: {
|
||||
id: 'token-id',
|
||||
} as UserTokenEntity,
|
||||
}),
|
||||
user2: Object.freeze<AuthUserDto>({
|
||||
id: 'user-2',
|
||||
email: 'user2@immich.app',
|
||||
isAdmin: false,
|
||||
isPublicUser: false,
|
||||
isAllowUpload: true,
|
||||
isAllowDownload: true,
|
||||
isShowMetadata: true,
|
||||
accessTokenId: 'token-id',
|
||||
externalPath: null,
|
||||
user2: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'user-2',
|
||||
email: 'user2@immich.app',
|
||||
isAdmin: false,
|
||||
} as UserEntity,
|
||||
userToken: {
|
||||
id: 'token-id',
|
||||
} as UserTokenEntity,
|
||||
}),
|
||||
external1: Object.freeze<AuthUserDto>({
|
||||
id: 'user-id',
|
||||
email: 'immich@test.com',
|
||||
isAdmin: false,
|
||||
isPublicUser: false,
|
||||
isAllowUpload: true,
|
||||
isAllowDownload: true,
|
||||
isShowMetadata: true,
|
||||
accessTokenId: 'token-id',
|
||||
externalPath: '/data/user1',
|
||||
external1: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'user-id',
|
||||
email: 'immich@test.com',
|
||||
isAdmin: false,
|
||||
externalPath: '/data/user1',
|
||||
} as UserEntity,
|
||||
userToken: {
|
||||
id: 'token-id',
|
||||
} as UserTokenEntity,
|
||||
}),
|
||||
adminSharedLink: Object.freeze<AuthUserDto>({
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
isAllowUpload: true,
|
||||
isAllowDownload: true,
|
||||
isPublicUser: true,
|
||||
isShowMetadata: true,
|
||||
sharedLinkId: '123',
|
||||
adminSharedLink: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
} as UserEntity,
|
||||
sharedLink: {
|
||||
id: '123',
|
||||
showExif: true,
|
||||
allowDownload: true,
|
||||
allowUpload: true,
|
||||
key: Buffer.from('shared-link-key'),
|
||||
} as SharedLinkEntity,
|
||||
}),
|
||||
adminSharedLinkNoExif: Object.freeze<AuthUserDto>({
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
isAllowUpload: true,
|
||||
isAllowDownload: true,
|
||||
isPublicUser: true,
|
||||
isShowMetadata: false,
|
||||
sharedLinkId: '123',
|
||||
adminSharedLinkNoExif: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
} as UserEntity,
|
||||
sharedLink: {
|
||||
id: '123',
|
||||
showExif: false,
|
||||
allowDownload: true,
|
||||
allowUpload: true,
|
||||
key: Buffer.from('shared-link-key'),
|
||||
} as SharedLinkEntity,
|
||||
}),
|
||||
readonlySharedLink: Object.freeze<AuthUserDto>({
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
isAllowUpload: false,
|
||||
isAllowDownload: false,
|
||||
isPublicUser: true,
|
||||
isShowMetadata: true,
|
||||
sharedLinkId: '123',
|
||||
accessTokenId: 'token-id',
|
||||
readonlySharedLink: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'admin_id',
|
||||
email: 'admin@test.com',
|
||||
isAdmin: true,
|
||||
} as UserEntity,
|
||||
sharedLink: {
|
||||
id: '123',
|
||||
allowUpload: false,
|
||||
allowDownload: false,
|
||||
showExif: true,
|
||||
} as SharedLinkEntity,
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
+6
-6
@@ -106,7 +106,7 @@ const albumResponse: AlbumResponseDto = {
|
||||
export const sharedLinkStub = {
|
||||
individual: Object.freeze({
|
||||
id: '123',
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
key: sharedLinkBytes,
|
||||
type: SharedLinkType.INDIVIDUAL,
|
||||
@@ -121,7 +121,7 @@ export const sharedLinkStub = {
|
||||
} as SharedLinkEntity),
|
||||
valid: Object.freeze({
|
||||
id: '123',
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
key: sharedLinkBytes,
|
||||
type: SharedLinkType.ALBUM,
|
||||
@@ -138,7 +138,7 @@ export const sharedLinkStub = {
|
||||
} as SharedLinkEntity),
|
||||
expired: Object.freeze({
|
||||
id: '123',
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
key: sharedLinkBytes,
|
||||
type: SharedLinkType.ALBUM,
|
||||
@@ -154,7 +154,7 @@ export const sharedLinkStub = {
|
||||
} as SharedLinkEntity),
|
||||
readonlyNoExif: Object.freeze<SharedLinkEntity>({
|
||||
id: '123',
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
key: sharedLinkBytes,
|
||||
type: SharedLinkType.ALBUM,
|
||||
@@ -169,7 +169,7 @@ export const sharedLinkStub = {
|
||||
albumId: 'album-123',
|
||||
album: {
|
||||
id: 'album-123',
|
||||
ownerId: authStub.admin.id,
|
||||
ownerId: authStub.admin.user.id,
|
||||
owner: userStub.admin,
|
||||
albumName: 'Test Album',
|
||||
description: '',
|
||||
@@ -260,7 +260,7 @@ export const sharedLinkStub = {
|
||||
}),
|
||||
passwordRequired: Object.freeze<SharedLinkEntity>({
|
||||
id: '123',
|
||||
userId: authStub.admin.id,
|
||||
userId: authStub.admin.user.id,
|
||||
user: userStub.admin,
|
||||
key: sharedLinkBytes,
|
||||
type: SharedLinkType.ALBUM,
|
||||
|
||||
Vendored
+7
-7
@@ -21,7 +21,7 @@ export const userDto = {
|
||||
|
||||
export const userStub = {
|
||||
admin: Object.freeze<UserEntity>({
|
||||
...authStub.admin,
|
||||
...authStub.admin.user,
|
||||
password: 'admin_password',
|
||||
name: 'admin_name',
|
||||
storageLabel: 'admin',
|
||||
@@ -38,7 +38,7 @@ export const userStub = {
|
||||
avatarColor: UserAvatarColor.PRIMARY,
|
||||
}),
|
||||
user1: Object.freeze<UserEntity>({
|
||||
...authStub.user1,
|
||||
...authStub.user1.user,
|
||||
password: 'immich_password',
|
||||
name: 'immich_name',
|
||||
storageLabel: null,
|
||||
@@ -55,7 +55,7 @@ export const userStub = {
|
||||
avatarColor: UserAvatarColor.PRIMARY,
|
||||
}),
|
||||
user2: Object.freeze<UserEntity>({
|
||||
...authStub.user2,
|
||||
...authStub.user2.user,
|
||||
password: 'immich_password',
|
||||
name: 'immich_name',
|
||||
storageLabel: null,
|
||||
@@ -72,7 +72,7 @@ export const userStub = {
|
||||
avatarColor: UserAvatarColor.PRIMARY,
|
||||
}),
|
||||
storageLabel: Object.freeze<UserEntity>({
|
||||
...authStub.user1,
|
||||
...authStub.user1.user,
|
||||
password: 'immich_password',
|
||||
name: 'immich_name',
|
||||
storageLabel: 'label-1',
|
||||
@@ -89,7 +89,7 @@ export const userStub = {
|
||||
avatarColor: UserAvatarColor.PRIMARY,
|
||||
}),
|
||||
externalPath1: Object.freeze<UserEntity>({
|
||||
...authStub.user1,
|
||||
...authStub.user1.user,
|
||||
password: 'immich_password',
|
||||
name: 'immich_name',
|
||||
storageLabel: 'label-1',
|
||||
@@ -106,7 +106,7 @@ export const userStub = {
|
||||
avatarColor: UserAvatarColor.PRIMARY,
|
||||
}),
|
||||
externalPath2: Object.freeze<UserEntity>({
|
||||
...authStub.user1,
|
||||
...authStub.user1.user,
|
||||
password: 'immich_password',
|
||||
name: 'immich_name',
|
||||
storageLabel: 'label-1',
|
||||
@@ -123,7 +123,7 @@ export const userStub = {
|
||||
avatarColor: UserAvatarColor.PRIMARY,
|
||||
}),
|
||||
profilePath: Object.freeze<UserEntity>({
|
||||
...authStub.user1,
|
||||
...authStub.user1.user,
|
||||
password: 'immich_password',
|
||||
name: 'immich_name',
|
||||
storageLabel: 'label-1',
|
||||
|
||||
Reference in New Issue
Block a user