diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-03 16:38:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-03 16:38:50 +0100 |
commit | 265ba139ebf56bbdc1c65f6ea4f367774c691fc0 (patch) | |
tree | c7c52d1ae48a35b8f9aa06a9fa2335a6ba502fd1 /server/tests/api/users | |
parent | 9bce811268cd74b402176ae9fcd8b77ac887576e (diff) | |
download | PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.gz PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.zst PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.zip |
Send account activitypub update events
Diffstat (limited to 'server/tests/api/users')
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts new file mode 100644 index 000000000..1c7f011a8 --- /dev/null +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -0,0 +1,85 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { Account } from '../../../../shared/models/actors' | ||
6 | import { doubleFollow, flushAndRunMultipleServers, wait } from '../../utils' | ||
7 | import { | ||
8 | flushTests, getMyUserInformation, killallServers, ServerInfo, testVideoImage, updateMyAvatar, | ||
9 | uploadVideo | ||
10 | } from '../../utils/index' | ||
11 | import { getAccount, getAccountsList } from '../../utils/users/accounts' | ||
12 | import { setAccessTokensToServers } from '../../utils/users/login' | ||
13 | |||
14 | const expect = chai.expect | ||
15 | |||
16 | describe('Test users with multiple servers', function () { | ||
17 | let servers: ServerInfo[] = [] | ||
18 | |||
19 | before(async function () { | ||
20 | this.timeout(120000) | ||
21 | |||
22 | servers = await flushAndRunMultipleServers(3) | ||
23 | |||
24 | // Get the access tokens | ||
25 | await setAccessTokensToServers(servers) | ||
26 | |||
27 | // Server 1 and server 2 follow each other | ||
28 | await doubleFollow(servers[0], servers[1]) | ||
29 | // Server 1 and server 3 follow each other | ||
30 | await doubleFollow(servers[0], servers[2]) | ||
31 | // Server 2 and server 3 follow each other | ||
32 | await doubleFollow(servers[1], servers[2]) | ||
33 | |||
34 | // The root user of server 1 is propagated to servers 2 and 3 | ||
35 | await uploadVideo(servers[0].url, servers[0].accessToken, {}) | ||
36 | |||
37 | await wait(5000) | ||
38 | }) | ||
39 | |||
40 | it('Should be able to update my avatar', async function () { | ||
41 | this.timeout(10000) | ||
42 | |||
43 | const fixture = 'avatar2.png' | ||
44 | |||
45 | await updateMyAvatar({ | ||
46 | url: servers[0].url, | ||
47 | accessToken: servers[0].accessToken, | ||
48 | fixture | ||
49 | }) | ||
50 | |||
51 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | ||
52 | const user = res.body | ||
53 | |||
54 | const test = await testVideoImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') | ||
55 | expect(test).to.equal(true) | ||
56 | |||
57 | await wait(5000) | ||
58 | }) | ||
59 | |||
60 | it('Should have updated my avatar on other servers too', async function () { | ||
61 | for (const server of servers) { | ||
62 | const resAccounts = await getAccountsList(server.url, '-createdAt') | ||
63 | |||
64 | const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account | ||
65 | expect(rootServer1List).not.to.be.undefined | ||
66 | |||
67 | const resAccount = await getAccount(server.url, rootServer1List.id) | ||
68 | const rootServer1Get = resAccount.body as Account | ||
69 | expect(rootServer1Get.name).to.equal('root') | ||
70 | expect(rootServer1Get.host).to.equal('localhost:9001') | ||
71 | |||
72 | const test = await testVideoImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') | ||
73 | expect(test).to.equal(true) | ||
74 | } | ||
75 | }) | ||
76 | |||
77 | after(async function () { | ||
78 | killallServers(servers) | ||
79 | |||
80 | // Keep the logs if the test failed | ||
81 | if (this[ 'ok' ]) { | ||
82 | await flushTests() | ||
83 | } | ||
84 | }) | ||
85 | }) | ||