1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Authenticate before make/quit friends (server + tests)

This commit is contained in:
Chocobozzz 2016-05-13 16:31:14 +02:00
parent 5dda52c924
commit b3b9264742
10 changed files with 68 additions and 38 deletions

View file

@ -97,7 +97,7 @@ function loginAndGetAccessToken (server, callback) {
})
}
function makeFriends (url, expectedStatus, callback) {
function makeFriends (url, accessToken, expectedStatus, callback) {
if (!callback) {
callback = expectedStatus
expectedStatus = 204
@ -109,6 +109,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 +119,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