Skip to content

Commit

Permalink
test: test don't need to set up sessions by themselves
Browse files Browse the repository at this point in the history
The setup is handled inside TestSetupBuilder.

Signed-off-by: David Mehren <[email protected]>
  • Loading branch information
davidmehren committed Mar 6, 2022
1 parent 9030488 commit 9c6d3d9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 31 deletions.
5 changes: 0 additions & 5 deletions test/private-api/auth.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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';
Expand Down
7 changes: 0 additions & 7 deletions test/private-api/history.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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', () => {
Expand All @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions test/private-api/me.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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');
Expand Down
4 changes: 0 additions & 4 deletions test/private-api/media.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions test/private-api/notes.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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');
Expand Down
6 changes: 0 additions & 6 deletions test/private-api/tokens.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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());
Expand Down

0 comments on commit 9c6d3d9

Please sign in to comment.