aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/users/users-multiple-servers.ts40
-rw-r--r--server/tests/api/videos/video-channels.ts4
-rw-r--r--server/tests/feeds/feeds.ts76
3 files changed, 49 insertions, 71 deletions
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 988fdad3f..791418318 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -5,7 +5,8 @@ import 'mocha'
5import { Account } from '../../../../shared/models/actors' 5import { Account } from '../../../../shared/models/actors'
6import { 6import {
7 checkTmpIsEmpty, 7 checkTmpIsEmpty,
8 checkVideoFilesWereRemoved, cleanupTests, 8 checkVideoFilesWereRemoved,
9 cleanupTests,
9 createUser, 10 createUser,
10 doubleFollow, 11 doubleFollow,
11 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
@@ -15,14 +16,7 @@ import {
15 updateMyUser, 16 updateMyUser,
16 userLogin 17 userLogin
17} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
18import { 19import { getMyUserInformation, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/extra-utils/index'
19 getMyUserInformation,
20 killallServers,
21 ServerInfo,
22 testImage,
23 updateMyAvatar,
24 uploadVideo
25} from '../../../../shared/extra-utils/index'
26import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts' 20import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts'
27import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' 21import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
28import { User } from '../../../../shared/models/users' 22import { User } from '../../../../shared/models/users'
@@ -34,12 +28,10 @@ const expect = chai.expect
34describe('Test users with multiple servers', function () { 28describe('Test users with multiple servers', function () {
35 let servers: ServerInfo[] = [] 29 let servers: ServerInfo[] = []
36 let user: User 30 let user: User
37 let userAccountName: string
38 let userAccountUUID: string
39 let userVideoChannelUUID: string
40 let userId: number 31 let userId: number
41 let videoUUID: string 32 let videoUUID: string
42 let userAccessToken: string 33 let userAccessToken: string
34 let userAvatarFilename: string
43 35
44 before(async function () { 36 before(async function () {
45 this.timeout(120000) 37 this.timeout(120000)
@@ -75,19 +67,6 @@ describe('Test users with multiple servers', function () {
75 } 67 }
76 68
77 { 69 {
78 const res = await getMyUserInformation(servers[0].url, userAccessToken)
79 const account: Account = res.body.account
80 userAccountName = account.name + '@' + account.host
81 userAccountUUID = account.uuid
82 }
83
84 {
85 const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken)
86 const user: User = res.body
87 userVideoChannelUUID = user.videoChannels[0].uuid
88 }
89
90 {
91 const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {}) 70 const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {})
92 videoUUID = resVideo.body.video.uuid 71 videoUUID = resVideo.body.video.uuid
93 } 72 }
@@ -106,6 +85,8 @@ describe('Test users with multiple servers', function () {
106 85
107 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 86 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
108 user = res.body 87 user = res.body
88
89 const account: Account = user.account
109 expect(user.account.displayName).to.equal('my super display name') 90 expect(user.account.displayName).to.equal('my super display name')
110 91
111 await waitJobs(servers) 92 await waitJobs(servers)
@@ -142,7 +123,9 @@ describe('Test users with multiple servers', function () {
142 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 123 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
143 user = res.body 124 user = res.body
144 125
145 await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') 126 userAvatarFilename = user.account.avatar.path
127
128 await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
146 129
147 await waitJobs(servers) 130 await waitJobs(servers)
148 }) 131 })
@@ -173,7 +156,7 @@ describe('Test users with multiple servers', function () {
173 156
174 it('Should list account videos', async function () { 157 it('Should list account videos', async function () {
175 for (const server of servers) { 158 for (const server of servers) {
176 const res = await getAccountVideos(server.url, server.accessToken, userAccountName, 0, 5) 159 const res = await getAccountVideos(server.url, server.accessToken, 'user1@localhost:' + servers[0].port, 0, 5)
177 160
178 expect(res.body.total).to.equal(1) 161 expect(res.body.total).to.equal(1)
179 expect(res.body.data).to.be.an('array') 162 expect(res.body.data).to.be.an('array')
@@ -218,8 +201,7 @@ describe('Test users with multiple servers', function () {
218 201
219 it('Should not have actor files', async () => { 202 it('Should not have actor files', async () => {
220 for (const server of servers) { 203 for (const server of servers) {
221 await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber) 204 await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber)
222 await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)
223 } 205 }
224 }) 206 })
225 207
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index e98f14ea8..2d298dd3f 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -18,12 +18,10 @@ import {
18import { 18import {
19 addVideoChannel, 19 addVideoChannel,
20 deleteVideoChannel, 20 deleteVideoChannel,
21 flushTests,
22 getAccountVideoChannelsList, 21 getAccountVideoChannelsList,
23 getMyUserInformation, 22 getMyUserInformation,
24 getVideoChannel, 23 getVideoChannel,
25 getVideoChannelsList, 24 getVideoChannelsList,
26 killallServers,
27 ServerInfo, 25 ServerInfo,
28 setAccessTokensToServers, 26 setAccessTokensToServers,
29 updateVideoChannel 27 updateVideoChannel
@@ -35,7 +33,6 @@ const expect = chai.expect
35describe('Test video channels', function () { 33describe('Test video channels', function () {
36 let servers: ServerInfo[] 34 let servers: ServerInfo[]
37 let userInfo: User 35 let userInfo: User
38 let accountUUID: string
39 let firstVideoChannelId: number 36 let firstVideoChannelId: number
40 let secondVideoChannelId: number 37 let secondVideoChannelId: number
41 let videoUUID: string 38 let videoUUID: string
@@ -51,7 +48,6 @@ describe('Test video channels', function () {
51 { 48 {
52 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 49 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
53 const user: User = res.body 50 const user: User = res.body
54 accountUUID = user.account.uuid
55 51
56 firstVideoChannelId = user.videoChannels[0].id 52 firstVideoChannelId = user.videoChannels[0].id
57 } 53 }
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 0dcdf09cf..437470327 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -7,13 +7,13 @@ import {
7 createUser, 7 createUser,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 flushTests, 10 getJSONfeed,
11 getJSONfeed, getMyUserInformation, 11 getMyUserInformation,
12 getXMLfeed, 12 getXMLfeed,
13 killallServers,
14 ServerInfo, 13 ServerInfo,
15 setAccessTokensToServers, 14 setAccessTokensToServers,
16 uploadVideo, userLogin 15 uploadVideo,
16 userLogin
17} from '../../../shared/extra-utils' 17} from '../../../shared/extra-utils'
18import * as libxmljs from 'libxmljs' 18import * as libxmljs from 'libxmljs'
19import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' 19import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
@@ -28,10 +28,10 @@ const expect = chai.expect
28describe('Test syndication feeds', () => { 28describe('Test syndication feeds', () => {
29 let servers: ServerInfo[] = [] 29 let servers: ServerInfo[] = []
30 let userAccessToken: string 30 let userAccessToken: string
31 let rootAccountUUID: string 31 let rootAccountId: number
32 let rootChannelUUID: string 32 let rootChannelId: number
33 let userAccountUUID: string 33 let userAccountId: number
34 let userChannelUUID: string 34 let userChannelId: number
35 35
36 before(async function () { 36 before(async function () {
37 this.timeout(120000) 37 this.timeout(120000)
@@ -45,8 +45,8 @@ describe('Test syndication feeds', () => {
45 { 45 {
46 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 46 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
47 const user: User = res.body 47 const user: User = res.body
48 rootAccountUUID = user.account.uuid 48 rootAccountId = user.account.id
49 rootChannelUUID = user.videoChannels[0].uuid 49 rootChannelId = user.videoChannels[0].id
50 } 50 }
51 51
52 { 52 {
@@ -56,8 +56,8 @@ describe('Test syndication feeds', () => {
56 56
57 const res = await getMyUserInformation(servers[0].url, userAccessToken) 57 const res = await getMyUserInformation(servers[0].url, userAccessToken)
58 const user: User = res.body 58 const user: User = res.body
59 userAccountUUID = user.account.uuid 59 userAccountId = user.account.id
60 userChannelUUID = user.videoChannels[0].uuid 60 userChannelId = user.videoChannels[0].id
61 } 61 }
62 62
63 { 63 {
@@ -127,71 +127,71 @@ describe('Test syndication feeds', () => {
127 }) 127 })
128 128
129 it('Should filter by account', async function () { 129 it('Should filter by account', async function () {
130 {
131 const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId })
132 const jsonObj = JSON.parse(json.text)
133 expect(jsonObj.items.length).to.be.equal(1)
134 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
135 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
136 }
137
138 {
139 const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId })
140 const jsonObj = JSON.parse(json.text)
141 expect(jsonObj.items.length).to.be.equal(1)
142 expect(jsonObj.items[ 0 ].title).to.equal('user video')
143 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
144 }
145
130 for (const server of servers) { 146 for (const server of servers) {
131 { 147 {
132 const json = await getJSONfeed(server.url, 'videos', { accountId: rootAccountUUID }) 148 const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port })
133 const jsonObj = JSON.parse(json.text) 149 const jsonObj = JSON.parse(json.text)
134 expect(jsonObj.items.length).to.be.equal(1) 150 expect(jsonObj.items.length).to.be.equal(1)
135 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') 151 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
136 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
137 } 152 }
138 153
139 { 154 {
140 const json = await getJSONfeed(server.url, 'videos', { accountId: userAccountUUID }) 155 const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port })
141 const jsonObj = JSON.parse(json.text) 156 const jsonObj = JSON.parse(json.text)
142 expect(jsonObj.items.length).to.be.equal(1) 157 expect(jsonObj.items.length).to.be.equal(1)
143 expect(jsonObj.items[ 0 ].title).to.equal('user video') 158 expect(jsonObj.items[ 0 ].title).to.equal('user video')
144 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
145 } 159 }
146 } 160 }
161 })
147 162
163 it('Should filter by video channel', async function () {
148 { 164 {
149 const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'root' }) 165 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: rootChannelId })
150 const jsonObj = JSON.parse(json.text) 166 const jsonObj = JSON.parse(json.text)
151 expect(jsonObj.items.length).to.be.equal(1) 167 expect(jsonObj.items.length).to.be.equal(1)
152 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') 168 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
169 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
153 } 170 }
154 171
155 { 172 {
156 const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'john' }) 173 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId })
157 const jsonObj = JSON.parse(json.text) 174 const jsonObj = JSON.parse(json.text)
158 expect(jsonObj.items.length).to.be.equal(1) 175 expect(jsonObj.items.length).to.be.equal(1)
159 expect(jsonObj.items[ 0 ].title).to.equal('user video') 176 expect(jsonObj.items[ 0 ].title).to.equal('user video')
177 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
160 } 178 }
161 })
162 179
163 it('Should filter by video channel', async function () {
164 for (const server of servers) { 180 for (const server of servers) {
165 { 181 {
166 const json = await getJSONfeed(server.url, 'videos', { videoChannelId: rootChannelUUID }) 182 const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port })
167 const jsonObj = JSON.parse(json.text) 183 const jsonObj = JSON.parse(json.text)
168 expect(jsonObj.items.length).to.be.equal(1) 184 expect(jsonObj.items.length).to.be.equal(1)
169 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') 185 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
170 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
171 } 186 }
172 187
173 { 188 {
174 const json = await getJSONfeed(server.url, 'videos', { videoChannelId: userChannelUUID }) 189 const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port })
175 const jsonObj = JSON.parse(json.text) 190 const jsonObj = JSON.parse(json.text)
176 expect(jsonObj.items.length).to.be.equal(1) 191 expect(jsonObj.items.length).to.be.equal(1)
177 expect(jsonObj.items[ 0 ].title).to.equal('user video') 192 expect(jsonObj.items[ 0 ].title).to.equal('user video')
178 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
179 } 193 }
180 } 194 }
181
182 {
183 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'root_channel' })
184 const jsonObj = JSON.parse(json.text)
185 expect(jsonObj.items.length).to.be.equal(1)
186 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
187 }
188
189 {
190 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'john_channel' })
191 const jsonObj = JSON.parse(json.text)
192 expect(jsonObj.items.length).to.be.equal(1)
193 expect(jsonObj.items[ 0 ].title).to.equal('user video')
194 }
195 }) 195 })
196 }) 196 })
197 197