aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/jobs.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/jobs.ts')
-rw-r--r--server/tests/api/check-params/jobs.ts43
1 files changed, 42 insertions, 1 deletions
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index d85961d62..801b13d1e 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -3,7 +3,14 @@
3import 'mocha' 3import 'mocha'
4import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' 4import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
5import { HttpStatusCode } from '@shared/models' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' 6import {
7 cleanupTests,
8 createSingleServer,
9 makeGetRequest,
10 makePostBodyRequest,
11 PeerTubeServer,
12 setAccessTokensToServers
13} from '@shared/server-commands'
7 14
8describe('Test jobs API validators', function () { 15describe('Test jobs API validators', function () {
9 const path = '/api/v1/jobs/failed' 16 const path = '/api/v1/jobs/failed'
@@ -76,7 +83,41 @@ describe('Test jobs API validators', function () {
76 expectedStatus: HttpStatusCode.FORBIDDEN_403 83 expectedStatus: HttpStatusCode.FORBIDDEN_403
77 }) 84 })
78 }) 85 })
86 })
87
88 describe('When pausing/resuming the job queue', async function () {
89 const commands = [ 'pause', 'resume' ]
90
91 it('Should fail with a non authenticated user', async function () {
92 for (const command of commands) {
93 await makePostBodyRequest({
94 url: server.url,
95 path: '/api/v1/jobs/' + command,
96 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
97 })
98 }
99 })
79 100
101 it('Should fail with a non admin user', async function () {
102 for (const command of commands) {
103 await makePostBodyRequest({
104 url: server.url,
105 path: '/api/v1/jobs/' + command,
106 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
107 })
108 }
109 })
110
111 it('Should succeed with the correct params', async function () {
112 for (const command of commands) {
113 await makePostBodyRequest({
114 url: server.url,
115 path: '/api/v1/jobs/' + command,
116 token: server.accessToken,
117 expectedStatus: HttpStatusCode.NO_CONTENT_204
118 })
119 }
120 })
80 }) 121 })
81 122
82 after(async function () { 123 after(async function () {