test: use constant credentials

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-12-30 12:48:24 +01:00 committed by Yannick Bungers
parent 4ade25036e
commit 4271ef740c
2 changed files with 20 additions and 7 deletions

View file

@ -9,7 +9,14 @@ import { User } from 'src/users/user.entity';
import request from 'supertest';
import { ConsoleLoggerService } from '../../src/logger/console-logger.service';
import { TestSetup, TestSetupBuilder } from '../test-setup';
import {
password1,
password2,
TestSetup,
TestSetupBuilder,
username1,
username2,
} from '../test-setup';
import { ensureDeleted } from '../utils';
describe('Media', () => {
@ -44,7 +51,7 @@ describe('Media', () => {
agent = request.agent(testSetup.app.getHttpServer());
await agent
.post('/api/private/auth/local/login')
.send({ username: 'testuser1', password: 'testuser1' })
.send({ username: username1, password: password1 })
.expect(201);
});
@ -135,7 +142,7 @@ describe('Media', () => {
const agent2 = request.agent(testSetup.app.getHttpServer());
await agent2
.post('/api/private/auth/local/login')
.send({ username: 'testuser2', password: 'testuser2' })
.send({ username: username2, password: password2 })
.expect(201);
// try to delete upload with second user

View file

@ -5,8 +5,14 @@
*/
import request from 'supertest';
import { User } from '../../src/users/user.entity';
import { TestSetup, TestSetupBuilder } from '../test-setup';
import {
password1,
password2,
TestSetup,
TestSetupBuilder,
username1,
username2,
} from '../test-setup';
describe('Tokens', () => {
let testSetup: TestSetup;
@ -21,7 +27,7 @@ describe('Tokens', () => {
agent = request.agent(testSetup.app.getHttpServer());
await agent
.post('/api/private/auth/local/login')
.send({ username: 'testuser1', password: 'testuser1' })
.send({ username: username1, password: password1 })
.expect(201);
});
@ -66,7 +72,7 @@ describe('Tokens', () => {
const agent2 = request.agent(testSetup.app.getHttpServer());
await agent2
.post('/api/private/auth/local/login')
.send({ username: 'testuser2', password: 'testuser2' })
.send({ username: username2, password: password2 })
.expect(201);
let response = await agent2
.delete('/api/private/tokens/' + keyId)