test: test don't need to set up sessions by themselves

The setup is handled inside TestSetupBuilder.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-03-05 19:20:33 +01:00
parent 9030488025
commit 9c6d3d9dab
6 changed files with 0 additions and 31 deletions

View file

@ -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';

View file

@ -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>(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);

View file

@ -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');

View file

@ -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);

View file

@ -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');

View file

@ -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());