diff options
Diffstat (limited to 'server/tests/api/check-params/bulk.ts')
-rw-r--r-- | server/tests/api/check-params/bulk.ts | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts deleted file mode 100644 index f03264b4f..000000000 --- a/server/tests/api/check-params/bulk.ts +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
4 | import { HttpStatusCode } from '@shared/models' | ||
5 | |||
6 | describe('Test bulk API validators', function () { | ||
7 | let server: PeerTubeServer | ||
8 | let userAccessToken: string | ||
9 | |||
10 | // --------------------------------------------------------------- | ||
11 | |||
12 | before(async function () { | ||
13 | this.timeout(120000) | ||
14 | |||
15 | server = await createSingleServer(1) | ||
16 | await setAccessTokensToServers([ server ]) | ||
17 | |||
18 | const user = { username: 'user1', password: 'password' } | ||
19 | await server.users.create({ username: user.username, password: user.password }) | ||
20 | |||
21 | userAccessToken = await server.login.getAccessToken(user) | ||
22 | }) | ||
23 | |||
24 | describe('When removing comments of', function () { | ||
25 | const path = '/api/v1/bulk/remove-comments-of' | ||
26 | |||
27 | it('Should fail with an unauthenticated user', async function () { | ||
28 | await makePostBodyRequest({ | ||
29 | url: server.url, | ||
30 | path, | ||
31 | fields: { accountName: 'user1', scope: 'my-videos' }, | ||
32 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 | ||
33 | }) | ||
34 | }) | ||
35 | |||
36 | it('Should fail with an unknown account', async function () { | ||
37 | await makePostBodyRequest({ | ||
38 | url: server.url, | ||
39 | token: server.accessToken, | ||
40 | path, | ||
41 | fields: { accountName: 'user2', scope: 'my-videos' }, | ||
42 | expectedStatus: HttpStatusCode.NOT_FOUND_404 | ||
43 | }) | ||
44 | }) | ||
45 | |||
46 | it('Should fail with an invalid scope', async function () { | ||
47 | await makePostBodyRequest({ | ||
48 | url: server.url, | ||
49 | token: server.accessToken, | ||
50 | path, | ||
51 | fields: { accountName: 'user1', scope: 'my-videoss' }, | ||
52 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
53 | }) | ||
54 | }) | ||
55 | |||
56 | it('Should fail to delete comments of the instance without the appropriate rights', async function () { | ||
57 | await makePostBodyRequest({ | ||
58 | url: server.url, | ||
59 | token: userAccessToken, | ||
60 | path, | ||
61 | fields: { accountName: 'user1', scope: 'instance' }, | ||
62 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | ||
63 | }) | ||
64 | }) | ||
65 | |||
66 | it('Should succeed with the correct params', async function () { | ||
67 | await makePostBodyRequest({ | ||
68 | url: server.url, | ||
69 | token: server.accessToken, | ||
70 | path, | ||
71 | fields: { accountName: 'user1', scope: 'instance' }, | ||
72 | expectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
73 | }) | ||
74 | }) | ||
75 | }) | ||
76 | |||
77 | after(async function () { | ||
78 | await cleanupTests([ server ]) | ||
79 | }) | ||
80 | }) | ||