diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-25 10:21:38 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-25 13:50:48 +0200 |
commit | 6b738c7a31591a83fdcd9c78b6b1f98e543c378b (patch) | |
tree | db771d0e99e9ff27570885fe2a6f58a7c1948fbc /server/tests/api/users/users-multiple-servers.ts | |
parent | 48dce1c90dff4e90a4bcffefaecf157336cf904b (diff) | |
download | PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.gz PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.zst PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.zip |
Video channel API routes refractor
Diffstat (limited to 'server/tests/api/users/users-multiple-servers.ts')
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 86 |
1 files changed, 66 insertions, 20 deletions
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index bb458f7a5..a7f3aa8d3 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -4,22 +4,33 @@ import * as chai from 'chai' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { Account } from '../../../../shared/models/actors' | 5 | import { Account } from '../../../../shared/models/actors' |
6 | import { | 6 | import { |
7 | checkVideoFilesWereRemoved, createUser, doubleFollow, flushAndRunMultipleServers, removeUser, updateMyUser, userLogin, | 7 | checkVideoFilesWereRemoved, |
8 | createUser, | ||
9 | doubleFollow, | ||
10 | flushAndRunMultipleServers, | ||
11 | getAccountVideos, | ||
12 | getVideoChannelsList, | ||
13 | removeUser, | ||
14 | updateMyUser, | ||
15 | userLogin, | ||
8 | wait | 16 | wait |
9 | } from '../../utils' | 17 | } from '../../utils' |
10 | import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' | 18 | import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' |
11 | import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' | 19 | import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' |
12 | import { setAccessTokensToServers } from '../../utils/users/login' | 20 | import { setAccessTokensToServers } from '../../utils/users/login' |
21 | import { User } from '../../../../shared/models/users' | ||
22 | import { VideoChannel } from '../../../../shared/models/videos' | ||
13 | 23 | ||
14 | const expect = chai.expect | 24 | const expect = chai.expect |
15 | 25 | ||
16 | describe('Test users with multiple servers', function () { | 26 | describe('Test users with multiple servers', function () { |
17 | let servers: ServerInfo[] = [] | 27 | let servers: ServerInfo[] = [] |
18 | let user | 28 | let user: User |
19 | let userUUID | 29 | let userAccountUUID: string |
20 | let userId | 30 | let userVideoChannelUUID: string |
21 | let videoUUID | 31 | let userId: number |
22 | let userAccessToken | 32 | let videoUUID: string |
33 | let userAccessToken: string | ||
23 | 34 | ||
24 | before(async function () { | 35 | before(async function () { |
25 | this.timeout(120000) | 36 | this.timeout(120000) |
@@ -39,17 +50,28 @@ describe('Test users with multiple servers', function () { | |||
39 | // The root user of server 1 is propagated to servers 2 and 3 | 50 | // The root user of server 1 is propagated to servers 2 and 3 |
40 | await uploadVideo(servers[0].url, servers[0].accessToken, {}) | 51 | await uploadVideo(servers[0].url, servers[0].accessToken, {}) |
41 | 52 | ||
42 | const user = { | 53 | { |
43 | username: 'user1', | 54 | const user = { |
44 | password: 'password' | 55 | username: 'user1', |
56 | password: 'password' | ||
57 | } | ||
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 | ||
61 | |||
62 | userAccessToken = await userLogin(servers[ 0 ], user) | ||
63 | } | ||
64 | |||
65 | { | ||
66 | const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
67 | const user: User = res.body | ||
68 | userVideoChannelUUID = user.videoChannels[0].uuid | ||
45 | } | 69 | } |
46 | const resUser = await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) | ||
47 | userUUID = resUser.body.user.uuid | ||
48 | userId = resUser.body.user.id | ||
49 | userAccessToken = await userLogin(servers[0], user) | ||
50 | 70 | ||
51 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, {}) | 71 | { |
52 | videoUUID = resVideo.body.uuid | 72 | const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {}) |
73 | videoUUID = resVideo.body.video.uuid | ||
74 | } | ||
53 | 75 | ||
54 | await wait(5000) | 76 | await wait(5000) |
55 | }) | 77 | }) |
@@ -106,14 +128,31 @@ describe('Test users with multiple servers', function () { | |||
106 | } | 128 | } |
107 | }) | 129 | }) |
108 | 130 | ||
131 | it('Should list account videos', async function () { | ||
132 | for (const server of servers) { | ||
133 | const res = await getAccountVideos(server.url, server.accessToken, userAccountUUID, 0, 5) | ||
134 | |||
135 | expect(res.body.total).to.equal(1) | ||
136 | expect(res.body.data).to.be.an('array') | ||
137 | expect(res.body.data).to.have.lengthOf(1) | ||
138 | expect(res.body.data[0].uuid).to.equal(videoUUID) | ||
139 | } | ||
140 | }) | ||
141 | |||
109 | it('Should remove the user', async function () { | 142 | it('Should remove the user', async function () { |
110 | this.timeout(10000) | 143 | this.timeout(10000) |
111 | 144 | ||
112 | for (const server of servers) { | 145 | for (const server of servers) { |
113 | const resAccounts = await getAccountsList(server.url, '-createdAt') | 146 | const resAccounts = await getAccountsList(server.url, '-createdAt') |
114 | 147 | ||
115 | const userServer1List = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account | 148 | const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account |
116 | expect(userServer1List).not.to.be.undefined | 149 | expect(accountDeleted).not.to.be.undefined |
150 | |||
151 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) | ||
152 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { | ||
153 | return a.displayName === 'Default user1 channel' && a.host === 'localhost:9001' | ||
154 | }) as VideoChannel | ||
155 | expect(videoChannelDeleted).not.to.be.undefined | ||
117 | } | 156 | } |
118 | 157 | ||
119 | await removeUser(servers[0].url, userId, servers[0].accessToken) | 158 | await removeUser(servers[0].url, userId, servers[0].accessToken) |
@@ -123,14 +162,21 @@ describe('Test users with multiple servers', function () { | |||
123 | for (const server of servers) { | 162 | for (const server of servers) { |
124 | const resAccounts = await getAccountsList(server.url, '-createdAt') | 163 | const resAccounts = await getAccountsList(server.url, '-createdAt') |
125 | 164 | ||
126 | const userServer1List = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account | 165 | const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account |
127 | expect(userServer1List).to.be.undefined | 166 | expect(accountDeleted).to.be.undefined |
167 | |||
168 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) | ||
169 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { | ||
170 | return a.name === 'Default user1 channel' && a.host === 'localhost:9001' | ||
171 | }) as VideoChannel | ||
172 | expect(videoChannelDeleted).to.be.undefined | ||
128 | } | 173 | } |
129 | }) | 174 | }) |
130 | 175 | ||
131 | it('Should not have actor files', async () => { | 176 | it('Should not have actor files', async () => { |
132 | for (const server of servers) { | 177 | for (const server of servers) { |
133 | await checkActorFilesWereRemoved(userUUID, server.serverNumber) | 178 | await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) |
179 | await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) | ||
134 | } | 180 | } |
135 | }) | 181 | }) |
136 | 182 | ||