diff options
Diffstat (limited to 'server/tests/api/check-params/video-source.ts')
-rw-r--r-- | server/tests/api/check-params/video-source.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/server/tests/api/check-params/video-source.ts b/server/tests/api/check-params/video-source.ts new file mode 100644 index 000000000..ca324bb9d --- /dev/null +++ b/server/tests/api/check-params/video-source.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
3 | |||
4 | describe('Test video sources API validator', function () { | ||
5 | let server: PeerTubeServer = null | ||
6 | let uuid: string | ||
7 | let userToken: string | ||
8 | |||
9 | before(async function () { | ||
10 | this.timeout(30000) | ||
11 | |||
12 | server = await createSingleServer(1) | ||
13 | await setAccessTokensToServers([ server ]) | ||
14 | |||
15 | const created = await server.videos.quickUpload({ name: 'video' }) | ||
16 | uuid = created.uuid | ||
17 | |||
18 | userToken = await server.users.generateUserAndToken('user') | ||
19 | }) | ||
20 | |||
21 | it('Should fail without a valid uuid', async function () { | ||
22 | await server.videos.getSource({ id: '4da6fde3-88f7-4d16-b119-108df563d0b0', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | ||
23 | }) | ||
24 | |||
25 | it('Should receive 404 when passing a non existing video id', async function () { | ||
26 | await server.videos.getSource({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | ||
27 | }) | ||
28 | |||
29 | it('Should not get the source as unauthenticated', async function () { | ||
30 | await server.videos.getSource({ id: uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401, token: null }) | ||
31 | }) | ||
32 | |||
33 | it('Should not get the source with another user', async function () { | ||
34 | await server.videos.getSource({ id: uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403, token: userToken }) | ||
35 | }) | ||
36 | |||
37 | it('Should succeed with the correct parameters get the source as another user', async function () { | ||
38 | await server.videos.getSource({ id: uuid }) | ||
39 | }) | ||
40 | |||
41 | after(async function () { | ||
42 | await cleanupTests([ server ]) | ||
43 | }) | ||
44 | }) | ||