aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorGreen-Star <Green-Star@users.noreply.github.com>2017-08-02 21:50:42 +0200
committerBigard Florian <florian.bigard@gmail.com>2017-08-02 21:50:42 +0200
commitd5f5a670fcf6258d0facf9a2fd3aabd550fbc78f (patch)
treebc945e1b6ab0f9cb36a481fea56cdfdaa8b1a341 /server/tests/api/check-params
parent291e8d3eed88fe714fb74ad897ac2c67347a85ff (diff)
downloadPeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.gz
PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.zst
PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.zip
Remove one pod (#76)
* Client: Fix typo * Client: Add removeFriend feature * Server: Add removeFriend feature * Server: Update method name * Fix rebase onto develop issues * Server: Fix error message * Server: Remove useless methods in removeFriend method * Server: Finish remove on pod feature after rebase * Server: Type pod parameter * Fix Travis build * Add friend-basic test for the remove one pod feature * Add check-params tests for the remove one pod feature * Fix typos * Add friend-advanced test for the remove one pod feature * Client: Trailing new line * Move to promises * Add undefined id test * Use find method instead of a for loop to find the friend to remove * Remove setTimeout method * Server: Remove requestScheduler operations * Server: Fix logging messages * Server: Remove sign request parameter
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/pods.js52
1 files changed, 48 insertions, 4 deletions
diff --git a/server/tests/api/check-params/pods.js b/server/tests/api/check-params/pods.js
index 2567fff5f..35ea59093 100644
--- a/server/tests/api/check-params/pods.js
+++ b/server/tests/api/check-params/pods.js
@@ -17,7 +17,7 @@ describe('Test pods API validators', function () {
17 // --------------------------------------------------------------- 17 // ---------------------------------------------------------------
18 18
19 before(function (done) { 19 before(function (done) {
20 this.timeout(20000) 20 this.timeout(45000)
21 21
22 series([ 22 series([
23 function (next) { 23 function (next) {
@@ -110,7 +110,7 @@ describe('Test pods API validators', function () {
110 .expect(400, done) 110 .expect(400, done)
111 }) 111 })
112 112
113 it('Should fail with a invalid token', function (done) { 113 it('Should fail with an invalid token', function (done) {
114 request(server.url) 114 request(server.url)
115 .post(path + '/makefriends') 115 .post(path + '/makefriends')
116 .send(body) 116 .send(body)
@@ -130,7 +130,7 @@ describe('Test pods API validators', function () {
130 }) 130 })
131 131
132 describe('When quitting friends', function () { 132 describe('When quitting friends', function () {
133 it('Should fail with a invalid token', function (done) { 133 it('Should fail with an invalid token', function (done) {
134 request(server.url) 134 request(server.url)
135 .get(path + '/quitfriends') 135 .get(path + '/quitfriends')
136 .query({ start: 'hello' }) 136 .query({ start: 'hello' })
@@ -148,6 +148,50 @@ describe('Test pods API validators', function () {
148 .expect(403, done) 148 .expect(403, done)
149 }) 149 })
150 }) 150 })
151
152 describe('When removing one friend', function () {
153 it('Should fail with an invalid token', function (done) {
154 request(server.url)
155 .delete(path + '/1')
156 .set('Authorization', 'Bearer faketoken')
157 .set('Accept', 'application/json')
158 .expect(401, done)
159 })
160
161 it('Should fail if the user is not an administrator', function (done) {
162 request(server.url)
163 .delete(path + '/1')
164 .set('Authorization', 'Bearer ' + userAccessToken)
165 .set('Accept', 'application/json')
166 .expect(403, done)
167 })
168
169 it('Should fail with an undefined id', function (done) {
170 request(server.url)
171 .delete(path + '/' + undefined)
172 .set('Authorization', 'Bearer ' + server.accessToken)
173 .set('Accept', 'application/json')
174 .expect(400, done)
175 })
176
177 it('Should fail with an invalid id', function (done) {
178 request(server.url)
179 .delete(path + '/foobar')
180 .set('Authorization', 'Bearer ' + server.accessToken)
181 .set('Accept', 'application/json')
182 .expect(400, done)
183 })
184
185 it('Should fail if the pod is not a friend', function (done) {
186 request(server.url)
187 .delete(path + '/-1')
188 .set('Authorization', 'Bearer ' + server.accessToken)
189 .set('Accept', 'application/json')
190 .expect(404, done)
191 })
192
193 it('Should succeed with the correct parameters')
194 })
151 }) 195 })
152 196
153 describe('When adding a pod', function () { 197 describe('When adding a pod', function () {
@@ -181,7 +225,7 @@ describe('Test pods API validators', function () {
181 requestsUtils.makePostBodyRequest(server.url, path, null, data, done) 225 requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
182 }) 226 })
183 227
184 it('Should fail without an host', function (done) { 228 it('Should fail without a host', function (done) {
185 const data = { 229 const data = {
186 email: 'testexample.com', 230 email: 'testexample.com',
187 publicKey: 'mysuperpublickey' 231 publicKey: 'mysuperpublickey'