aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-18 10:53:54 +0100
committerChocobozzz <me@florianbigard.com>2018-01-18 15:42:20 +0100
commitf05a1c30c15d2ae35c11e241ca039a72eeb7d6ad (patch)
tree6d90c0de5dd3ad506e738d447e4f396951ed5624 /server/tests/api/users
parent1174a8479ab9ee47b3305d668fe757435057a298 (diff)
downloadPeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.gz
PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.zst
PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.zip
Don't show videos of remote instance after unfollow
Diffstat (limited to 'server/tests/api/users')
-rw-r--r--server/tests/api/users/users-multiple-servers.ts66
-rw-r--r--server/tests/api/users/users.ts4
2 files changed, 59 insertions, 11 deletions
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 1c7f011a8..0483b9c3d 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -3,18 +3,20 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { Account } from '../../../../shared/models/actors' 5import { Account } from '../../../../shared/models/actors'
6import { doubleFollow, flushAndRunMultipleServers, wait } from '../../utils' 6import { checkVideoFilesWereRemoved, createUser, doubleFollow, flushAndRunMultipleServers, removeUser, userLogin, wait } from '../../utils'
7import { 7import { flushTests, getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index'
8 flushTests, getMyUserInformation, killallServers, ServerInfo, testVideoImage, updateMyAvatar, 8import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts'
9 uploadVideo
10} from '../../utils/index'
11import { getAccount, getAccountsList } from '../../utils/users/accounts'
12import { setAccessTokensToServers } from '../../utils/users/login' 9import { setAccessTokensToServers } from '../../utils/users/login'
13 10
14const expect = chai.expect 11const expect = chai.expect
15 12
16describe('Test users with multiple servers', function () { 13describe('Test users with multiple servers', function () {
17 let servers: ServerInfo[] = [] 14 let servers: ServerInfo[] = []
15 let user
16 let userUUID
17 let userId
18 let videoUUID
19 let userAccessToken
18 20
19 before(async function () { 21 before(async function () {
20 this.timeout(120000) 22 this.timeout(120000)
@@ -34,6 +36,18 @@ describe('Test users with multiple servers', function () {
34 // The root user of server 1 is propagated to servers 2 and 3 36 // The root user of server 1 is propagated to servers 2 and 3
35 await uploadVideo(servers[0].url, servers[0].accessToken, {}) 37 await uploadVideo(servers[0].url, servers[0].accessToken, {})
36 38
39 const user = {
40 username: 'user1',
41 password: 'password'
42 }
43 const resUser = await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
44 userUUID = resUser.body.user.uuid
45 userId = resUser.body.user.id
46 userAccessToken = await userLogin(servers[0], user)
47
48 const resVideo = await uploadVideo(servers[0].url, userAccessToken, {})
49 videoUUID = resVideo.body.uuid
50
37 await wait(5000) 51 await wait(5000)
38 }) 52 })
39 53
@@ -49,9 +63,9 @@ describe('Test users with multiple servers', function () {
49 }) 63 })
50 64
51 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 65 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
52 const user = res.body 66 user = res.body
53 67
54 const test = await testVideoImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') 68 const test = await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png')
55 expect(test).to.equal(true) 69 expect(test).to.equal(true)
56 70
57 await wait(5000) 71 await wait(5000)
@@ -69,11 +83,45 @@ describe('Test users with multiple servers', function () {
69 expect(rootServer1Get.name).to.equal('root') 83 expect(rootServer1Get.name).to.equal('root')
70 expect(rootServer1Get.host).to.equal('localhost:9001') 84 expect(rootServer1Get.host).to.equal('localhost:9001')
71 85
72 const test = await testVideoImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') 86 const test = await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png')
73 expect(test).to.equal(true) 87 expect(test).to.equal(true)
74 } 88 }
75 }) 89 })
76 90
91 it('Should remove the user', async function () {
92 this.timeout(10000)
93
94 for (const server of servers) {
95 const resAccounts = await getAccountsList(server.url, '-createdAt')
96
97 const userServer1List = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account
98 expect(userServer1List).not.to.be.undefined
99 }
100
101 await removeUser(servers[0].url, userId, servers[0].accessToken)
102
103 await wait(5000)
104
105 for (const server of servers) {
106 const resAccounts = await getAccountsList(server.url, '-createdAt')
107
108 const userServer1List = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account
109 expect(userServer1List).to.be.undefined
110 }
111 })
112
113 it('Should not have actor files', async () => {
114 for (const server of servers) {
115 await checkActorFilesWereRemoved(userUUID, server.serverNumber)
116 }
117 })
118
119 it('Should not have video files', async () => {
120 for (const server of servers) {
121 await checkVideoFilesWereRemoved(videoUUID, server.serverNumber)
122 }
123 })
124
77 after(async function () { 125 after(async function () {
78 killallServers(servers) 126 killallServers(servers)
79 127
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index b788637e7..d8004ff24 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -7,7 +7,7 @@ import {
7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, getUserInformation, 7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, getUserInformation,
8 getUsersList, 8 getUsersList,
9 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo, 9 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo,
10 runServer, ServerInfo, serverLogin, testVideoImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo 10 runServer, ServerInfo, serverLogin, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo
11} from '../../utils/index' 11} from '../../utils/index'
12import { follow } from '../../utils/server/follows' 12import { follow } from '../../utils/server/follows'
13import { setAccessTokensToServers } from '../../utils/users/login' 13import { setAccessTokensToServers } from '../../utils/users/login'
@@ -361,7 +361,7 @@ describe('Test users', function () {
361 const res = await getMyUserInformation(server.url, accessTokenUser) 361 const res = await getMyUserInformation(server.url, accessTokenUser)
362 const user = res.body 362 const user = res.body
363 363
364 const test = await testVideoImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') 364 const test = await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png')
365 expect(test).to.equal(true) 365 expect(test).to.equal(true)
366 }) 366 })
367 367