X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Futils.js;h=f0b1c3653db6a9e2f0b63c8a63f0f9b5c393fbdb;hb=fbf1134e3e6b386c9ec5a3946c61f3faf84397fb;hp=45f11ac8f36ce57fc51b464d8ba538b2f5099532;hpb=bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js index 45f11ac8f..f0b1c3653 100644 --- a/server/tests/api/utils.js +++ b/server/tests/api/utils.js @@ -12,6 +12,7 @@ const testUtils = { getFriendsList: getFriendsList, getVideo: getVideo, getVideosList: getVideosList, + getVideosListPagination: getVideosListPagination, login: login, loginAndGetAccessToken: loginAndGetAccessToken, makeFriends: makeFriends, @@ -20,6 +21,7 @@ const testUtils = { flushAndRunMultipleServers: flushAndRunMultipleServers, runServer: runServer, searchVideo: searchVideo, + searchVideoWithPagination: searchVideoWithPagination, testImage: testImage, uploadVideo: uploadVideo } @@ -63,6 +65,19 @@ function getVideosList (url, end) { .end(end) } +function getVideosListPagination (url, start, count, end) { + const path = '/api/v1/videos' + + request(url) + .get(path) + .query({ start: start }) + .query({ count: count }) + .set('Accept', 'application/json') + .expect(200) + .expect('Content-Type', /json/) + .end(end) +} + function login (url, client, user, expectedStatus, end) { if (!end) { end = expectedStatus @@ -97,7 +112,7 @@ function loginAndGetAccessToken (server, callback) { }) } -function makeFriends (url, expectedStatus, callback) { +function makeFriends (url, accessToken, expectedStatus, callback) { if (!callback) { callback = expectedStatus expectedStatus = 204 @@ -109,6 +124,7 @@ function makeFriends (url, expectedStatus, callback) { request(url) .get(path) .set('Accept', 'application/json') + .set('Authorization', 'Bearer ' + accessToken) .expect(expectedStatus) .end(function (err, res) { if (err) throw err @@ -118,14 +134,20 @@ function makeFriends (url, expectedStatus, callback) { }) } -function quitFriends (url, callback) { +function quitFriends (url, accessToken, expectedStatus, callback) { + if (!callback) { + callback = expectedStatus + expectedStatus = 204 + } + const path = '/api/v1/pods/quitfriends' // The first pod make friend with the third request(url) .get(path) .set('Accept', 'application/json') - .expect(204) + .set('Authorization', 'Bearer ' + accessToken) + .expect(expectedStatus) .end(function (err, res) { if (err) throw err @@ -254,6 +276,19 @@ function searchVideo (url, search, end) { .end(end) } +function searchVideoWithPagination (url, search, start, count, end) { + const path = '/api/v1/videos' + + request(url) + .get(path + '/search/' + search) + .query({ start: start }) + .query({ count: count }) + .set('Accept', 'application/json') + .expect(200) + .expect('Content-Type', /json/) + .end(end) +} + function testImage (url, videoName, imagePath, callback) { request(url) .get(imagePath)