aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/accounts.ts4
-rw-r--r--server/tests/api/check-params/video-channels.ts10
-rw-r--r--server/tests/api/check-params/videos.ts6
-rw-r--r--server/tests/api/users/users-multiple-servers.ts15
-rw-r--r--server/tests/api/videos/video-channels.ts5
-rw-r--r--server/tests/api/videos/video-nsfw.ts6
-rw-r--r--server/tests/utils/users/accounts.ts4
-rw-r--r--server/tests/utils/videos/video-channels.ts4
-rw-r--r--server/tests/utils/videos/videos.ts4
9 files changed, 28 insertions, 30 deletions
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index 50dc0804e..9e0b1e35c 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -35,8 +35,8 @@ describe('Test users API validators', function () {
35 }) 35 })
36 36
37 describe('When getting an account', function () { 37 describe('When getting an account', function () {
38 it('Should return 404 with a non existing id', async function () { 38 it('Should return 404 with a non existing name', async function () {
39 await getAccount(server.url, 4545454, 404) 39 await getAccount(server.url, 'arfaze', 404)
40 }) 40 })
41 }) 41 })
42 42
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 56b990be6..5080af2c9 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -7,7 +7,8 @@ import {
7 createUser, 7 createUser,
8 deleteVideoChannel, 8 deleteVideoChannel,
9 flushTests, 9 flushTests,
10 getAccountVideoChannelsList, getMyUserInformation, 10 getAccountVideoChannelsList,
11 getMyUserInformation,
11 getVideoChannelsList, 12 getVideoChannelsList,
12 immutableAssign, 13 immutableAssign,
13 killallServers, 14 killallServers,
@@ -20,7 +21,6 @@ import {
20 userLogin 21 userLogin
21} from '../../utils' 22} from '../../utils'
22import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 23import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
23import { getAccountsList } from '../../utils/users/accounts'
24import { User } from '../../../../shared/models/users' 24import { User } from '../../../../shared/models/users'
25 25
26const expect = chai.expect 26const expect = chai.expect
@@ -74,12 +74,8 @@ describe('Test video channels API validator', function () {
74 }) 74 })
75 75
76 describe('When listing account video channels', function () { 76 describe('When listing account video channels', function () {
77 it('Should fail with bad account', async function () {
78 await getAccountVideoChannelsList(server.url, 'hello', 400)
79 })
80
81 it('Should fail with a unknown account', async function () { 77 it('Should fail with a unknown account', async function () {
82 await getAccountVideoChannelsList(server.url, 154, 404) 78 await getAccountVideoChannelsList(server.url, 'unknown', 404)
83 }) 79 })
84 }) 80 })
85 81
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index c81e9752e..7b40b91e7 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -18,7 +18,7 @@ describe('Test videos API validator', function () {
18 const path = '/api/v1/videos/' 18 const path = '/api/v1/videos/'
19 let server: ServerInfo 19 let server: ServerInfo
20 let userAccessToken = '' 20 let userAccessToken = ''
21 let accountUUID: string 21 let accountName: string
22 let channelId: number 22 let channelId: number
23 let channelUUID: string 23 let channelUUID: string
24 let videoId 24 let videoId
@@ -43,7 +43,7 @@ describe('Test videos API validator', function () {
43 const res = await getMyUserInformation(server.url, server.accessToken) 43 const res = await getMyUserInformation(server.url, server.accessToken)
44 channelId = res.body.videoChannels[ 0 ].id 44 channelId = res.body.videoChannels[ 0 ].id
45 channelUUID = res.body.videoChannels[ 0 ].uuid 45 channelUUID = res.body.videoChannels[ 0 ].uuid
46 accountUUID = res.body.account.uuid 46 accountName = res.body.account.name + '@' + res.body.account.host
47 } 47 }
48 }) 48 })
49 49
@@ -116,7 +116,7 @@ describe('Test videos API validator', function () {
116 let path: string 116 let path: string
117 117
118 before(async function () { 118 before(async function () {
119 path = '/api/v1/accounts/' + accountUUID + '/videos' 119 path = '/api/v1/accounts/' + accountName + '/videos'
120 }) 120 })
121 121
122 it('Should fail with a bad start pagination', async function () { 122 it('Should fail with a bad start pagination', async function () {
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 8b9b63348..0e1e6c97d 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -26,7 +26,7 @@ const expect = chai.expect
26describe('Test users with multiple servers', function () { 26describe('Test users with multiple servers', function () {
27 let servers: ServerInfo[] = [] 27 let servers: ServerInfo[] = []
28 let user: User 28 let user: User
29 let userAccountUUID: string 29 let userAccountName: string
30 let userVideoChannelUUID: string 30 let userVideoChannelUUID: string
31 let userId: number 31 let userId: number
32 let videoUUID: string 32 let videoUUID: string
@@ -56,13 +56,16 @@ describe('Test users with multiple servers', function () {
56 password: 'password' 56 password: 'password'
57 } 57 }
58 const res = await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, user.username, user.password) 58 const res = await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, user.username, user.password)
59 userAccountUUID = res.body.user.account.uuid
60 userId = res.body.user.id 59 userId = res.body.user.id
61
62 userAccessToken = await userLogin(servers[ 0 ], user) 60 userAccessToken = await userLogin(servers[ 0 ], user)
63 } 61 }
64 62
65 { 63 {
64 const res = await getMyUserInformation(servers[0].url, userAccessToken)
65 userAccountName = res.body.account.name + '@' + res.body.account.host
66 }
67
68 {
66 const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken) 69 const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken)
67 const user: User = res.body 70 const user: User = res.body
68 userVideoChannelUUID = user.videoChannels[0].uuid 71 userVideoChannelUUID = user.videoChannels[0].uuid
@@ -135,7 +138,7 @@ describe('Test users with multiple servers', function () {
135 const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account 138 const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account
136 expect(rootServer1List).not.to.be.undefined 139 expect(rootServer1List).not.to.be.undefined
137 140
138 const resAccount = await getAccount(server.url, rootServer1List.id) 141 const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
139 const rootServer1Get = resAccount.body as Account 142 const rootServer1Get = resAccount.body as Account
140 expect(rootServer1Get.name).to.equal('root') 143 expect(rootServer1Get.name).to.equal('root')
141 expect(rootServer1Get.host).to.equal('localhost:9001') 144 expect(rootServer1Get.host).to.equal('localhost:9001')
@@ -148,7 +151,7 @@ describe('Test users with multiple servers', function () {
148 151
149 it('Should list account videos', async function () { 152 it('Should list account videos', async function () {
150 for (const server of servers) { 153 for (const server of servers) {
151 const res = await getAccountVideos(server.url, server.accessToken, userAccountUUID, 0, 5) 154 const res = await getAccountVideos(server.url, server.accessToken, userAccountName, 0, 5)
152 155
153 expect(res.body.total).to.equal(1) 156 expect(res.body.total).to.equal(1)
154 expect(res.body.data).to.be.an('array') 157 expect(res.body.data).to.be.an('array')
@@ -193,7 +196,7 @@ describe('Test users with multiple servers', function () {
193 196
194 it('Should not have actor files', async () => { 197 it('Should not have actor files', async () => {
195 for (const server of servers) { 198 for (const server of servers) {
196 await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) 199 await checkActorFilesWereRemoved(userAccountName, server.serverNumber)
197 await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) 200 await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)
198 } 201 }
199 }) 202 })
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 35c418f7c..7ae505fd7 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -17,7 +17,6 @@ import {
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 updateVideoChannel 18 updateVideoChannel
19} from '../../utils/index' 19} from '../../utils/index'
20import { getAccountsList } from '../../utils/users/accounts'
21 20
22const expect = chai.expect 21const expect = chai.expect
23 22
@@ -99,7 +98,7 @@ describe('Test video channels', function () {
99 }) 98 })
100 99
101 it('Should have two video channels when getting account channels on server 1', async function () { 100 it('Should have two video channels when getting account channels on server 1', async function () {
102 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid) 101 const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host)
103 expect(res.body.total).to.equal(2) 102 expect(res.body.total).to.equal(2)
104 expect(res.body.data).to.be.an('array') 103 expect(res.body.data).to.be.an('array')
105 expect(res.body.data).to.have.lengthOf(2) 104 expect(res.body.data).to.have.lengthOf(2)
@@ -112,7 +111,7 @@ describe('Test video channels', function () {
112 }) 111 })
113 112
114 it('Should have one video channel when getting account channels on server 2', async function () { 113 it('Should have one video channel when getting account channels on server 2', async function () {
115 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid) 114 const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host)
116 expect(res.body.total).to.equal(1) 115 expect(res.body.total).to.equal(1)
117 expect(res.body.data).to.be.an('array') 116 expect(res.body.data).to.be.an('array')
118 expect(res.body.data).to.have.lengthOf(1) 117 expect(res.body.data).to.have.lengthOf(1)
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index b8c85f45b..a8f152561 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -32,13 +32,13 @@ describe('Test video NSFW policy', function () {
32 .then(res => { 32 .then(res => {
33 const user: User = res.body 33 const user: User = res.body
34 const videoChannelUUID = user.videoChannels[0].uuid 34 const videoChannelUUID = user.videoChannels[0].uuid
35 const accountUUID = user.account.uuid 35 const accountName = user.account.name + '@' + user.account.host
36 36
37 if (token) { 37 if (token) {
38 return Promise.all([ 38 return Promise.all([
39 getVideosListWithToken(server.url, token), 39 getVideosListWithToken(server.url, token),
40 searchVideoWithToken(server.url, 'n', token), 40 searchVideoWithToken(server.url, 'n', token),
41 getAccountVideos(server.url, token, accountUUID, 0, 5), 41 getAccountVideos(server.url, token, accountName, 0, 5),
42 getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5) 42 getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5)
43 ]) 43 ])
44 } 44 }
@@ -46,7 +46,7 @@ describe('Test video NSFW policy', function () {
46 return Promise.all([ 46 return Promise.all([
47 getVideosList(server.url), 47 getVideosList(server.url),
48 searchVideo(server.url, 'n'), 48 searchVideo(server.url, 'n'),
49 getAccountVideos(server.url, undefined, accountUUID, 0, 5), 49 getAccountVideos(server.url, undefined, accountName, 0, 5),
50 getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5) 50 getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5)
51 ]) 51 ])
52 }) 52 })
diff --git a/server/tests/utils/users/accounts.ts b/server/tests/utils/users/accounts.ts
index a5c13c319..30b3c54f8 100644
--- a/server/tests/utils/users/accounts.ts
+++ b/server/tests/utils/users/accounts.ts
@@ -19,8 +19,8 @@ function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected =
19 }) 19 })
20} 20}
21 21
22function getAccount (url: string, accountId: number | string, statusCodeExpected = 200) { 22function getAccount (url: string, accountName: string, statusCodeExpected = 200) {
23 const path = '/api/v1/accounts/' + accountId 23 const path = '/api/v1/accounts/' + accountName
24 24
25 return makeGetRequest({ 25 return makeGetRequest({
26 url, 26 url,
diff --git a/server/tests/utils/videos/video-channels.ts b/server/tests/utils/videos/video-channels.ts
index 021c4c420..a064598f4 100644
--- a/server/tests/utils/videos/video-channels.ts
+++ b/server/tests/utils/videos/video-channels.ts
@@ -16,8 +16,8 @@ function getVideoChannelsList (url: string, start: number, count: number, sort?:
16 .expect('Content-Type', /json/) 16 .expect('Content-Type', /json/)
17} 17}
18 18
19function getAccountVideoChannelsList (url: string, accountId: number | string, specialStatus = 200) { 19function getAccountVideoChannelsList (url: string, accountName: string, specialStatus = 200) {
20 const path = '/api/v1/accounts/' + accountId + '/video-channels' 20 const path = '/api/v1/accounts/' + accountName + '/video-channels'
21 21
22 return request(url) 22 return request(url)
23 .get(path) 23 .get(path)
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts
index 07c4ffc77..46fa5f79d 100644
--- a/server/tests/utils/videos/videos.ts
+++ b/server/tests/utils/videos/videos.ts
@@ -167,8 +167,8 @@ function getMyVideos (url: string, accessToken: string, start: number, count: nu
167 .expect('Content-Type', /json/) 167 .expect('Content-Type', /json/)
168} 168}
169 169
170function getAccountVideos (url: string, accessToken: string, accountId: number | string, start: number, count: number, sort?: string) { 170function getAccountVideos (url: string, accessToken: string, accountName: string, start: number, count: number, sort?: string) {
171 const path = '/api/v1/accounts/' + accountId + '/videos' 171 const path = '/api/v1/accounts/' + accountName + '/videos'
172 172
173 return makeGetRequest({ 173 return makeGetRequest({
174 url, 174 url,