diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-26 08:50:52 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-15 15:14:21 +0200 |
commit | 48f07b4a4091cb10dc4d179118e155f3a118dca8 (patch) | |
tree | 8fcc6bd8cafa636ebaf97a083fafbcc0d52ad5cd /server/tests | |
parent | 7243f84db0f34c6d5610a54603b0cce7c284a7b3 (diff) | |
download | PeerTube-48f07b4a4091cb10dc4d179118e155f3a118dca8.tar.gz PeerTube-48f07b4a4091cb10dc4d179118e155f3a118dca8.tar.zst PeerTube-48f07b4a4091cb10dc4d179118e155f3a118dca8.zip |
All API tests in parallel
Diffstat (limited to 'server/tests')
29 files changed, 260 insertions, 197 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index edf588c16..34c6be49b 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | cleanupTests, | ||
6 | doubleFollow, | 7 | doubleFollow, |
7 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
8 | flushTests, | 9 | flushTests, |
@@ -39,7 +40,7 @@ describe('Test activitypub', function () { | |||
39 | const object = res.body | 40 | const object = res.body |
40 | 41 | ||
41 | expect(object.type).to.equal('Person') | 42 | expect(object.type).to.equal('Person') |
42 | expect(object.id).to.equal('http://localhost:9001/accounts/root') | 43 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') |
43 | expect(object.name).to.equal('root') | 44 | expect(object.name).to.equal('root') |
44 | expect(object.preferredUsername).to.equal('root') | 45 | expect(object.preferredUsername).to.equal('root') |
45 | }) | 46 | }) |
@@ -49,17 +50,17 @@ describe('Test activitypub', function () { | |||
49 | const object = res.body | 50 | const object = res.body |
50 | 51 | ||
51 | expect(object.type).to.equal('Video') | 52 | expect(object.type).to.equal('Video') |
52 | expect(object.id).to.equal('http://localhost:9001/videos/watch/' + videoUUID) | 53 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) |
53 | expect(object.name).to.equal('video') | 54 | expect(object.name).to.equal('video') |
54 | }) | 55 | }) |
55 | 56 | ||
56 | it('Should redirect to the origin video object', async function () { | 57 | it('Should redirect to the origin video object', async function () { |
57 | const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302) | 58 | const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302) |
58 | 59 | ||
59 | expect(res.header.location).to.equal('http://localhost:9001/videos/watch/' + videoUUID) | 60 | expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) |
60 | }) | 61 | }) |
61 | 62 | ||
62 | after(function () { | 63 | after(async function () { |
63 | killallServers(servers) | 64 | await cleanupTests(servers) |
64 | }) | 65 | }) |
65 | }) | 66 | }) |
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index 7240bb0fb..3a1c0d321 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | ||
5 | import { | 5 | import { |
6 | cleanupTests, | ||
6 | closeAllSequelize, | 7 | closeAllSequelize, |
7 | createUser, | 8 | createUser, |
8 | doubleFollow, | 9 | doubleFollow, |
@@ -48,8 +49,16 @@ describe('Test ActivityPub fetcher', function () { | |||
48 | const badVideoUUID = res.body.video.uuid | 49 | const badVideoUUID = res.body.video.uuid |
49 | await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' }) | 50 | await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' }) |
50 | 51 | ||
51 | await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1') | 52 | { |
52 | await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID) | 53 | const to = 'http://localhost:' + servers[0].port + '/accounts/user1' |
54 | const value = 'http://localhost:' + servers[1].port + '/accounts/user1' | ||
55 | await setActorField(servers[0].internalServerNumber, to, 'url', value) | ||
56 | } | ||
57 | |||
58 | { | ||
59 | const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID | ||
60 | await setVideoField(servers[0].internalServerNumber, badVideoUUID, 'url', value) | ||
61 | } | ||
53 | }) | 62 | }) |
54 | 63 | ||
55 | it('Should add only the video with a valid actor URL', async function () { | 64 | it('Should add only the video with a valid actor URL', async function () { |
@@ -78,7 +87,9 @@ describe('Test ActivityPub fetcher', function () { | |||
78 | }) | 87 | }) |
79 | 88 | ||
80 | after(async function () { | 89 | after(async function () { |
81 | killallServers(servers) | 90 | this.timeout(10000) |
91 | |||
92 | await cleanupTests(servers) | ||
82 | 93 | ||
83 | await closeAllSequelize(servers) | 94 | await closeAllSequelize(servers) |
84 | }) | 95 | }) |
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index 9be9aa495..921ee874c 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts | |||
@@ -2,13 +2,14 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { |
5 | cleanupTests, closeAllSequelize, | ||
5 | createVideoPlaylist, | 6 | createVideoPlaylist, |
6 | doubleFollow, | 7 | doubleFollow, |
7 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
8 | generateUserAccessToken, | 9 | generateUserAccessToken, |
9 | getVideo, | 10 | getVideo, |
10 | getVideoPlaylist, | 11 | getVideoPlaylist, |
11 | killallServers, rateVideo, | 12 | killallServers, |
12 | reRunServer, | 13 | reRunServer, |
13 | ServerInfo, | 14 | ServerInfo, |
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
@@ -48,26 +49,26 @@ describe('Test AP refresher', function () { | |||
48 | } | 49 | } |
49 | 50 | ||
50 | { | 51 | { |
51 | const a1 = await generateUserAccessToken(servers[1], 'user1') | 52 | const a1 = await generateUserAccessToken(servers[ 1 ], 'user1') |
52 | await uploadVideo(servers[1].url, a1, { name: 'video4' }) | 53 | await uploadVideo(servers[ 1 ].url, a1, { name: 'video4' }) |
53 | 54 | ||
54 | const a2 = await generateUserAccessToken(servers[1], 'user2') | 55 | const a2 = await generateUserAccessToken(servers[ 1 ], 'user2') |
55 | await uploadVideo(servers[1].url, a2, { name: 'video5' }) | 56 | await uploadVideo(servers[ 1 ].url, a2, { name: 'video5' }) |
56 | } | 57 | } |
57 | 58 | ||
58 | { | 59 | { |
59 | const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } | 60 | const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id } |
60 | const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) | 61 | const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs }) |
61 | playlistUUID1 = res.body.videoPlaylist.uuid | 62 | playlistUUID1 = res.body.videoPlaylist.uuid |
62 | } | 63 | } |
63 | 64 | ||
64 | { | 65 | { |
65 | const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } | 66 | const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id } |
66 | const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) | 67 | const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs }) |
67 | playlistUUID2 = res.body.videoPlaylist.uuid | 68 | playlistUUID2 = res.body.videoPlaylist.uuid |
68 | } | 69 | } |
69 | 70 | ||
70 | await doubleFollow(servers[0], servers[1]) | 71 | await doubleFollow(servers[ 0 ], servers[ 1 ]) |
71 | }) | 72 | }) |
72 | 73 | ||
73 | describe('Videos refresher', function () { | 74 | describe('Videos refresher', function () { |
@@ -78,7 +79,7 @@ describe('Test AP refresher', function () { | |||
78 | await wait(10000) | 79 | await wait(10000) |
79 | 80 | ||
80 | // Change UUID so the remote server returns a 404 | 81 | // Change UUID so the remote server returns a 404 |
81 | await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') | 82 | await setVideoField(servers[ 1 ].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') |
82 | 83 | ||
83 | await getVideo(servers[ 0 ].url, videoUUID1) | 84 | await getVideo(servers[ 0 ].url, videoUUID1) |
84 | await getVideo(servers[ 0 ].url, videoUUID2) | 85 | await getVideo(servers[ 0 ].url, videoUUID2) |
@@ -94,7 +95,7 @@ describe('Test AP refresher', function () { | |||
94 | 95 | ||
95 | killallServers([ servers[ 1 ] ]) | 96 | killallServers([ servers[ 1 ] ]) |
96 | 97 | ||
97 | await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') | 98 | await setVideoField(servers[ 1 ].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') |
98 | 99 | ||
99 | // Video will need a refresh | 100 | // Video will need a refresh |
100 | await wait(10000) | 101 | await wait(10000) |
@@ -121,15 +122,16 @@ describe('Test AP refresher', function () { | |||
121 | await wait(10000) | 122 | await wait(10000) |
122 | 123 | ||
123 | // Change actor name so the remote server returns a 404 | 124 | // Change actor name so the remote server returns a 404 |
124 | await setActorField(2, 'http://localhost:9002/accounts/user2', 'preferredUsername', 'toto') | 125 | const to = 'http://localhost:' + servers[ 1 ].port + '/accounts/user2' |
126 | await setActorField(servers[ 1 ].internalServerNumber, to, 'preferredUsername', 'toto') | ||
125 | 127 | ||
126 | await getAccount(servers[ 0 ].url, 'user1@localhost:9002') | 128 | await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port) |
127 | await getAccount(servers[ 0 ].url, 'user2@localhost:9002') | 129 | await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port) |
128 | 130 | ||
129 | await waitJobs(servers) | 131 | await waitJobs(servers) |
130 | 132 | ||
131 | await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200) | 133 | await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port, 200) |
132 | await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404) | 134 | await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port, 404) |
133 | }) | 135 | }) |
134 | }) | 136 | }) |
135 | 137 | ||
@@ -141,7 +143,7 @@ describe('Test AP refresher', function () { | |||
141 | await wait(10000) | 143 | await wait(10000) |
142 | 144 | ||
143 | // Change UUID so the remote server returns a 404 | 145 | // Change UUID so the remote server returns a 404 |
144 | await setPlaylistField(2, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') | 146 | await setPlaylistField(servers[ 1 ].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') |
145 | 147 | ||
146 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID1) | 148 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID1) |
147 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID2) | 149 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID2) |
@@ -153,7 +155,11 @@ describe('Test AP refresher', function () { | |||
153 | }) | 155 | }) |
154 | }) | 156 | }) |
155 | 157 | ||
156 | after(function () { | 158 | after(async function () { |
157 | killallServers(servers) | 159 | this.timeout(10000) |
160 | |||
161 | await cleanupTests(servers) | ||
162 | |||
163 | await closeAllSequelize(servers) | ||
158 | }) | 164 | }) |
159 | }) | 165 | }) |
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index 11e6859bf..dc960c5c3 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts | |||
@@ -3,9 +3,9 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | ||
5 | import { | 5 | import { |
6 | cleanupTests, | ||
6 | closeAllSequelize, | 7 | closeAllSequelize, |
7 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
8 | flushTests, | ||
9 | killallServers, | 9 | killallServers, |
10 | ServerInfo, | 10 | ServerInfo, |
11 | setActorField | 11 | setActorField |
@@ -18,18 +18,26 @@ import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-u | |||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
21 | function setKeysOfServer2 (serverNumber: number, publicKey: string, privateKey: string) { | 21 | function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: string, privateKey: string) { |
22 | return Promise.all([ | 22 | return Promise.all([ |
23 | setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'publicKey', publicKey), | 23 | setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'publicKey', publicKey), |
24 | setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'privateKey', privateKey) | 24 | setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'privateKey', privateKey) |
25 | ]) | 25 | ]) |
26 | } | 26 | } |
27 | 27 | ||
28 | function setKeysOfServer3 (serverNumber: number, publicKey: string, privateKey: string) { | 28 | function getAnnounceWithoutContext (server2: ServerInfo) { |
29 | return Promise.all([ | 29 | const json = require('./json/peertube/announce-without-context.json') |
30 | setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'publicKey', publicKey), | 30 | const result: typeof json = {} |
31 | setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'privateKey', privateKey) | 31 | |
32 | ]) | 32 | for (const key of Object.keys(json)) { |
33 | if (Array.isArray(json[key])) { | ||
34 | result[key] = json[key].map(v => v.replace(':9002', `:${server2.port}`)) | ||
35 | } else { | ||
36 | result[ key ] = json[ key ].replace(':9002', `:${server2.port}`) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | return result | ||
33 | } | 41 | } |
34 | 42 | ||
35 | describe('Test ActivityPub security', function () { | 43 | describe('Test ActivityPub security', function () { |
@@ -38,13 +46,13 @@ describe('Test ActivityPub security', function () { | |||
38 | 46 | ||
39 | const keys = require('./json/peertube/keys.json') | 47 | const keys = require('./json/peertube/keys.json') |
40 | const invalidKeys = require('./json/peertube/invalid-keys.json') | 48 | const invalidKeys = require('./json/peertube/invalid-keys.json') |
41 | const baseHttpSignature = { | 49 | const baseHttpSignature = () => ({ |
42 | algorithm: HTTP_SIGNATURE.ALGORITHM, | 50 | algorithm: HTTP_SIGNATURE.ALGORITHM, |
43 | authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, | 51 | authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, |
44 | keyId: 'acct:peertube@localhost:9002', | 52 | keyId: 'acct:peertube@localhost:' + servers[1].port, |
45 | key: keys.privateKey, | 53 | key: keys.privateKey, |
46 | headers: HTTP_SIGNATURE.HEADERS_TO_SIGN | 54 | headers: HTTP_SIGNATURE.HEADERS_TO_SIGN |
47 | } | 55 | }) |
48 | 56 | ||
49 | // --------------------------------------------------------------- | 57 | // --------------------------------------------------------------- |
50 | 58 | ||
@@ -55,56 +63,56 @@ describe('Test ActivityPub security', function () { | |||
55 | 63 | ||
56 | url = servers[0].url + '/inbox' | 64 | url = servers[0].url + '/inbox' |
57 | 65 | ||
58 | await setKeysOfServer2(1, keys.publicKey, keys.privateKey) | 66 | await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey) |
59 | 67 | ||
60 | const to = { url: 'http://localhost:9001/accounts/peertube' } | 68 | const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' } |
61 | const by = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } | 69 | const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey } |
62 | await makeFollowRequest(to, by) | 70 | await makeFollowRequest(to, by) |
63 | }) | 71 | }) |
64 | 72 | ||
65 | describe('When checking HTTP signature', function () { | 73 | describe('When checking HTTP signature', function () { |
66 | 74 | ||
67 | it('Should fail with an invalid digest', async function () { | 75 | it('Should fail with an invalid digest', async function () { |
68 | const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) | 76 | const body = activityPubContextify(getAnnounceWithoutContext(servers[1])) |
69 | const headers = { | 77 | const headers = { |
70 | Digest: buildDigest({ hello: 'coucou' }) | 78 | Digest: buildDigest({ hello: 'coucou' }) |
71 | } | 79 | } |
72 | 80 | ||
73 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) | 81 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers) |
74 | 82 | ||
75 | expect(response.statusCode).to.equal(403) | 83 | expect(response.statusCode).to.equal(403) |
76 | }) | 84 | }) |
77 | 85 | ||
78 | it('Should fail with an invalid date', async function () { | 86 | it('Should fail with an invalid date', async function () { |
79 | const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) | 87 | const body = activityPubContextify(getAnnounceWithoutContext(servers[1])) |
80 | const headers = buildGlobalHeaders(body) | 88 | const headers = buildGlobalHeaders(body) |
81 | headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT' | 89 | headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT' |
82 | 90 | ||
83 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) | 91 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers) |
84 | 92 | ||
85 | expect(response.statusCode).to.equal(403) | 93 | expect(response.statusCode).to.equal(403) |
86 | }) | 94 | }) |
87 | 95 | ||
88 | it('Should fail with bad keys', async function () { | 96 | it('Should fail with bad keys', async function () { |
89 | await setKeysOfServer2(1, invalidKeys.publicKey, invalidKeys.privateKey) | 97 | await setKeysOfServer(servers[0], servers[1], invalidKeys.publicKey, invalidKeys.privateKey) |
90 | await setKeysOfServer2(2, invalidKeys.publicKey, invalidKeys.privateKey) | 98 | await setKeysOfServer(servers[1], servers[1], invalidKeys.publicKey, invalidKeys.privateKey) |
91 | 99 | ||
92 | const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) | 100 | const body = activityPubContextify(getAnnounceWithoutContext(servers[1])) |
93 | const headers = buildGlobalHeaders(body) | 101 | const headers = buildGlobalHeaders(body) |
94 | 102 | ||
95 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) | 103 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers) |
96 | 104 | ||
97 | expect(response.statusCode).to.equal(403) | 105 | expect(response.statusCode).to.equal(403) |
98 | }) | 106 | }) |
99 | 107 | ||
100 | it('Should succeed with a valid HTTP signature', async function () { | 108 | it('Should succeed with a valid HTTP signature', async function () { |
101 | await setKeysOfServer2(1, keys.publicKey, keys.privateKey) | 109 | await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey) |
102 | await setKeysOfServer2(2, keys.publicKey, keys.privateKey) | 110 | await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey) |
103 | 111 | ||
104 | const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) | 112 | const body = activityPubContextify(getAnnounceWithoutContext(servers[1])) |
105 | const headers = buildGlobalHeaders(body) | 113 | const headers = buildGlobalHeaders(body) |
106 | 114 | ||
107 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) | 115 | const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers) |
108 | 116 | ||
109 | expect(response.statusCode).to.equal(204) | 117 | expect(response.statusCode).to.equal(204) |
110 | }) | 118 | }) |
@@ -112,28 +120,28 @@ describe('Test ActivityPub security', function () { | |||
112 | 120 | ||
113 | describe('When checking Linked Data Signature', function () { | 121 | describe('When checking Linked Data Signature', function () { |
114 | before(async () => { | 122 | before(async () => { |
115 | await setKeysOfServer3(3, keys.publicKey, keys.privateKey) | 123 | await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey) |
116 | 124 | ||
117 | const to = { url: 'http://localhost:9001/accounts/peertube' } | 125 | const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' } |
118 | const by = { url: 'http://localhost:9003/accounts/peertube', privateKey: keys.privateKey } | 126 | const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey } |
119 | await makeFollowRequest(to, by) | 127 | await makeFollowRequest(to, by) |
120 | }) | 128 | }) |
121 | 129 | ||
122 | it('Should fail with bad keys', async function () { | 130 | it('Should fail with bad keys', async function () { |
123 | this.timeout(10000) | 131 | this.timeout(10000) |
124 | 132 | ||
125 | await setKeysOfServer3(1, invalidKeys.publicKey, invalidKeys.privateKey) | 133 | await setKeysOfServer(servers[0], servers[2], invalidKeys.publicKey, invalidKeys.privateKey) |
126 | await setKeysOfServer3(3, invalidKeys.publicKey, invalidKeys.privateKey) | 134 | await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey) |
127 | 135 | ||
128 | const body = require('./json/peertube/announce-without-context.json') | 136 | const body = getAnnounceWithoutContext(servers[1]) |
129 | body.actor = 'http://localhost:9003/accounts/peertube' | 137 | body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' |
130 | 138 | ||
131 | const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:9003/accounts/peertube' } | 139 | const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } |
132 | const signedBody = await buildSignedActivity(signer, body) | 140 | const signedBody = await buildSignedActivity(signer, body) |
133 | 141 | ||
134 | const headers = buildGlobalHeaders(signedBody) | 142 | const headers = buildGlobalHeaders(signedBody) |
135 | 143 | ||
136 | const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers) | 144 | const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) |
137 | 145 | ||
138 | expect(response.statusCode).to.equal(403) | 146 | expect(response.statusCode).to.equal(403) |
139 | }) | 147 | }) |
@@ -141,20 +149,20 @@ describe('Test ActivityPub security', function () { | |||
141 | it('Should fail with an altered body', async function () { | 149 | it('Should fail with an altered body', async function () { |
142 | this.timeout(10000) | 150 | this.timeout(10000) |
143 | 151 | ||
144 | await setKeysOfServer3(1, keys.publicKey, keys.privateKey) | 152 | await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey) |
145 | await setKeysOfServer3(3, keys.publicKey, keys.privateKey) | 153 | await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey) |
146 | 154 | ||
147 | const body = require('./json/peertube/announce-without-context.json') | 155 | const body = getAnnounceWithoutContext(servers[1]) |
148 | body.actor = 'http://localhost:9003/accounts/peertube' | 156 | body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' |
149 | 157 | ||
150 | const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' } | 158 | const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } |
151 | const signedBody = await buildSignedActivity(signer, body) | 159 | const signedBody = await buildSignedActivity(signer, body) |
152 | 160 | ||
153 | signedBody.actor = 'http://localhost:9003/account/peertube' | 161 | signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube' |
154 | 162 | ||
155 | const headers = buildGlobalHeaders(signedBody) | 163 | const headers = buildGlobalHeaders(signedBody) |
156 | 164 | ||
157 | const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers) | 165 | const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) |
158 | 166 | ||
159 | expect(response.statusCode).to.equal(403) | 167 | expect(response.statusCode).to.equal(403) |
160 | }) | 168 | }) |
@@ -162,22 +170,24 @@ describe('Test ActivityPub security', function () { | |||
162 | it('Should succeed with a valid signature', async function () { | 170 | it('Should succeed with a valid signature', async function () { |
163 | this.timeout(10000) | 171 | this.timeout(10000) |
164 | 172 | ||
165 | const body = require('./json/peertube/announce-without-context.json') | 173 | const body = getAnnounceWithoutContext(servers[1]) |
166 | body.actor = 'http://localhost:9003/accounts/peertube' | 174 | body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' |
167 | 175 | ||
168 | const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' } | 176 | const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } |
169 | const signedBody = await buildSignedActivity(signer, body) | 177 | const signedBody = await buildSignedActivity(signer, body) |
170 | 178 | ||
171 | const headers = buildGlobalHeaders(signedBody) | 179 | const headers = buildGlobalHeaders(signedBody) |
172 | 180 | ||
173 | const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers) | 181 | const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers) |
174 | 182 | ||
175 | expect(response.statusCode).to.equal(204) | 183 | expect(response.statusCode).to.equal(204) |
176 | }) | 184 | }) |
177 | }) | 185 | }) |
178 | 186 | ||
179 | after(async function () { | 187 | after(async function () { |
180 | killallServers(servers) | 188 | this.timeout(10000) |
189 | |||
190 | await cleanupTests(servers) | ||
181 | 191 | ||
182 | await closeAllSequelize(servers) | 192 | await closeAllSequelize(servers) |
183 | }) | 193 | }) |
diff --git a/server/tests/api/index-2.ts b/server/tests/api/index-2.ts deleted file mode 100644 index ed93faa91..000000000 --- a/server/tests/api/index-2.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | import './server' | ||
2 | import './users' | ||
diff --git a/server/tests/api/index-3.ts b/server/tests/api/index-3.ts deleted file mode 100644 index 39823b82c..000000000 --- a/server/tests/api/index-3.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | import './videos' | ||
diff --git a/server/tests/api/index-4.ts b/server/tests/api/index-4.ts deleted file mode 100644 index 7d8be2b3d..000000000 --- a/server/tests/api/index-4.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | import './redundancy' | ||
2 | import './activitypub' | ||
diff --git a/server/tests/api/index.ts b/server/tests/api/index.ts index bc140f860..bac77ab2e 100644 --- a/server/tests/api/index.ts +++ b/server/tests/api/index.ts | |||
@@ -1,5 +1,9 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './index-1' | 2 | import './activitypub' |
3 | import './index-2' | 3 | import './check-params' |
4 | import './index-3' | 4 | import './notifications' |
5 | import './index-4' | 5 | import './redundancy' |
6 | import './search' | ||
7 | import './server' | ||
8 | import './users' | ||
9 | import './videos' | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index c0d11914b..ca389b7b6 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -11,9 +11,9 @@ import { | |||
11 | getAbout, | 11 | getAbout, |
12 | getConfig, | 12 | getConfig, |
13 | getCustomConfig, | 13 | getCustomConfig, |
14 | killallServers, | 14 | killallServers, parallelTests, |
15 | registerUser, | 15 | registerUser, |
16 | reRunServer, | 16 | reRunServer, ServerInfo, |
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | updateCustomConfig | 18 | updateCustomConfig |
19 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
@@ -21,7 +21,7 @@ import { ServerConfig } from '../../../../shared/models' | |||
21 | 21 | ||
22 | const expect = chai.expect | 22 | const expect = chai.expect |
23 | 23 | ||
24 | function checkInitialConfig (data: CustomConfig) { | 24 | function checkInitialConfig (server: ServerInfo, data: CustomConfig) { |
25 | expect(data.instance.name).to.equal('PeerTube') | 25 | expect(data.instance.name).to.equal('PeerTube') |
26 | expect(data.instance.shortDescription).to.equal( | 26 | expect(data.instance.shortDescription).to.equal( |
27 | 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' + | 27 | 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' + |
@@ -45,7 +45,7 @@ function checkInitialConfig (data: CustomConfig) { | |||
45 | expect(data.signup.limit).to.equal(4) | 45 | expect(data.signup.limit).to.equal(4) |
46 | expect(data.signup.requiresEmailVerification).to.be.false | 46 | expect(data.signup.requiresEmailVerification).to.be.false |
47 | 47 | ||
48 | expect(data.admin.email).to.equal('admin1@example.com') | 48 | expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com') |
49 | expect(data.contactForm.enabled).to.be.true | 49 | expect(data.contactForm.enabled).to.be.true |
50 | 50 | ||
51 | expect(data.user.videoQuota).to.equal(5242880) | 51 | expect(data.user.videoQuota).to.equal(5242880) |
@@ -89,7 +89,11 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
89 | expect(data.signup.limit).to.equal(5) | 89 | expect(data.signup.limit).to.equal(5) |
90 | expect(data.signup.requiresEmailVerification).to.be.false | 90 | expect(data.signup.requiresEmailVerification).to.be.false |
91 | 91 | ||
92 | expect(data.admin.email).to.equal('superadmin1@example.com') | 92 | // We override admin email in parallel tests, so skip this exception |
93 | if (parallelTests() === false) { | ||
94 | expect(data.admin.email).to.equal('superadmin1@example.com') | ||
95 | } | ||
96 | |||
93 | expect(data.contactForm.enabled).to.be.false | 97 | expect(data.contactForm.enabled).to.be.false |
94 | 98 | ||
95 | expect(data.user.videoQuota).to.equal(5242881) | 99 | expect(data.user.videoQuota).to.equal(5242881) |
@@ -118,6 +122,7 @@ describe('Test config', function () { | |||
118 | 122 | ||
119 | before(async function () { | 123 | before(async function () { |
120 | this.timeout(30000) | 124 | this.timeout(30000) |
125 | |||
121 | server = await flushAndRunServer(1) | 126 | server = await flushAndRunServer(1) |
122 | await setAccessTokensToServers([ server ]) | 127 | await setAccessTokensToServers([ server ]) |
123 | }) | 128 | }) |
@@ -160,7 +165,7 @@ describe('Test config', function () { | |||
160 | const res = await getCustomConfig(server.url, server.accessToken) | 165 | const res = await getCustomConfig(server.url, server.accessToken) |
161 | const data = res.body as CustomConfig | 166 | const data = res.body as CustomConfig |
162 | 167 | ||
163 | checkInitialConfig(data) | 168 | checkInitialConfig(server, data) |
164 | }) | 169 | }) |
165 | 170 | ||
166 | it('Should update the customized configuration', async function () { | 171 | it('Should update the customized configuration', async function () { |
@@ -297,7 +302,7 @@ describe('Test config', function () { | |||
297 | const res = await getCustomConfig(server.url, server.accessToken) | 302 | const res = await getCustomConfig(server.url, server.accessToken) |
298 | const data = res.body | 303 | const data = res.body |
299 | 304 | ||
300 | checkInitialConfig(data) | 305 | checkInitialConfig(server, data) |
301 | }) | 306 | }) |
302 | 307 | ||
303 | after(async function () { | 308 | after(async function () { |
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index 0a1c49ef5..87e55060c 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts | |||
@@ -54,7 +54,7 @@ describe('Test contact form', function () { | |||
54 | 54 | ||
55 | expect(email['from'][0]['address']).equal('test-admin@localhost') | 55 | expect(email['from'][0]['address']).equal('test-admin@localhost') |
56 | expect(email['from'][0]['name']).equal('toto@example.com') | 56 | expect(email['from'][0]['name']).equal('toto@example.com') |
57 | expect(email['to'][0]['address']).equal('admin1@example.com') | 57 | expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com') |
58 | expect(email['subject']).contains('Contact form') | 58 | expect(email['subject']).contains('Contact form') |
59 | expect(email['text']).contains('my super message') | 59 | expect(email['text']).contains('my super message') |
60 | }) | 60 | }) |
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 9ccb1c36f..5929a3adb 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -37,15 +37,17 @@ describe('Test emails', function () { | |||
37 | username: 'user_1', | 37 | username: 'user_1', |
38 | password: 'super_password' | 38 | password: 'super_password' |
39 | } | 39 | } |
40 | let emailPort: number | ||
40 | 41 | ||
41 | before(async function () { | 42 | before(async function () { |
42 | this.timeout(30000) | 43 | this.timeout(30000) |
43 | 44 | ||
44 | await MockSmtpServer.Instance.collectEmails(emails) | 45 | emailPort = await MockSmtpServer.Instance.collectEmails(emails) |
45 | 46 | ||
46 | const overrideConfig = { | 47 | const overrideConfig = { |
47 | smtp: { | 48 | smtp: { |
48 | hostname: 'localhost' | 49 | hostname: 'localhost', |
50 | port: emailPort | ||
49 | } | 51 | } |
50 | } | 52 | } |
51 | server = await flushAndRunServer(1, overrideConfig) | 53 | server = await flushAndRunServer(1, overrideConfig) |
@@ -134,7 +136,7 @@ describe('Test emails', function () { | |||
134 | 136 | ||
135 | expect(email['from'][0]['name']).equal('localhost:' + server.port) | 137 | expect(email['from'][0]['name']).equal('localhost:' + server.port) |
136 | expect(email['from'][0]['address']).equal('test-admin@localhost') | 138 | expect(email['from'][0]['address']).equal('test-admin@localhost') |
137 | expect(email['to'][0]['address']).equal('admin1@example.com') | 139 | expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com') |
138 | expect(email['subject']).contains('abuse') | 140 | expect(email['subject']).contains('abuse') |
139 | expect(email['text']).contains(videoUUID) | 141 | expect(email['text']).contains(videoUUID) |
140 | }) | 142 | }) |
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts index fc20f8961..a82acdb34 100644 --- a/server/tests/api/server/follows-moderation.ts +++ b/server/tests/api/server/follows-moderation.ts | |||
@@ -29,7 +29,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc | |||
29 | 29 | ||
30 | const follow = res.body.data[0] as ActorFollow | 30 | const follow = res.body.data[0] as ActorFollow |
31 | expect(follow.state).to.equal(state) | 31 | expect(follow.state).to.equal(state) |
32 | expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube') | 32 | expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube') |
33 | expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube') | 33 | expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube') |
34 | } | 34 | } |
35 | 35 | ||
@@ -39,7 +39,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc | |||
39 | 39 | ||
40 | const follow = res.body.data[0] as ActorFollow | 40 | const follow = res.body.data[0] as ActorFollow |
41 | expect(follow.state).to.equal(state) | 41 | expect(follow.state).to.equal(state) |
42 | expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube') | 42 | expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube') |
43 | expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube') | 43 | expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube') |
44 | } | 44 | } |
45 | } | 45 | } |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index d4155667f..e8d6f5138 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -141,7 +141,7 @@ describe('Test follows', function () { | |||
141 | 141 | ||
142 | it('Should search followers on server 2', async function () { | 142 | it('Should search followers on server 2', async function () { |
143 | { | 143 | { |
144 | const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', '9001') | 144 | const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', servers[0].port + '') |
145 | const follows = res.body.data | 145 | const follows = res.body.data |
146 | 146 | ||
147 | expect(res.body.total).to.equal(1) | 147 | expect(res.body.total).to.equal(1) |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 9a8bc08f9..068654d8c 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -60,48 +60,50 @@ describe('Test handle downs', function () { | |||
60 | privacy: VideoPrivacy.UNLISTED | 60 | privacy: VideoPrivacy.UNLISTED |
61 | }) | 61 | }) |
62 | 62 | ||
63 | const checkAttributes = { | 63 | let checkAttributes: any |
64 | name: 'my super name for server 1', | 64 | let unlistedCheckAttributes: any |
65 | category: 5, | ||
66 | licence: 4, | ||
67 | language: 'ja', | ||
68 | nsfw: true, | ||
69 | description: 'my super description for server 1', | ||
70 | support: 'my super support text for server 1', | ||
71 | account: { | ||
72 | name: 'root', | ||
73 | host: 'localhost:' + servers[0].port | ||
74 | }, | ||
75 | isLocal: false, | ||
76 | duration: 10, | ||
77 | tags: [ 'tag1p1', 'tag2p1' ], | ||
78 | privacy: VideoPrivacy.PUBLIC, | ||
79 | commentsEnabled: true, | ||
80 | downloadEnabled: true, | ||
81 | channel: { | ||
82 | name: 'root_channel', | ||
83 | displayName: 'Main root channel', | ||
84 | description: '', | ||
85 | isLocal: false | ||
86 | }, | ||
87 | fixture: 'video_short1.webm', | ||
88 | files: [ | ||
89 | { | ||
90 | resolution: 720, | ||
91 | size: 572456 | ||
92 | } | ||
93 | ] | ||
94 | } | ||
95 | |||
96 | const unlistedCheckAttributes = immutableAssign(checkAttributes, { | ||
97 | privacy: VideoPrivacy.UNLISTED | ||
98 | }) | ||
99 | 65 | ||
100 | before(async function () { | 66 | before(async function () { |
101 | this.timeout(30000) | 67 | this.timeout(30000) |
102 | 68 | ||
103 | servers = await flushAndRunMultipleServers(3) | 69 | servers = await flushAndRunMultipleServers(3) |
104 | 70 | ||
71 | checkAttributes = { | ||
72 | name: 'my super name for server 1', | ||
73 | category: 5, | ||
74 | licence: 4, | ||
75 | language: 'ja', | ||
76 | nsfw: true, | ||
77 | description: 'my super description for server 1', | ||
78 | support: 'my super support text for server 1', | ||
79 | account: { | ||
80 | name: 'root', | ||
81 | host: 'localhost:' + servers[0].port | ||
82 | }, | ||
83 | isLocal: false, | ||
84 | duration: 10, | ||
85 | tags: [ 'tag1p1', 'tag2p1' ], | ||
86 | privacy: VideoPrivacy.PUBLIC, | ||
87 | commentsEnabled: true, | ||
88 | downloadEnabled: true, | ||
89 | channel: { | ||
90 | name: 'root_channel', | ||
91 | displayName: 'Main root channel', | ||
92 | description: '', | ||
93 | isLocal: false | ||
94 | }, | ||
95 | fixture: 'video_short1.webm', | ||
96 | files: [ | ||
97 | { | ||
98 | resolution: 720, | ||
99 | size: 572456 | ||
100 | } | ||
101 | ] | ||
102 | } | ||
103 | unlistedCheckAttributes = immutableAssign(checkAttributes, { | ||
104 | privacy: VideoPrivacy.UNLISTED | ||
105 | }) | ||
106 | |||
105 | // Get the access tokens | 107 | // Get the access tokens |
106 | await setAccessTokensToServers(servers) | 108 | await setAccessTokensToServers(servers) |
107 | }) | 109 | }) |
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts index 3644fa0d3..68f442199 100644 --- a/server/tests/api/server/logs.ts +++ b/server/tests/api/server/logs.ts | |||
@@ -45,7 +45,7 @@ describe('Test logs', function () { | |||
45 | }) | 45 | }) |
46 | 46 | ||
47 | it('Should get logs with an end date', async function () { | 47 | it('Should get logs with an end date', async function () { |
48 | this.timeout(10000) | 48 | this.timeout(20000) |
49 | 49 | ||
50 | await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) | 50 | await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) |
51 | await waitJobs([ server ]) | 51 | await waitJobs([ server ]) |
diff --git a/server/tests/api/travis-1.sh b/server/tests/api/travis-1.sh index 0673bb2bf..f7332795c 100644 --- a/server/tests/api/travis-1.sh +++ b/server/tests/api/travis-1.sh | |||
@@ -2,9 +2,9 @@ | |||
2 | 2 | ||
3 | set -eu | 3 | set -eu |
4 | 4 | ||
5 | checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo) | ||
5 | notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo) | 6 | notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo) |
6 | searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo) | 7 | searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo) |
7 | checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo) | ||
8 | 8 | ||
9 | MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 4 --timeout 5000 --exit --require ts-node/register --bail \ | 9 | MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \ |
10 | $notificationsFiles $searchFiles $checkParamFiles | 10 | $notificationsFiles $searchFiles $checkParamFiles |
diff --git a/server/tests/api/travis-2.sh b/server/tests/api/travis-2.sh new file mode 100644 index 000000000..abeb48144 --- /dev/null +++ b/server/tests/api/travis-2.sh | |||
@@ -0,0 +1,9 @@ | |||
1 | #!/usr/bin/env sh | ||
2 | |||
3 | set -eu | ||
4 | |||
5 | serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo) | ||
6 | usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo) | ||
7 | |||
8 | MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \ | ||
9 | $serverFiles $usersFiles | ||
diff --git a/server/tests/api/travis-3.sh b/server/tests/api/travis-3.sh new file mode 100644 index 000000000..81e6c2e4b --- /dev/null +++ b/server/tests/api/travis-3.sh | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/usr/bin/env sh | ||
2 | |||
3 | set -eu | ||
4 | |||
5 | videosFiles=$(find server/tests/api/videos -type f | grep -v index.ts | xargs echo) | ||
6 | |||
7 | MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \ | ||
8 | $videosFiles | ||
diff --git a/server/tests/api/travis-4.sh b/server/tests/api/travis-4.sh new file mode 100644 index 000000000..24bf5b71c --- /dev/null +++ b/server/tests/api/travis-4.sh | |||
@@ -0,0 +1,9 @@ | |||
1 | #!/usr/bin/env sh | ||
2 | |||
3 | set -eu | ||
4 | |||
5 | redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo) | ||
6 | activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo) | ||
7 | |||
8 | MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \ | ||
9 | $redundancyFiles $activitypubFiles | ||
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 48811e647..c8a89d6be 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -71,8 +71,8 @@ describe('Test users subscriptions', function () { | |||
71 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { | 71 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { |
72 | this.timeout(60000) | 72 | this.timeout(60000) |
73 | 73 | ||
74 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') | 74 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) |
75 | await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') | 75 | await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) |
76 | 76 | ||
77 | await waitJobs(servers) | 77 | await waitJobs(servers) |
78 | 78 | ||
@@ -116,22 +116,22 @@ describe('Test users subscriptions', function () { | |||
116 | 116 | ||
117 | it('Should get subscription', async function () { | 117 | it('Should get subscription', async function () { |
118 | { | 118 | { |
119 | const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:9003') | 119 | const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:' + servers[2].port) |
120 | const videoChannel: VideoChannel = res.body | 120 | const videoChannel: VideoChannel = res.body |
121 | 121 | ||
122 | expect(videoChannel.name).to.equal('user3_channel') | 122 | expect(videoChannel.name).to.equal('user3_channel') |
123 | expect(videoChannel.host).to.equal('localhost:9003') | 123 | expect(videoChannel.host).to.equal('localhost:' + servers[2].port) |
124 | expect(videoChannel.displayName).to.equal('Main user3 channel') | 124 | expect(videoChannel.displayName).to.equal('Main user3 channel') |
125 | expect(videoChannel.followingCount).to.equal(0) | 125 | expect(videoChannel.followingCount).to.equal(0) |
126 | expect(videoChannel.followersCount).to.equal(1) | 126 | expect(videoChannel.followersCount).to.equal(1) |
127 | } | 127 | } |
128 | 128 | ||
129 | { | 129 | { |
130 | const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:9001') | 130 | const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:' + servers[0].port) |
131 | const videoChannel: VideoChannel = res.body | 131 | const videoChannel: VideoChannel = res.body |
132 | 132 | ||
133 | expect(videoChannel.name).to.equal('root_channel') | 133 | expect(videoChannel.name).to.equal('root_channel') |
134 | expect(videoChannel.host).to.equal('localhost:9001') | 134 | expect(videoChannel.host).to.equal('localhost:' + servers[0].port) |
135 | expect(videoChannel.displayName).to.equal('Main root channel') | 135 | expect(videoChannel.displayName).to.equal('Main root channel') |
136 | expect(videoChannel.followingCount).to.equal(0) | 136 | expect(videoChannel.followingCount).to.equal(0) |
137 | expect(videoChannel.followersCount).to.equal(1) | 137 | expect(videoChannel.followersCount).to.equal(1) |
@@ -140,19 +140,19 @@ describe('Test users subscriptions', function () { | |||
140 | 140 | ||
141 | it('Should return the existing subscriptions', async function () { | 141 | it('Should return the existing subscriptions', async function () { |
142 | const uris = [ | 142 | const uris = [ |
143 | 'user3_channel@localhost:9003', | 143 | 'user3_channel@localhost:' + servers[2].port, |
144 | 'root2_channel@localhost:9001', | 144 | 'root2_channel@localhost:' + servers[0].port, |
145 | 'root_channel@localhost:9001', | 145 | 'root_channel@localhost:' + servers[0].port, |
146 | 'user3_channel@localhost:9001' | 146 | 'user3_channel@localhost:' + servers[0].port |
147 | ] | 147 | ] |
148 | 148 | ||
149 | const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris) | 149 | const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris) |
150 | const body = res.body | 150 | const body = res.body |
151 | 151 | ||
152 | expect(body['user3_channel@localhost:9003']).to.be.true | 152 | expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true |
153 | expect(body['root2_channel@localhost:9001']).to.be.false | 153 | expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false |
154 | expect(body['root_channel@localhost:9001']).to.be.true | 154 | expect(body['root_channel@localhost:' + servers[0].port]).to.be.true |
155 | expect(body['user3_channel@localhost:9001']).to.be.false | 155 | expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false |
156 | }) | 156 | }) |
157 | 157 | ||
158 | it('Should list subscription videos', async function () { | 158 | it('Should list subscription videos', async function () { |
@@ -291,7 +291,7 @@ describe('Test users subscriptions', function () { | |||
291 | it('Should remove user of server 3 subscription', async function () { | 291 | it('Should remove user of server 3 subscription', async function () { |
292 | this.timeout(30000) | 292 | this.timeout(30000) |
293 | 293 | ||
294 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') | 294 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) |
295 | 295 | ||
296 | await waitJobs(servers) | 296 | await waitJobs(servers) |
297 | }) | 297 | }) |
@@ -312,7 +312,7 @@ describe('Test users subscriptions', function () { | |||
312 | it('Should remove the root subscription and not display the videos anymore', async function () { | 312 | it('Should remove the root subscription and not display the videos anymore', async function () { |
313 | this.timeout(30000) | 313 | this.timeout(30000) |
314 | 314 | ||
315 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') | 315 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) |
316 | 316 | ||
317 | await waitJobs(servers) | 317 | await waitJobs(servers) |
318 | 318 | ||
@@ -340,7 +340,7 @@ describe('Test users subscriptions', function () { | |||
340 | it('Should follow user of server 3 again', async function () { | 340 | it('Should follow user of server 3 again', async function () { |
341 | this.timeout(60000) | 341 | this.timeout(60000) |
342 | 342 | ||
343 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') | 343 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) |
344 | 344 | ||
345 | await waitJobs(servers) | 345 | await waitJobs(servers) |
346 | 346 | ||
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 9a971adb3..988fdad3f 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -151,13 +151,13 @@ describe('Test users with multiple servers', function () { | |||
151 | for (const server of servers) { | 151 | for (const server of servers) { |
152 | const resAccounts = await getAccountsList(server.url, '-createdAt') | 152 | const resAccounts = await getAccountsList(server.url, '-createdAt') |
153 | 153 | ||
154 | const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account | 154 | const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) as Account |
155 | expect(rootServer1List).not.to.be.undefined | 155 | expect(rootServer1List).not.to.be.undefined |
156 | 156 | ||
157 | const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host) | 157 | const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host) |
158 | const rootServer1Get = resAccount.body as Account | 158 | const rootServer1Get = resAccount.body as Account |
159 | expect(rootServer1Get.name).to.equal('root') | 159 | expect(rootServer1Get.name).to.equal('root') |
160 | expect(rootServer1Get.host).to.equal('localhost:9001') | 160 | expect(rootServer1Get.host).to.equal('localhost:' + servers[0].port) |
161 | expect(rootServer1Get.displayName).to.equal('my super display name') | 161 | expect(rootServer1Get.displayName).to.equal('my super display name') |
162 | expect(rootServer1Get.description).to.equal('my super description updated') | 162 | expect(rootServer1Get.description).to.equal('my super description updated') |
163 | 163 | ||
@@ -188,12 +188,12 @@ describe('Test users with multiple servers', function () { | |||
188 | for (const server of servers) { | 188 | for (const server of servers) { |
189 | const resAccounts = await getAccountsList(server.url, '-createdAt') | 189 | const resAccounts = await getAccountsList(server.url, '-createdAt') |
190 | 190 | ||
191 | const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account | 191 | const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account |
192 | expect(accountDeleted).not.to.be.undefined | 192 | expect(accountDeleted).not.to.be.undefined |
193 | 193 | ||
194 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) | 194 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) |
195 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { | 195 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { |
196 | return a.displayName === 'Main user1 channel' && a.host === 'localhost:9001' | 196 | return a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port |
197 | }) as VideoChannel | 197 | }) as VideoChannel |
198 | expect(videoChannelDeleted).not.to.be.undefined | 198 | expect(videoChannelDeleted).not.to.be.undefined |
199 | } | 199 | } |
@@ -205,12 +205,12 @@ describe('Test users with multiple servers', function () { | |||
205 | for (const server of servers) { | 205 | for (const server of servers) { |
206 | const resAccounts = await getAccountsList(server.url, '-createdAt') | 206 | const resAccounts = await getAccountsList(server.url, '-createdAt') |
207 | 207 | ||
208 | const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account | 208 | const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account |
209 | expect(accountDeleted).to.be.undefined | 209 | expect(accountDeleted).to.be.undefined |
210 | 210 | ||
211 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) | 211 | const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) |
212 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { | 212 | const videoChannelDeleted = resVideoChannels.body.data.find(a => { |
213 | return a.name === 'Main user1 channel' && a.host === 'localhost:9001' | 213 | return a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port |
214 | }) as VideoChannel | 214 | }) as VideoChannel |
215 | expect(videoChannelDeleted).to.be.undefined | 215 | expect(videoChannelDeleted).to.be.undefined |
216 | } | 216 | } |
@@ -218,14 +218,14 @@ describe('Test users with multiple servers', function () { | |||
218 | 218 | ||
219 | it('Should not have actor files', async () => { | 219 | it('Should not have actor files', async () => { |
220 | for (const server of servers) { | 220 | for (const server of servers) { |
221 | await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) | 221 | await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber) |
222 | await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) | 222 | await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber) |
223 | } | 223 | } |
224 | }) | 224 | }) |
225 | 225 | ||
226 | it('Should not have video files', async () => { | 226 | it('Should not have video files', async () => { |
227 | for (const server of servers) { | 227 | for (const server of servers) { |
228 | await checkVideoFilesWereRemoved(videoUUID, server.serverNumber) | 228 | await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber) |
229 | } | 229 | } |
230 | }) | 230 | }) |
231 | 231 | ||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index c8e32f3f5..c1a24b838 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -316,7 +316,7 @@ describe('Test users', function () { | |||
316 | 316 | ||
317 | const rootUser = users[ 1 ] | 317 | const rootUser = users[ 1 ] |
318 | expect(rootUser.username).to.equal('root') | 318 | expect(rootUser.username).to.equal('root') |
319 | expect(rootUser.email).to.equal('admin1@example.com') | 319 | expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com') |
320 | expect(user.nsfwPolicy).to.equal('display') | 320 | expect(user.nsfwPolicy).to.equal('display') |
321 | 321 | ||
322 | userId = user.id | 322 | userId = user.id |
@@ -334,7 +334,7 @@ describe('Test users', function () { | |||
334 | 334 | ||
335 | const user = users[ 0 ] | 335 | const user = users[ 0 ] |
336 | expect(user.username).to.equal('root') | 336 | expect(user.username).to.equal('root') |
337 | expect(user.email).to.equal('admin1@example.com') | 337 | expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com') |
338 | expect(user.roleLabel).to.equal('Administrator') | 338 | expect(user.roleLabel).to.equal('Administrator') |
339 | expect(user.nsfwPolicy).to.equal('display') | 339 | expect(user.nsfwPolicy).to.equal('display') |
340 | }) | 340 | }) |
@@ -379,7 +379,7 @@ describe('Test users', function () { | |||
379 | expect(users.length).to.equal(2) | 379 | expect(users.length).to.equal(2) |
380 | 380 | ||
381 | expect(users[ 0 ].username).to.equal('root') | 381 | expect(users[ 0 ].username).to.equal('root') |
382 | expect(users[ 0 ].email).to.equal('admin1@example.com') | 382 | expect(users[ 0 ].email).to.equal('admin' + server.internalServerNumber + '@example.com') |
383 | expect(users[ 0 ].nsfwPolicy).to.equal('display') | 383 | expect(users[ 0 ].nsfwPolicy).to.equal('display') |
384 | 384 | ||
385 | expect(users[ 1 ].username).to.equal('user_1') | 385 | expect(users[ 1 ].username).to.equal('user_1') |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 89904759a..09b461200 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -109,7 +109,7 @@ describe('Test multiple servers', function () { | |||
109 | // All servers should have this video | 109 | // All servers should have this video |
110 | let publishedAt: string = null | 110 | let publishedAt: string = null |
111 | for (const server of servers) { | 111 | for (const server of servers) { |
112 | const isLocal = server.url === 'http://localhost:' + servers[0].port | 112 | const isLocal = server.port === servers[0].port |
113 | const checkAttributes = { | 113 | const checkAttributes = { |
114 | name: 'my super name for server 1', | 114 | name: 'my super name for server 1', |
115 | category: 5, | 115 | category: 5, |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index b0412f4df..d8f394ac7 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -37,7 +37,7 @@ describe('Test a single server', function () { | |||
37 | let videoUUID = '' | 37 | let videoUUID = '' |
38 | let videosListBase: any[] = null | 38 | let videosListBase: any[] = null |
39 | 39 | ||
40 | const getCheckAttributes = { | 40 | const getCheckAttributes = () => ({ |
41 | name: 'my super name', | 41 | name: 'my super name', |
42 | category: 2, | 42 | category: 2, |
43 | licence: 6, | 43 | licence: 6, |
@@ -68,9 +68,9 @@ describe('Test a single server', function () { | |||
68 | size: 218910 | 68 | size: 218910 |
69 | } | 69 | } |
70 | ] | 70 | ] |
71 | } | 71 | }) |
72 | 72 | ||
73 | const updateCheckAttributes = { | 73 | const updateCheckAttributes = () => ({ |
74 | name: 'my super video updated', | 74 | name: 'my super video updated', |
75 | category: 4, | 75 | category: 4, |
76 | licence: 2, | 76 | licence: 2, |
@@ -101,7 +101,7 @@ describe('Test a single server', function () { | |||
101 | size: 292677 | 101 | size: 292677 |
102 | } | 102 | } |
103 | ] | 103 | ] |
104 | } | 104 | }) |
105 | 105 | ||
106 | before(async function () { | 106 | before(async function () { |
107 | this.timeout(30000) | 107 | this.timeout(30000) |
@@ -182,7 +182,7 @@ describe('Test a single server', function () { | |||
182 | expect(res.body.data.length).to.equal(1) | 182 | expect(res.body.data.length).to.equal(1) |
183 | 183 | ||
184 | const video = res.body.data[0] | 184 | const video = res.body.data[0] |
185 | await completeVideoCheck(server.url, video, getCheckAttributes) | 185 | await completeVideoCheck(server.url, video, getCheckAttributes()) |
186 | }) | 186 | }) |
187 | 187 | ||
188 | it('Should get the video by UUID', async function () { | 188 | it('Should get the video by UUID', async function () { |
@@ -191,7 +191,7 @@ describe('Test a single server', function () { | |||
191 | const res = await getVideo(server.url, videoUUID) | 191 | const res = await getVideo(server.url, videoUUID) |
192 | 192 | ||
193 | const video = res.body | 193 | const video = res.body |
194 | await completeVideoCheck(server.url, video, getCheckAttributes) | 194 | await completeVideoCheck(server.url, video, getCheckAttributes()) |
195 | }) | 195 | }) |
196 | 196 | ||
197 | it('Should have the views updated', async function () { | 197 | it('Should have the views updated', async function () { |
@@ -376,7 +376,7 @@ describe('Test a single server', function () { | |||
376 | const res = await getVideo(server.url, videoId) | 376 | const res = await getVideo(server.url, videoId) |
377 | const video = res.body | 377 | const video = res.body |
378 | 378 | ||
379 | await completeVideoCheck(server.url, video, updateCheckAttributes) | 379 | await completeVideoCheck(server.url, video, updateCheckAttributes()) |
380 | }) | 380 | }) |
381 | 381 | ||
382 | it('Should update only the tags of a video', async function () { | 382 | it('Should update only the tags of a video', async function () { |
@@ -388,7 +388,7 @@ describe('Test a single server', function () { | |||
388 | const res = await getVideo(server.url, videoId) | 388 | const res = await getVideo(server.url, videoId) |
389 | const video = res.body | 389 | const video = res.body |
390 | 390 | ||
391 | await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) | 391 | await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes)) |
392 | }) | 392 | }) |
393 | 393 | ||
394 | it('Should update only the description of a video', async function () { | 394 | it('Should update only the description of a video', async function () { |
@@ -400,7 +400,8 @@ describe('Test a single server', function () { | |||
400 | const res = await getVideo(server.url, videoId) | 400 | const res = await getVideo(server.url, videoId) |
401 | const video = res.body | 401 | const video = res.body |
402 | 402 | ||
403 | await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) | 403 | const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) |
404 | await completeVideoCheck(server.url, video, expectedAttributes) | ||
404 | }) | 405 | }) |
405 | 406 | ||
406 | it('Should like a video', async function () { | 407 | it('Should like a video', async function () { |
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 1c0327d40..3a3add71b 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -4,7 +4,8 @@ import * as chai from 'chai' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | acceptChangeOwnership, | 6 | acceptChangeOwnership, |
7 | changeVideoOwnership, cleanupTests, | 7 | changeVideoOwnership, |
8 | cleanupTests, | ||
8 | createUser, | 9 | createUser, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
@@ -13,7 +14,6 @@ import { | |||
13 | getVideo, | 14 | getVideo, |
14 | getVideoChangeOwnershipList, | 15 | getVideoChangeOwnershipList, |
15 | getVideosList, | 16 | getVideosList, |
16 | killallServers, | ||
17 | refuseChangeOwnership, | 17 | refuseChangeOwnership, |
18 | ServerInfo, | 18 | ServerInfo, |
19 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
@@ -203,8 +203,8 @@ describe('Test video change ownership - nominal', function () { | |||
203 | } | 203 | } |
204 | }) | 204 | }) |
205 | 205 | ||
206 | after(function () { | 206 | after(async function () { |
207 | killallServers(servers) | 207 | await cleanupTests(servers) |
208 | }) | 208 | }) |
209 | }) | 209 | }) |
210 | 210 | ||
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index f09148404..41fe3be5c 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -41,7 +41,7 @@ describe('Test video channels', function () { | |||
41 | let videoUUID: string | 41 | let videoUUID: string |
42 | 42 | ||
43 | before(async function () { | 43 | before(async function () { |
44 | this.timeout(30000) | 44 | this.timeout(60000) |
45 | 45 | ||
46 | servers = await flushAndRunMultipleServers(2) | 46 | servers = await flushAndRunMultipleServers(2) |
47 | 47 | ||
@@ -213,7 +213,7 @@ describe('Test video channels', function () { | |||
213 | this.timeout(10000) | 213 | this.timeout(10000) |
214 | 214 | ||
215 | for (const server of servers) { | 215 | for (const server of servers) { |
216 | const channelURI = 'second_video_channel@localhost:' + server.port | 216 | const channelURI = 'second_video_channel@localhost:' + servers[0].port |
217 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | 217 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) |
218 | expect(res1.body.total).to.equal(1) | 218 | expect(res1.body.total).to.equal(1) |
219 | expect(res1.body.data).to.be.an('array') | 219 | expect(res1.body.data).to.be.an('array') |
@@ -234,11 +234,11 @@ describe('Test video channels', function () { | |||
234 | this.timeout(10000) | 234 | this.timeout(10000) |
235 | 235 | ||
236 | for (const server of servers) { | 236 | for (const server of servers) { |
237 | const secondChannelURI = 'second_video_channel@localhost:' + server.port | 237 | const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port |
238 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) | 238 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) |
239 | expect(res1.body.total).to.equal(0) | 239 | expect(res1.body.total).to.equal(0) |
240 | 240 | ||
241 | const channelURI = 'root_channel@localhost:' + server.port | 241 | const channelURI = 'root_channel@localhost:' + servers[0].port |
242 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | 242 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) |
243 | expect(res2.body.total).to.equal(1) | 243 | expect(res2.body.total).to.equal(1) |
244 | 244 | ||
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 4565d0ebe..504c50dee 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -50,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
50 | 50 | ||
51 | { | 51 | { |
52 | for (const resolution of resolutions) { | 52 | for (const resolution of resolutions) { |
53 | const res2 = await getPlaylist(`http://localhost:${server.port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) | 53 | const res2 = await getPlaylist(`http://localhost:${servers[0].port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) |
54 | 54 | ||
55 | const subPlaylist = res2.text | 55 | const subPlaylist = res2.text |
56 | expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) | 56 | expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) |
@@ -58,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | { | 60 | { |
61 | const baseUrl = 'http://localhost:' + server.port + '/static/streaming-playlists/hls' | 61 | const baseUrl = 'http://localhost:' + servers[0].port + '/static/streaming-playlists/hls' |
62 | 62 | ||
63 | for (const resolution of resolutions) { | 63 | for (const resolution of resolutions) { |
64 | await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) | 64 | await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index e4d817ff8..83a2f3d4d 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -358,7 +358,7 @@ describe('Test video playlists', function () { | |||
358 | 358 | ||
359 | for (const server of servers) { | 359 | for (const server of servers) { |
360 | const results = [ | 360 | const results = [ |
361 | await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'), | 361 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), |
362 | await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') | 362 | await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') |
363 | ] | 363 | ] |
364 | 364 | ||
@@ -757,7 +757,7 @@ describe('Test video playlists', function () { | |||
757 | this.timeout(30000) | 757 | this.timeout(30000) |
758 | 758 | ||
759 | for (const server of servers) { | 759 | for (const server of servers) { |
760 | await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber) | 760 | await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber) |
761 | } | 761 | } |
762 | }) | 762 | }) |
763 | 763 | ||
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index c21d46d56..fbddd40f4 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | flushAndRunServer, | 10 | flushAndRunServer, |
11 | ServerInfo, | 11 | ServerInfo, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests | 13 | uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize |
14 | } from '../../../../shared/extra-utils' | 14 | } from '../../../../shared/extra-utils' |
15 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' | 15 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' |
16 | import { VideosOverview } from '../../../../shared/models/overviews' | 16 | import { VideosOverview } from '../../../../shared/models/overviews' |
@@ -58,14 +58,14 @@ describe('Test video views cleaner', function () { | |||
58 | 58 | ||
59 | { | 59 | { |
60 | for (const server of servers) { | 60 | for (const server of servers) { |
61 | const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) | 61 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) |
62 | expect(total).to.equal(2) | 62 | expect(total).to.equal(2) |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | { | 66 | { |
67 | for (const server of servers) { | 67 | for (const server of servers) { |
68 | const total = await countVideoViewsOf(server.serverNumber, videoIdServer2) | 68 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2) |
69 | expect(total).to.equal(2) | 69 | expect(total).to.equal(2) |
70 | } | 70 | } |
71 | } | 71 | } |
@@ -74,8 +74,6 @@ describe('Test video views cleaner', function () { | |||
74 | it('Should clean old video views', async function () { | 74 | it('Should clean old video views', async function () { |
75 | this.timeout(50000) | 75 | this.timeout(50000) |
76 | 76 | ||
77 | this.timeout(50000) | ||
78 | |||
79 | killallServers([ servers[0] ]) | 77 | killallServers([ servers[0] ]) |
80 | 78 | ||
81 | await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) | 79 | await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) |
@@ -86,21 +84,23 @@ describe('Test video views cleaner', function () { | |||
86 | 84 | ||
87 | { | 85 | { |
88 | for (const server of servers) { | 86 | for (const server of servers) { |
89 | const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) | 87 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) |
90 | expect(total).to.equal(2) | 88 | expect(total).to.equal(2) |
91 | } | 89 | } |
92 | } | 90 | } |
93 | 91 | ||
94 | { | 92 | { |
95 | const totalServer1 = await countVideoViewsOf(servers[0].serverNumber, videoIdServer2) | 93 | const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2) |
96 | expect(totalServer1).to.equal(0) | 94 | expect(totalServer1).to.equal(0) |
97 | 95 | ||
98 | const totalServer2 = await countVideoViewsOf(servers[1].serverNumber, videoIdServer2) | 96 | const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2) |
99 | expect(totalServer2).to.equal(2) | 97 | expect(totalServer2).to.equal(2) |
100 | } | 98 | } |
101 | }) | 99 | }) |
102 | 100 | ||
103 | after(async function () { | 101 | after(async function () { |
102 | await closeAllSequelize(servers) | ||
103 | |||
104 | await cleanupTests(servers) | 104 | await cleanupTests(servers) |
105 | }) | 105 | }) |
106 | }) | 106 | }) |