-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* remove authentication module from tldraw.module --------- Co-authored-by: Tomasz Wiaderek <[email protected]>
- Loading branch information
1 parent
1a76702
commit b2ba7d9
Showing
3 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
apps/server/src/modules/tldraw/controller/api-test/tldraw.controller.401.api.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { EntityManager } from '@mikro-orm/mongodb'; | ||
import { courseFactory, TestXApiKeyClient, UserAndAccountTestFactory } from '@shared/testing'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ServerTestModule } from '@modules/server'; | ||
import { Logger } from '@src/core/logger'; | ||
import { TldrawService } from '../../service'; | ||
import { TldrawController } from '..'; | ||
import { TldrawRepo } from '../../repo'; | ||
import { tldrawEntityFactory } from '../../testing'; | ||
|
||
const baseRouteName = '/tldraw-document'; | ||
describe('tldraw controller (api)', () => { | ||
let app: INestApplication; | ||
let em: EntityManager; | ||
let testXApiKeyClient: TestXApiKeyClient; | ||
const API_KEY = '7ccd4e11-c6f6-48b0-81eb-cccf7922e7a4'; | ||
|
||
beforeAll(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [ServerTestModule], | ||
controllers: [TldrawController], | ||
providers: [Logger, TldrawService, TldrawRepo], | ||
}).compile(); | ||
|
||
app = module.createNestApplication(); | ||
await app.init(); | ||
em = module.get(EntityManager); | ||
testXApiKeyClient = new TestXApiKeyClient(app, baseRouteName, API_KEY); | ||
}); | ||
|
||
afterAll(async () => { | ||
await app.close(); | ||
}); | ||
|
||
describe('when request does not contain token', () => { | ||
const setup = async () => { | ||
const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher(); | ||
const course = courseFactory.build({ teachers: [teacherUser] }); | ||
await em.persistAndFlush([teacherAccount, teacherUser, course]); | ||
|
||
const drawingItemData = tldrawEntityFactory.build(); | ||
|
||
await em.persistAndFlush([drawingItemData]); | ||
em.clear(); | ||
|
||
return { teacherUser, drawingItemData }; | ||
}; | ||
|
||
it('should return status 401 for delete', async () => { | ||
const { drawingItemData } = await setup(); | ||
|
||
const response = await testXApiKeyClient.delete(`${drawingItemData.docName}`); | ||
|
||
expect(response.status).toEqual(401); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters