diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 21:21:47 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 21:30:18 +0200 |
commit | 0e1dc3e7c69995c691e1dd82e3c2bc68748661ca (patch) | |
tree | f2a4b5cffc72e33c902b67083bbaa35b6f22f0ca /server/tests/api/check-params/video-blacklists.js | |
parent | b0f9f39ed70299a208d1b388c72de8b7f3510cb7 (diff) | |
download | PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.gz PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.zst PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.zip |
Convert tests to typescript
Diffstat (limited to 'server/tests/api/check-params/video-blacklists.js')
-rw-r--r-- | server/tests/api/check-params/video-blacklists.js | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/server/tests/api/check-params/video-blacklists.js b/server/tests/api/check-params/video-blacklists.js deleted file mode 100644 index 53b503e56..000000000 --- a/server/tests/api/check-params/video-blacklists.js +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | /* eslint-disable no-unused-expressions */ | ||
2 | |||
3 | 'use strict' | ||
4 | |||
5 | const series = require('async/series') | ||
6 | |||
7 | const loginUtils = require('../../utils/login') | ||
8 | const requestsUtils = require('../../utils/requests') | ||
9 | const serversUtils = require('../../utils/servers') | ||
10 | const usersUtils = require('../../utils/users') | ||
11 | const videosUtils = require('../../utils/videos') | ||
12 | |||
13 | describe('Test video blacklists API validators', function () { | ||
14 | let server = null | ||
15 | let userAccessToken = null | ||
16 | |||
17 | // --------------------------------------------------------------- | ||
18 | |||
19 | before(function (done) { | ||
20 | this.timeout(120000) | ||
21 | |||
22 | series([ | ||
23 | function (next) { | ||
24 | serversUtils.flushTests(next) | ||
25 | }, | ||
26 | function (next) { | ||
27 | serversUtils.runServer(1, function (server1) { | ||
28 | server = server1 | ||
29 | |||
30 | next() | ||
31 | }) | ||
32 | }, | ||
33 | function (next) { | ||
34 | loginUtils.loginAndGetAccessToken(server, function (err, token) { | ||
35 | if (err) throw err | ||
36 | server.accessToken = token | ||
37 | |||
38 | next() | ||
39 | }) | ||
40 | }, | ||
41 | function (next) { | ||
42 | const username = 'user1' | ||
43 | const password = 'my super password' | ||
44 | |||
45 | usersUtils.createUser(server.url, server.accessToken, username, password, next) | ||
46 | }, | ||
47 | function (next) { | ||
48 | const user = { | ||
49 | username: 'user1', | ||
50 | password: 'my super password' | ||
51 | } | ||
52 | |||
53 | loginUtils.getUserAccessToken(server, user, function (err, accessToken) { | ||
54 | if (err) throw err | ||
55 | |||
56 | userAccessToken = accessToken | ||
57 | |||
58 | next() | ||
59 | }) | ||
60 | }, | ||
61 | // Upload a video | ||
62 | function (next) { | ||
63 | const videoAttributes = {} | ||
64 | videosUtils.uploadVideo(server.url, server.accessToken, videoAttributes, next) | ||
65 | }, | ||
66 | function (next) { | ||
67 | videosUtils.getVideosList(server.url, function (err, res) { | ||
68 | if (err) throw err | ||
69 | |||
70 | const videos = res.body.data | ||
71 | server.video = videos[0] | ||
72 | |||
73 | next() | ||
74 | }) | ||
75 | } | ||
76 | ], done) | ||
77 | }) | ||
78 | |||
79 | describe('When adding a video in blacklist', function () { | ||
80 | const basePath = '/api/v1/videos/' | ||
81 | |||
82 | it('Should fail with nothing', function (done) { | ||
83 | const path = basePath + server.video + '/blacklist' | ||
84 | const data = {} | ||
85 | requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done) | ||
86 | }) | ||
87 | |||
88 | it('Should fail with a wrong video', function (done) { | ||
89 | const wrongPath = '/api/v1/videos/blabla/blacklist' | ||
90 | const data = {} | ||
91 | requestsUtils.makePostBodyRequest(server.url, wrongPath, server.accessToken, data, done) | ||
92 | }) | ||
93 | |||
94 | it('Should fail with a non authenticated user', function (done) { | ||
95 | const data = {} | ||
96 | const path = basePath + server.video + '/blacklist' | ||
97 | requestsUtils.makePostBodyRequest(server.url, path, 'hello', data, done, 401) | ||
98 | }) | ||
99 | |||
100 | it('Should fail with a non admin user', function (done) { | ||
101 | const data = {} | ||
102 | const path = basePath + server.video + '/blacklist' | ||
103 | requestsUtils.makePostBodyRequest(server.url, path, userAccessToken, data, done, 403) | ||
104 | }) | ||
105 | |||
106 | it('Should fail with a local video', function (done) { | ||
107 | const data = {} | ||
108 | const path = basePath + server.video.id + '/blacklist' | ||
109 | requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done, 403) | ||
110 | }) | ||
111 | }) | ||
112 | |||
113 | after(function (done) { | ||
114 | process.kill(-server.app.pid) | ||
115 | |||
116 | // Keep the logs if the test failed | ||
117 | if (this.ok) { | ||
118 | serversUtils.flushTests(done) | ||
119 | } else { | ||
120 | done() | ||
121 | } | ||
122 | }) | ||
123 | }) | ||