diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-13 16:31:14 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-13 16:31:14 +0200 |
commit | b3b926474204ad736ec434aafc8afc6bc55079f6 (patch) | |
tree | ba235886357a8c032fea7ef17cd9ab9519ea6a2b /server/tests/api/utils.js | |
parent | 5dda52c924763a889e98b4cf97c588b34ef01812 (diff) | |
download | PeerTube-b3b926474204ad736ec434aafc8afc6bc55079f6.tar.gz PeerTube-b3b926474204ad736ec434aafc8afc6bc55079f6.tar.zst PeerTube-b3b926474204ad736ec434aafc8afc6bc55079f6.zip |
Authenticate before make/quit friends (server + tests)
Diffstat (limited to 'server/tests/api/utils.js')
-rw-r--r-- | server/tests/api/utils.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js index 45f11ac8f..9c5e4ee61 100644 --- a/server/tests/api/utils.js +++ b/server/tests/api/utils.js | |||
@@ -97,7 +97,7 @@ function loginAndGetAccessToken (server, callback) { | |||
97 | }) | 97 | }) |
98 | } | 98 | } |
99 | 99 | ||
100 | function makeFriends (url, expectedStatus, callback) { | 100 | function makeFriends (url, accessToken, expectedStatus, callback) { |
101 | if (!callback) { | 101 | if (!callback) { |
102 | callback = expectedStatus | 102 | callback = expectedStatus |
103 | expectedStatus = 204 | 103 | expectedStatus = 204 |
@@ -109,6 +109,7 @@ function makeFriends (url, expectedStatus, callback) { | |||
109 | request(url) | 109 | request(url) |
110 | .get(path) | 110 | .get(path) |
111 | .set('Accept', 'application/json') | 111 | .set('Accept', 'application/json') |
112 | .set('Authorization', 'Bearer ' + accessToken) | ||
112 | .expect(expectedStatus) | 113 | .expect(expectedStatus) |
113 | .end(function (err, res) { | 114 | .end(function (err, res) { |
114 | if (err) throw err | 115 | if (err) throw err |
@@ -118,14 +119,20 @@ function makeFriends (url, expectedStatus, callback) { | |||
118 | }) | 119 | }) |
119 | } | 120 | } |
120 | 121 | ||
121 | function quitFriends (url, callback) { | 122 | function quitFriends (url, accessToken, expectedStatus, callback) { |
123 | if (!callback) { | ||
124 | callback = expectedStatus | ||
125 | expectedStatus = 204 | ||
126 | } | ||
127 | |||
122 | const path = '/api/v1/pods/quitfriends' | 128 | const path = '/api/v1/pods/quitfriends' |
123 | 129 | ||
124 | // The first pod make friend with the third | 130 | // The first pod make friend with the third |
125 | request(url) | 131 | request(url) |
126 | .get(path) | 132 | .get(path) |
127 | .set('Accept', 'application/json') | 133 | .set('Accept', 'application/json') |
128 | .expect(204) | 134 | .set('Authorization', 'Bearer ' + accessToken) |
135 | .expect(expectedStatus) | ||
129 | .end(function (err, res) { | 136 | .end(function (err, res) { |
130 | if (err) throw err | 137 | if (err) throw err |
131 | 138 | ||