diff --git a/src/api/private/tokens/tokens.controller.ts b/src/api/private/tokens/tokens.controller.ts index d785e2ccf..aa730d1fa 100644 --- a/src/api/private/tokens/tokens.controller.ts +++ b/src/api/private/tokens/tokens.controller.ts @@ -33,9 +33,9 @@ export class TokensController { @Get() async getUserTokens(): Promise { // ToDo: Get real userName - return ( - await this.authService.getTokensByUsername('hardcoded') - ).map((token) => this.authService.toAuthTokenDto(token)); + return (await this.authService.getTokensByUsername('hardcoded')).map( + (token) => this.authService.toAuthTokenDto(token), + ); } @Post() diff --git a/src/auth/auth.service.spec.ts b/src/auth/auth.service.spec.ts index c3a255d3d..695c36578 100644 --- a/src/auth/auth.service.spec.ts +++ b/src/auth/auth.service.spec.ts @@ -159,13 +159,15 @@ describe('AuthService', () => { user: user, lastUsed: new Date(1549312452000), }); - jest.spyOn(authTokenRepo, 'save').mockImplementationOnce( - async (authTokenSaved, _): Promise => { - expect(authTokenSaved.keyId).toEqual(authToken.keyId); - expect(authTokenSaved.lastUsed).not.toEqual(1549312452000); - return authToken; - }, - ); + jest + .spyOn(authTokenRepo, 'save') + .mockImplementationOnce( + async (authTokenSaved, _): Promise => { + expect(authTokenSaved.keyId).toEqual(authToken.keyId); + expect(authTokenSaved.lastUsed).not.toEqual(1549312452000); + return authToken; + }, + ); await service.setLastUsedToken(authToken.keyId); }); it('throws if the token is not in the database', async () => { @@ -189,11 +191,11 @@ describe('AuthService', () => { user: user, accessTokenHash: accessTokenHash, }); - jest.spyOn(authTokenRepo, 'save').mockImplementationOnce( - async (_, __): Promise => { + jest + .spyOn(authTokenRepo, 'save') + .mockImplementationOnce(async (_, __): Promise => { return authToken; - }, - ); + }); const userByToken = await service.validateToken( `${authToken.keyId}.${token}`, ); @@ -222,15 +224,15 @@ describe('AuthService', () => { ...authToken, user: user, }); - jest.spyOn(authTokenRepo, 'remove').mockImplementationOnce( - async (token, __): Promise => { + jest + .spyOn(authTokenRepo, 'remove') + .mockImplementationOnce(async (token, __): Promise => { expect(token).toEqual({ ...authToken, user: user, }); return authToken; - }, - ); + }); await service.removeToken(authToken.keyId); }); it('throws if the token is not in the database', async () => { @@ -249,12 +251,14 @@ describe('AuthService', () => { ...user, authTokens: [authToken], }); - jest.spyOn(authTokenRepo, 'save').mockImplementationOnce( - async (authTokenSaved: AuthToken, _): Promise => { - expect(authTokenSaved.lastUsed).toBeNull(); - return authTokenSaved; - }, - ); + jest + .spyOn(authTokenRepo, 'save') + .mockImplementationOnce( + async (authTokenSaved: AuthToken, _): Promise => { + expect(authTokenSaved.lastUsed).toBeNull(); + return authTokenSaved; + }, + ); const token = await service.createTokenForUser( user.userName, identifier, @@ -273,12 +277,14 @@ describe('AuthService', () => { ...user, authTokens: [authToken], }); - jest.spyOn(authTokenRepo, 'save').mockImplementationOnce( - async (authTokenSaved: AuthToken, _): Promise => { - expect(authTokenSaved.lastUsed).toBeNull(); - return authTokenSaved; - }, - ); + jest + .spyOn(authTokenRepo, 'save') + .mockImplementationOnce( + async (authTokenSaved: AuthToken, _): Promise => { + expect(authTokenSaved.lastUsed).toBeNull(); + return authTokenSaved; + }, + ); const validUntil = new Date().getTime() + 30000; const token = await service.createTokenForUser( user.userName, diff --git a/src/config/auth.config.ts b/src/config/auth.config.ts index 26c918252..3de148f16 100644 --- a/src/config/auth.config.ts +++ b/src/config/auth.config.ts @@ -229,20 +229,18 @@ const authSchema = Joi.object({ export default registerAs('authConfig', () => { // ToDo: Validate these with Joi to prevent duplicate entries? - const gitlabNames = toArrayConfig( - process.env.HD_AUTH_GITLABS, - ',', - ).map((name) => name.toUpperCase()); + const gitlabNames = toArrayConfig(process.env.HD_AUTH_GITLABS, ',').map( + (name) => name.toUpperCase(), + ); const ldapNames = toArrayConfig(process.env.HD_AUTH_LDAPS, ',').map((name) => name.toUpperCase(), ); const samlNames = toArrayConfig(process.env.HD_AUTH_SAMLS, ',').map((name) => name.toUpperCase(), ); - const oauth2Names = toArrayConfig( - process.env.HD_AUTH_OAUTH2S, - ',', - ).map((name) => name.toUpperCase()); + const oauth2Names = toArrayConfig(process.env.HD_AUTH_OAUTH2S, ',').map( + (name) => name.toUpperCase(), + ); const gitlabs = gitlabNames.map((gitlabName) => { return { diff --git a/src/frontend-config/frontend-config.service.spec.ts b/src/frontend-config/frontend-config.service.spec.ts index 05d06ba53..f69265a9a 100644 --- a/src/frontend-config/frontend-config.service.spec.ts +++ b/src/frontend-config/frontend-config.service.spec.ts @@ -210,12 +210,13 @@ describe('FrontendConfigService', () => { imprint: imprintLink, }, }; - const externalServicesConfig: ExternalServicesConfig = { - plantUmlServer: plantUmlServer, - imageProxy: imageProxy, - }; - const module: TestingModule = await Test.createTestingModule( + const externalServicesConfig: ExternalServicesConfig = { + plantUmlServer: plantUmlServer, + imageProxy: imageProxy, + }; + const module: TestingModule = + await Test.createTestingModule({ imports: [ ConfigModule.forRoot({ isGlobal: true, @@ -238,8 +239,7 @@ describe('FrontendConfigService', () => { LoggerModule, ], providers: [FrontendConfigService], - }, - ).compile(); + }).compile(); const service = module.get(FrontendConfigService); const config = await service.getFrontendConfig(); diff --git a/src/history/history.service.spec.ts b/src/history/history.service.spec.ts index e7fc8a48b..509a9382f 100644 --- a/src/history/history.service.spec.ts +++ b/src/history/history.service.spec.ts @@ -250,12 +250,14 @@ describe('HistoryService', () => { const historyEntry = HistoryEntry.create(user, note); it('with an entry', async () => { jest.spyOn(historyRepo, 'find').mockResolvedValueOnce([historyEntry]); - jest.spyOn(historyRepo, 'remove').mockImplementationOnce( - async (entry: HistoryEntry): Promise => { - expect(entry).toEqual(historyEntry); - return entry; - }, - ); + jest + .spyOn(historyRepo, 'remove') + .mockImplementationOnce( + async (entry: HistoryEntry): Promise => { + expect(entry).toEqual(historyEntry); + return entry; + }, + ); await service.deleteHistory(user); }); it('with multiple entries', async () => { @@ -298,12 +300,14 @@ describe('HistoryService', () => { const historyEntry = HistoryEntry.create(user, note); jest.spyOn(historyRepo, 'findOne').mockResolvedValueOnce(historyEntry); jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note); - jest.spyOn(historyRepo, 'remove').mockImplementation( - async (entry: HistoryEntry): Promise => { - expect(entry).toEqual(historyEntry); - return entry; - }, - ); + jest + .spyOn(historyRepo, 'remove') + .mockImplementation( + async (entry: HistoryEntry): Promise => { + expect(entry).toEqual(historyEntry); + return entry; + }, + ); await service.deleteHistoryEntry(alias, user); }); }); diff --git a/src/media/backends/azure-backend.ts b/src/media/backends/azure-backend.ts index 2ed8f0986..17b1f1332 100644 --- a/src/media/backends/azure-backend.ts +++ b/src/media/backends/azure-backend.ts @@ -42,9 +42,8 @@ export class AzureBackend implements MediaBackend { buffer: Buffer, fileName: string, ): Promise<[string, BackendData]> { - const blockBlobClient: BlockBlobClient = this.client.getBlockBlobClient( - fileName, - ); + const blockBlobClient: BlockBlobClient = + this.client.getBlockBlobClient(fileName); try { await blockBlobClient.upload(buffer, buffer.length); const url = this.getUrl(fileName); @@ -61,9 +60,8 @@ export class AzureBackend implements MediaBackend { } async deleteFile(fileName: string, _: BackendData): Promise { - const blockBlobClient: BlockBlobClient = this.client.getBlockBlobClient( - fileName, - ); + const blockBlobClient: BlockBlobClient = + this.client.getBlockBlobClient(fileName); try { await blockBlobClient.delete(); const url = this.getUrl(fileName); diff --git a/src/media/media.service.spec.ts b/src/media/media.service.spec.ts index 940fc5a86..3d0a098bd 100644 --- a/src/media/media.service.spec.ts +++ b/src/media/media.service.spec.ts @@ -112,15 +112,17 @@ describe('MediaService', () => { fileId = entry.id; return entry; }); - jest.spyOn(service.mediaBackend, 'saveFile').mockImplementationOnce( - async ( - buffer: Buffer, - fileName: string, - ): Promise<[string, BackendData]> => { - expect(buffer).toEqual(testImage); - return [fileName, null]; - }, - ); + jest + .spyOn(service.mediaBackend, 'saveFile') + .mockImplementationOnce( + async ( + buffer: Buffer, + fileName: string, + ): Promise<[string, BackendData]> => { + expect(buffer).toEqual(testImage); + return [fileName, null]; + }, + ); const url = await service.saveFile(testImage, 'hardcoded', 'test'); expect(url).toEqual(fileId); }); @@ -150,12 +152,14 @@ describe('MediaService', () => { userName: 'hardcoded', } as User, } as MediaUpload; - jest.spyOn(service.mediaBackend, 'deleteFile').mockImplementationOnce( - async (fileName: string, backendData: BackendData): Promise => { - expect(fileName).toEqual(mockMediaUploadEntry.id); - expect(backendData).toEqual(mockMediaUploadEntry.backendData); - }, - ); + jest + .spyOn(service.mediaBackend, 'deleteFile') + .mockImplementationOnce( + async (fileName: string, backendData: BackendData): Promise => { + expect(fileName).toEqual(mockMediaUploadEntry.id); + expect(backendData).toEqual(mockMediaUploadEntry.backendData); + }, + ); jest .spyOn(mediaRepo, 'remove') .mockImplementationOnce(async (entry, _) => { diff --git a/src/permissions/permissions.service.spec.ts b/src/permissions/permissions.service.spec.ts index f9fabf46f..c97ef750d 100644 --- a/src/permissions/permissions.service.spec.ts +++ b/src/permissions/permissions.service.spec.ts @@ -462,9 +462,8 @@ describe('PermissionsService', () => { describe('check if groups work with', () => { const guestPermission = GuestPermission.WRITE; - const rawPermissions = createNoteGroupPermissionsCombinations( - guestPermission, - ); + const rawPermissions = + createNoteGroupPermissionsCombinations(guestPermission); const permissions = permuteNoteGroupPermissions(rawPermissions); let i = 0; for (const permission of permissions) { diff --git a/test/public-api/me.e2e-spec.ts b/test/public-api/me.e2e-spec.ts index 53e810eae..3d58d8b60 100644 --- a/test/public-api/me.e2e-spec.ts +++ b/test/public-api/me.e2e-spec.ts @@ -122,18 +122,15 @@ describe('Me', () => { it('works with an existing note', async () => { const noteName = 'testGetNoteHistory2'; const note = await notesService.createNote('', noteName); - const createdHistoryEntry = await historyService.createOrUpdateHistoryEntry( - note, - user, - ); + const createdHistoryEntry = + await historyService.createOrUpdateHistoryEntry(note, user); const response = await request(app.getHttpServer()) .get(`/me/history/${noteName}`) .expect('Content-Type', /json/) .expect(200); const historyEntry = response.body; - const historyEntryDto = historyService.toHistoryEntryDto( - createdHistoryEntry, - ); + const historyEntryDto = + historyService.toHistoryEntryDto(createdHistoryEntry); expect(historyEntry.identifier).toEqual(historyEntryDto.identifier); expect(historyEntry.title).toEqual(historyEntryDto.title); expect(historyEntry.tags).toEqual(historyEntryDto.tags);