aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-21 10:34:18 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd (patch)
treee442f6cdf0cb622cb78f64d0d9de23bfb6deb951 /server/tests/api
parent8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (diff)
downloadPeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.tar.gz
PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.tar.zst
PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.zip
Add get subscription endpoint
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts59
-rw-r--r--server/tests/api/users/user-subscriptions.ts27
2 files changed, 81 insertions, 5 deletions
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 628a74476..6a6dd9a6f 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -61,7 +61,7 @@ describe('Test user subscriptions API validators', function () {
61 }) 61 })
62 }) 62 })
63 63
64 it('Should success with the correct parameters', async function () { 64 it('Should succeed with the correct parameters', async function () {
65 await makeGetRequest({ 65 await makeGetRequest({
66 url: server.url, 66 url: server.url,
67 path, 67 path,
@@ -94,7 +94,7 @@ describe('Test user subscriptions API validators', function () {
94 }) 94 })
95 }) 95 })
96 96
97 it('Should success with the correct parameters', async function () { 97 it('Should succeed with the correct parameters', async function () {
98 await makeGetRequest({ 98 await makeGetRequest({
99 url: server.url, 99 url: server.url,
100 path, 100 path,
@@ -140,7 +140,7 @@ describe('Test user subscriptions API validators', function () {
140 }) 140 })
141 }) 141 })
142 142
143 it('Should success with the correct parameters', async function () { 143 it('Should succeed with the correct parameters', async function () {
144 await makePostBodyRequest({ 144 await makePostBodyRequest({
145 url: server.url, 145 url: server.url,
146 path, 146 path,
@@ -151,6 +151,57 @@ describe('Test user subscriptions API validators', function () {
151 }) 151 })
152 }) 152 })
153 153
154 describe('When getting a subscription', function () {
155 it('Should fail with a non authenticated user', async function () {
156 await makeGetRequest({
157 url: server.url,
158 path: path + '/user1_channel@localhost:9001',
159 statusCodeExpected: 401
160 })
161 })
162
163 it('Should fail with bad URIs', async function () {
164 await makeGetRequest({
165 url: server.url,
166 path: path + '/root',
167 token: server.accessToken,
168 statusCodeExpected: 400
169 })
170
171 await makeGetRequest({
172 url: server.url,
173 path: path + '/root@',
174 token: server.accessToken,
175 statusCodeExpected: 400
176 })
177
178 await makeGetRequest({
179 url: server.url,
180 path: path + '/root@hello@',
181 token: server.accessToken,
182 statusCodeExpected: 400
183 })
184 })
185
186 it('Should fail with an unknown subscription', async function () {
187 await makeGetRequest({
188 url: server.url,
189 path: path + '/root1@localhost:9001',
190 token: server.accessToken,
191 statusCodeExpected: 404
192 })
193 })
194
195 it('Should succeed with the correct parameters', async function () {
196 await makeGetRequest({
197 url: server.url,
198 path: path + '/user1_channel@localhost:9001',
199 token: server.accessToken,
200 statusCodeExpected: 200
201 })
202 })
203 })
204
154 describe('When removing a subscription', function () { 205 describe('When removing a subscription', function () {
155 it('Should fail with a non authenticated user', async function () { 206 it('Should fail with a non authenticated user', async function () {
156 await makeDeleteRequest({ 207 await makeDeleteRequest({
@@ -192,7 +243,7 @@ describe('Test user subscriptions API validators', function () {
192 }) 243 })
193 }) 244 })
194 245
195 it('Should success with the correct parameters', async function () { 246 it('Should succeed with the correct parameters', async function () {
196 await makeDeleteRequest({ 247 await makeDeleteRequest({
197 url: server.url, 248 url: server.url,
198 path: path + '/user1_channel@localhost:9001', 249 path: path + '/user1_channel@localhost:9001',
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index ba59a9a60..2fbda6828 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -11,7 +11,8 @@ import {
11 addUserSubscription, 11 addUserSubscription,
12 listUserSubscriptions, 12 listUserSubscriptions,
13 listUserSubscriptionVideos, 13 listUserSubscriptionVideos,
14 removeUserSubscription 14 removeUserSubscription,
15 getUserSubscription
15} from '../../utils/users/user-subscriptions' 16} from '../../utils/users/user-subscriptions'
16 17
17const expect = chai.expect 18const expect = chai.expect
@@ -101,6 +102,30 @@ describe('Test users subscriptions', function () {
101 } 102 }
102 }) 103 })
103 104
105 it('Should get subscription', async function () {
106 {
107 const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:9003')
108 const videoChannel: VideoChannel = res.body
109
110 expect(videoChannel.name).to.equal('user3_channel')
111 expect(videoChannel.host).to.equal('localhost:9003')
112 expect(videoChannel.displayName).to.equal('Main user3 channel')
113 expect(videoChannel.followingCount).to.equal(0)
114 expect(videoChannel.followersCount).to.equal(1)
115 }
116
117 {
118 const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:9001')
119 const videoChannel: VideoChannel = res.body
120
121 expect(videoChannel.name).to.equal('root_channel')
122 expect(videoChannel.host).to.equal('localhost:9001')
123 expect(videoChannel.displayName).to.equal('Main root channel')
124 expect(videoChannel.followingCount).to.equal(0)
125 expect(videoChannel.followersCount).to.equal(1)
126 }
127 })
128
104 it('Should list subscription videos', async function () { 129 it('Should list subscription videos', async function () {
105 { 130 {
106 const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) 131 const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken)