aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/request-schedulers.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-04 21:21:47 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-04 21:30:18 +0200
commit0e1dc3e7c69995c691e1dd82e3c2bc68748661ca (patch)
treef2a4b5cffc72e33c902b67083bbaa35b6f22f0ca /server/tests/api/check-params/request-schedulers.ts
parentb0f9f39ed70299a208d1b388c72de8b7f3510cb7 (diff)
downloadPeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.gz
PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.zst
PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.zip
Convert tests to typescript
Diffstat (limited to 'server/tests/api/check-params/request-schedulers.ts')
-rw-r--r--server/tests/api/check-params/request-schedulers.ts65
1 files changed, 65 insertions, 0 deletions
diff --git a/server/tests/api/check-params/request-schedulers.ts b/server/tests/api/check-params/request-schedulers.ts
new file mode 100644
index 000000000..c39f5947b
--- /dev/null
+++ b/server/tests/api/check-params/request-schedulers.ts
@@ -0,0 +1,65 @@
1/* tslint:disable:no-unused-expression */
2
3import * as request from 'supertest'
4import 'mocha'
5
6import {
7 flushTests,
8 runServer,
9 createUser,
10 setAccessTokensToServers,
11 killallServers,
12 getUserAccessToken
13} from '../../utils'
14
15describe('Test request schedulers stats API validators', function () {
16 const path = '/api/v1/request-schedulers/stats'
17 let server = null
18 let userAccessToken = null
19
20 // ---------------------------------------------------------------
21
22 before(async function () {
23 this.timeout(20000)
24
25 await flushTests()
26
27 server = await runServer(1)
28 await setAccessTokensToServers([ server ])
29
30 const username = 'user'
31 const password = 'my super password'
32 await createUser(server.url, server.accessToken, username, password)
33
34 const user = {
35 username: 'user',
36 password: 'my super password'
37 }
38
39 userAccessToken = await getUserAccessToken(server, user)
40 })
41
42 it('Should fail with an non authenticated user', async function () {
43 await request(server.url)
44 .get(path)
45 .set('Accept', 'application/json')
46 .expect(401)
47 })
48
49 it('Should fail with a non admin user', async function () {
50 await request(server.url)
51 .get(path)
52 .set('Authorization', 'Bearer ' + userAccessToken)
53 .set('Accept', 'application/json')
54 .expect(403)
55 })
56
57 after(async function () {
58 killallServers([ server ])
59
60 // Keep the logs if the test failed
61 if (this['ok']) {
62 await flushTests()
63 }
64 })
65})