aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/debug.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-11 10:56:29 +0200
committerChocobozzz <me@florianbigard.com>2019-04-11 10:58:09 +0200
commit5d79474cc66383ecbfcef6366f63a34c3af21cbf (patch)
tree6b2cd85c25294ca04c94cbbcc90353d25e9cee06 /server/tests/api/check-params/debug.ts
parent2b3f1919fda81c2781ceeb9071d426c184e1b21c (diff)
downloadPeerTube-5d79474cc66383ecbfcef6366f63a34c3af21cbf.tar.gz
PeerTube-5d79474cc66383ecbfcef6366f63a34c3af21cbf.tar.zst
PeerTube-5d79474cc66383ecbfcef6366f63a34c3af21cbf.zip
Add debug component to help admins to fix IP issues
Diffstat (limited to 'server/tests/api/check-params/debug.ts')
-rw-r--r--server/tests/api/check-params/debug.ts78
1 files changed, 78 insertions, 0 deletions
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
new file mode 100644
index 000000000..9bf664657
--- /dev/null
+++ b/server/tests/api/check-params/debug.ts
@@ -0,0 +1,78 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4
5import {
6 createUser,
7 flushTests,
8 killallServers,
9 runServer,
10 ServerInfo,
11 setAccessTokensToServers,
12 userLogin
13} from '../../../../shared/utils'
14import { makeGetRequest } from '../../../../shared/utils/requests/requests'
15
16describe('Test debug API validators', function () {
17 const path = '/api/v1/server/debug'
18 let server: ServerInfo
19 let userAccessToken = ''
20
21 // ---------------------------------------------------------------
22
23 before(async function () {
24 this.timeout(120000)
25
26 await flushTests()
27
28 server = await runServer(1)
29
30 await setAccessTokensToServers([ server ])
31
32 const user = {
33 username: 'user1',
34 password: 'my super password'
35 }
36 await createUser(server.url, server.accessToken, user.username, user.password)
37 userAccessToken = await userLogin(server, user)
38 })
39
40 describe('When getting debug endpoint', function () {
41
42 it('Should fail with a non authenticated user', async function () {
43 await makeGetRequest({
44 url: server.url,
45 path,
46 statusCodeExpected: 401
47 })
48 })
49
50 it('Should fail with a non admin user', async function () {
51 await makeGetRequest({
52 url: server.url,
53 path,
54 token: userAccessToken,
55 statusCodeExpected: 403
56 })
57 })
58
59 it('Should succeed with the correct params', async function () {
60 await makeGetRequest({
61 url: server.url,
62 path,
63 token: server.accessToken,
64 query: { startDate: new Date().toISOString() },
65 statusCodeExpected: 200
66 })
67 })
68 })
69
70 after(async function () {
71 killallServers([ server ])
72
73 // Keep the logs if the test failed
74 if (this['ok']) {
75 await flushTests()
76 }
77 })
78})