aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/singlePod.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-04-14 22:06:11 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-04-14 22:06:11 +0200
commit0c1cbbfe29d91c95f9c574b57adf067654b8b5b4 (patch)
treeb61e48caedea8881cbfd1159295f6c311b35be90 /server/tests/api/singlePod.js
parentc9bf7d30bd688e84b12dca03029dde6e9645a997 (diff)
downloadPeerTube-0c1cbbfe29d91c95f9c574b57adf067654b8b5b4.tar.gz
PeerTube-0c1cbbfe29d91c95f9c574b57adf067654b8b5b4.tar.zst
PeerTube-0c1cbbfe29d91c95f9c574b57adf067654b8b5b4.zip
Add authentications for routes that need it and adapts the tests
Diffstat (limited to 'server/tests/api/singlePod.js')
-rw-r--r--server/tests/api/singlePod.js33
1 files changed, 19 insertions, 14 deletions
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index 0b96f221a..64d5475dd 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -12,8 +12,7 @@ webtorrent.silent = true
12const utils = require('./utils') 12const utils = require('./utils')
13 13
14describe('Test a single pod', function () { 14describe('Test a single pod', function () {
15 let app = null 15 let server = null
16 let url = ''
17 let video_id = -1 16 let video_id = -1
18 17
19 before(function (done) { 18 before(function (done) {
@@ -24,9 +23,15 @@ describe('Test a single pod', function () {
24 utils.flushTests(next) 23 utils.flushTests(next)
25 }, 24 },
26 function (next) { 25 function (next) {
27 utils.runServer(1, function (app1, url1) { 26 utils.runServer(1, function (server1) {
28 app = app1 27 server = server1
29 url = url1 28 next()
29 })
30 },
31 function (next) {
32 utils.loginAndGetAccessToken(server, function (err, token) {
33 if (err) throw err
34 server.access_token = token
30 next() 35 next()
31 }) 36 })
32 }, 37 },
@@ -37,7 +42,7 @@ describe('Test a single pod', function () {
37 }) 42 })
38 43
39 it('Should not have videos', function (done) { 44 it('Should not have videos', function (done) {
40 utils.getVideosList(url, function (err, res) { 45 utils.getVideosList(server.url, function (err, res) {
41 if (err) throw err 46 if (err) throw err
42 47
43 expect(res.body).to.be.an('array') 48 expect(res.body).to.be.an('array')
@@ -49,14 +54,14 @@ describe('Test a single pod', function () {
49 54
50 it('Should upload the video', function (done) { 55 it('Should upload the video', function (done) {
51 this.timeout(5000) 56 this.timeout(5000)
52 utils.uploadVideo(url, 'my super name', 'my super description', 'video_short.webm', done) 57 utils.uploadVideo(server.url, server.access_token, 'my super name', 'my super description', 'video_short.webm', done)
53 }) 58 })
54 59
55 it('Should seed the uploaded video', function (done) { 60 it('Should seed the uploaded video', function (done) {
56 // Yes, this could be long 61 // Yes, this could be long
57 this.timeout(60000) 62 this.timeout(60000)
58 63
59 utils.getVideosList(url, function (err, res) { 64 utils.getVideosList(server.url, function (err, res) {
60 if (err) throw err 65 if (err) throw err
61 66
62 expect(res.body).to.be.an('array') 67 expect(res.body).to.be.an('array')
@@ -84,7 +89,7 @@ describe('Test a single pod', function () {
84 // Yes, this could be long 89 // Yes, this could be long
85 this.timeout(60000) 90 this.timeout(60000)
86 91
87 utils.getVideo(url, video_id, function (err, res) { 92 utils.getVideo(server.url, video_id, function (err, res) {
88 if (err) throw err 93 if (err) throw err
89 94
90 const video = res.body 95 const video = res.body
@@ -104,7 +109,7 @@ describe('Test a single pod', function () {
104 }) 109 })
105 110
106 it('Should search the video', function (done) { 111 it('Should search the video', function (done) {
107 utils.searchVideo(url, 'my', function (err, res) { 112 utils.searchVideo(server.url, 'my', function (err, res) {
108 if (err) throw err 113 if (err) throw err
109 114
110 expect(res.body).to.be.an('array') 115 expect(res.body).to.be.an('array')
@@ -120,7 +125,7 @@ describe('Test a single pod', function () {
120 }) 125 })
121 126
122 it('Should not find a search', function (done) { 127 it('Should not find a search', function (done) {
123 utils.searchVideo(url, 'hello', function (err, res) { 128 utils.searchVideo(server.url, 'hello', function (err, res) {
124 if (err) throw err 129 if (err) throw err
125 130
126 expect(res.body).to.be.an('array') 131 expect(res.body).to.be.an('array')
@@ -131,7 +136,7 @@ describe('Test a single pod', function () {
131 }) 136 })
132 137
133 it('Should remove the video', function (done) { 138 it('Should remove the video', function (done) {
134 utils.removeVideo(url, video_id, function (err) { 139 utils.removeVideo(server.url, server.access_token, video_id, function (err) {
135 if (err) throw err 140 if (err) throw err
136 141
137 fs.readdir(pathUtils.join(__dirname, '../../../test1/uploads/'), function (err, files) { 142 fs.readdir(pathUtils.join(__dirname, '../../../test1/uploads/'), function (err, files) {
@@ -144,7 +149,7 @@ describe('Test a single pod', function () {
144 }) 149 })
145 150
146 it('Should not have videos', function (done) { 151 it('Should not have videos', function (done) {
147 utils.getVideosList(url, function (err, res) { 152 utils.getVideosList(server.url, function (err, res) {
148 if (err) throw err 153 if (err) throw err
149 154
150 expect(res.body).to.be.an('array') 155 expect(res.body).to.be.an('array')
@@ -155,7 +160,7 @@ describe('Test a single pod', function () {
155 }) 160 })
156 161
157 after(function (done) { 162 after(function (done) {
158 process.kill(-app.pid) 163 process.kill(-server.app.pid)
159 process.kill(-webtorrent.app.pid) 164 process.kill(-webtorrent.app.pid)
160 165
161 // Keep the logs if the test failed 166 // Keep the logs if the test failed