mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 20:14:35 -04:00
test(groups): fix 'API requires authentication' test
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
965162e1c2
commit
9c78f639e0
1 changed files with 19 additions and 6 deletions
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
|
|
||||||
|
import { GuestAccess } from '../../src/config/guest_access.enum';
|
||||||
|
import { createDefaultMockNoteConfig } from '../../src/config/mock/note.config.mock';
|
||||||
|
import { NoteConfig } from '../../src/config/note.config';
|
||||||
import { LoginDto } from '../../src/identity/local/login.dto';
|
import { LoginDto } from '../../src/identity/local/login.dto';
|
||||||
import {
|
import {
|
||||||
password1,
|
password1,
|
||||||
|
@ -16,9 +19,14 @@ import {
|
||||||
describe('Groups', () => {
|
describe('Groups', () => {
|
||||||
let testSetup: TestSetup;
|
let testSetup: TestSetup;
|
||||||
let testuser1Session: request.SuperAgentTest;
|
let testuser1Session: request.SuperAgentTest;
|
||||||
|
const noteConfigMock: NoteConfig = createDefaultMockNoteConfig();
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
testSetup = await TestSetupBuilder.create().withUsers().build();
|
testSetup = await TestSetupBuilder.create({
|
||||||
|
noteConfigMock: noteConfigMock,
|
||||||
|
})
|
||||||
|
.withUsers()
|
||||||
|
.build();
|
||||||
await testSetup.app.init();
|
await testSetup.app.init();
|
||||||
|
|
||||||
// create a test group
|
// create a test group
|
||||||
|
@ -57,10 +65,15 @@ describe('Groups', () => {
|
||||||
expect(response.status).toBe(404);
|
expect(response.status).toBe(404);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('API requires authentication', async () => {
|
describe('API requires authentication', () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
noteConfigMock.guestAccess = GuestAccess.DENY;
|
||||||
|
});
|
||||||
|
test('get group', async () => {
|
||||||
const response = await request(testSetup.app.getHttpServer()).get(
|
const response = await request(testSetup.app.getHttpServer()).get(
|
||||||
'/api/private/groups/testgroup1',
|
'/api/private/groups/testgroup1',
|
||||||
);
|
);
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue