From 9c6d3d9dabfa1a27a473b8ed6a0579c767065f77 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sat, 5 Mar 2022 19:20:33 +0100 Subject: [PATCH] test: test don't need to set up sessions by themselves The setup is handled inside TestSetupBuilder. Signed-off-by: David Mehren --- test/private-api/auth.e2e-spec.ts | 5 ----- test/private-api/history.e2e-spec.ts | 7 ------- test/private-api/me.e2e-spec.ts | 4 ---- test/private-api/media.e2e-spec.ts | 4 ---- test/private-api/notes.e2e-spec.ts | 5 ----- test/private-api/tokens.e2e-spec.ts | 6 ------ 6 files changed, 31 deletions(-) diff --git a/test/private-api/auth.e2e-spec.ts b/test/private-api/auth.e2e-spec.ts index 4f2218f29..b4832b884 100644 --- a/test/private-api/auth.e2e-spec.ts +++ b/test/private-api/auth.e2e-spec.ts @@ -10,13 +10,11 @@ */ import request from 'supertest'; -import { AuthConfig } from '../../src/config/auth.config'; import { LoginDto } from '../../src/identity/local/login.dto'; import { RegisterDto } from '../../src/identity/local/register.dto'; import { UpdatePasswordDto } from '../../src/identity/local/update-password.dto'; import { UserRelationEnum } from '../../src/users/user-relation.enum'; import { checkPassword } from '../../src/utils/password'; -import { setupSessionMiddleware } from '../../src/utils/session'; import { TestSetup, TestSetupBuilder } from '../test-setup'; describe('Auth', () => { @@ -28,9 +26,6 @@ describe('Auth', () => { beforeAll(async () => { testSetup = await TestSetupBuilder.create().build(); - - const authConfig = testSetup.configService.get('authConfig') as AuthConfig; - setupSessionMiddleware(testSetup.app, authConfig); await testSetup.app.init(); username = 'hardcoded'; diff --git a/test/private-api/history.e2e-spec.ts b/test/private-api/history.e2e-spec.ts index b3fa704ac..750337eac 100644 --- a/test/private-api/history.e2e-spec.ts +++ b/test/private-api/history.e2e-spec.ts @@ -3,10 +3,8 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { ConfigService } from '@nestjs/config'; import request from 'supertest'; -import { AuthConfig } from '../../src/config/auth.config'; import { HistoryEntryImportDto } from '../../src/history/history-entry-import.dto'; import { HistoryEntry } from '../../src/history/history-entry.entity'; import { HistoryService } from '../../src/history/history.service'; @@ -15,7 +13,6 @@ import { Note } from '../../src/notes/note.entity'; import { NotesService } from '../../src/notes/notes.service'; import { User } from '../../src/users/user.entity'; import { UsersService } from '../../src/users/users.service'; -import { setupSessionMiddleware } from '../../src/utils/session'; import { TestSetup, TestSetupBuilder } from '../test-setup'; describe('History', () => { @@ -37,10 +34,6 @@ describe('History', () => { const moduleRef = testSetup.moduleRef; - const config = moduleRef.get(ConfigService); - - const authConfig = config.get('authConfig') as AuthConfig; - setupSessionMiddleware(testSetup.app, authConfig); await testSetup.app.init(); content = 'This is a test note.'; historyService = moduleRef.get(HistoryService); diff --git a/test/private-api/me.e2e-spec.ts b/test/private-api/me.e2e-spec.ts index 13a7ffcf2..14801dc0b 100644 --- a/test/private-api/me.e2e-spec.ts +++ b/test/private-api/me.e2e-spec.ts @@ -6,12 +6,10 @@ import { promises as fs } from 'fs'; import request from 'supertest'; -import { AuthConfig } from '../../src/config/auth.config'; import { NotInDBError } from '../../src/errors/errors'; import { Note } from '../../src/notes/note.entity'; import { FullUserInfoDto } from '../../src/users/user-info.dto'; import { User } from '../../src/users/user.entity'; -import { setupSessionMiddleware } from '../../src/utils/session'; import { TestSetup, TestSetupBuilder } from '../test-setup'; describe('Me', () => { @@ -31,8 +29,6 @@ describe('Me', () => { uploadPath = testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath; - const authConfig = testSetup.configService.get('authConfig') as AuthConfig; - setupSessionMiddleware(testSetup.app, authConfig); await testSetup.app.init(); user = await testSetup.userService.createUser('hardcoded', 'Testy'); diff --git a/test/private-api/media.e2e-spec.ts b/test/private-api/media.e2e-spec.ts index 7d4a09da9..4f9160d49 100644 --- a/test/private-api/media.e2e-spec.ts +++ b/test/private-api/media.e2e-spec.ts @@ -8,9 +8,7 @@ import { join } from 'path'; import { User } from 'src/users/user.entity'; import request from 'supertest'; -import { AuthConfig } from '../../src/config/auth.config'; import { ConsoleLoggerService } from '../../src/logger/console-logger.service'; -import { setupSessionMiddleware } from '../../src/utils/session'; import { TestSetup, TestSetupBuilder } from '../test-setup'; import { ensureDeleted } from '../utils'; @@ -30,8 +28,6 @@ describe('Media', () => { testSetup.app.useStaticAssets(uploadPath, { prefix: '/uploads', }); - const authConfig = testSetup.configService.get('authConfig') as AuthConfig; - setupSessionMiddleware(testSetup.app, authConfig); await testSetup.app.init(); const logger = await testSetup.app.resolve(ConsoleLoggerService); diff --git a/test/private-api/notes.e2e-spec.ts b/test/private-api/notes.e2e-spec.ts index e77062fbb..841652900 100644 --- a/test/private-api/notes.e2e-spec.ts +++ b/test/private-api/notes.e2e-spec.ts @@ -7,10 +7,8 @@ import { promises as fs } from 'fs'; import { join } from 'path'; import request from 'supertest'; -import { AuthConfig } from '../../src/config/auth.config'; import { NotInDBError } from '../../src/errors/errors'; import { User } from '../../src/users/user.entity'; -import { setupSessionMiddleware } from '../../src/utils/session'; import { TestSetup, TestSetupBuilder } from '../test-setup'; describe('Notes', () => { @@ -32,9 +30,6 @@ describe('Notes', () => { uploadPath = testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath; - const authConfig = testSetup.configService.get('authConfig') as AuthConfig; - setupSessionMiddleware(testSetup.app, authConfig); - await testSetup.app.init(); user = await testSetup.userService.createUser('hardcoded', 'Testy'); diff --git a/test/private-api/tokens.e2e-spec.ts b/test/private-api/tokens.e2e-spec.ts index f85e604ec..0f88b8678 100644 --- a/test/private-api/tokens.e2e-spec.ts +++ b/test/private-api/tokens.e2e-spec.ts @@ -5,9 +5,7 @@ */ import request from 'supertest'; -import { AuthConfig } from '../../src/config/auth.config'; import { User } from '../../src/users/user.entity'; -import { setupSessionMiddleware } from '../../src/utils/session'; import { TestSetup, TestSetupBuilder } from '../test-setup'; describe('Tokens', () => { @@ -22,10 +20,6 @@ describe('Tokens', () => { user = await testSetup.userService.createUser('hardcoded', 'Testy'); await testSetup.identityService.createLocalIdentity(user, 'test'); - - const authConfig = testSetup.configService.get('authConfig') as AuthConfig; - setupSessionMiddleware(testSetup.app, authConfig); - await testSetup.app.init(); agent = request.agent(testSetup.app.getHttpServer());