aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/activitypub/client.ts40
-rw-r--r--server/tests/api/activitypub/fetch.ts7
-rw-r--r--server/tests/api/activitypub/helpers.ts10
-rw-r--r--server/tests/api/activitypub/index.ts1
-rw-r--r--server/tests/api/activitypub/refresher.ts93
-rw-r--r--server/tests/api/activitypub/security.ts7
-rw-r--r--server/tests/api/check-params/users.ts17
-rw-r--r--server/tests/api/redundancy/redundancy.ts27
-rw-r--r--server/tests/api/users/users.ts2
-rw-r--r--server/tests/cli/index.ts1
-rw-r--r--server/tests/misc-endpoints.ts82
-rw-r--r--server/tests/utils/miscs/sql.ts38
-rw-r--r--server/tests/utils/miscs/stubs.ts14
-rw-r--r--server/tests/utils/requests/activitypub.ts43
14 files changed, 251 insertions, 131 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index d45232c8d..6d90d8643 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -3,32 +3,41 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 doubleFollow,
7 flushAndRunMultipleServers,
6 flushTests, 8 flushTests,
7 killallServers, 9 killallServers,
8 makeActivityPubGetRequest, 10 makeActivityPubGetRequest,
9 runServer,
10 ServerInfo, 11 ServerInfo,
11 setAccessTokensToServers 12 setAccessTokensToServers,
13 uploadVideo
12} from '../../../../shared/utils' 14} from '../../../../shared/utils'
13 15
14
15const expect = chai.expect 16const expect = chai.expect
16 17
17describe('Test activitypub', function () { 18describe('Test activitypub', function () {
18 let server: ServerInfo = null 19 let servers: ServerInfo[] = []
20 let videoUUID: string
19 21
20 before(async function () { 22 before(async function () {
21 this.timeout(30000) 23 this.timeout(30000)
22 24
23 await flushTests() 25 await flushTests()
24 26
25 server = await runServer(1) 27 servers = await flushAndRunMultipleServers(2)
28
29 await setAccessTokensToServers(servers)
30
31 {
32 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
33 videoUUID = res.body.video.uuid
34 }
26 35
27 await setAccessTokensToServers([ server ]) 36 await doubleFollow(servers[0], servers[1])
28 }) 37 })
29 38
30 it('Should return the account object', async function () { 39 it('Should return the account object', async function () {
31 const res = await makeActivityPubGetRequest(server.url, '/accounts/root') 40 const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
32 const object = res.body 41 const object = res.body
33 42
34 expect(object.type).to.equal('Person') 43 expect(object.type).to.equal('Person')
@@ -37,7 +46,22 @@ describe('Test activitypub', function () {
37 expect(object.preferredUsername).to.equal('root') 46 expect(object.preferredUsername).to.equal('root')
38 }) 47 })
39 48
49 it('Should return the video object', async function () {
50 const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID)
51 const object = res.body
52
53 expect(object.type).to.equal('Video')
54 expect(object.id).to.equal('http://localhost:9001/videos/watch/' + videoUUID)
55 expect(object.name).to.equal('video')
56 })
57
58 it('Should redirect to the origin video object', async function () {
59 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302)
60
61 expect(res.header.location).to.equal('http://localhost:9001/videos/watch/' + videoUUID)
62 })
63
40 after(async function () { 64 after(async function () {
41 killallServers([ server ]) 65 killallServers(servers)
42 }) 66 })
43}) 67})
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index e84eb18bb..03609c1a9 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -11,12 +11,13 @@ import {
11 killallServers, 11 killallServers,
12 ServerInfo, 12 ServerInfo,
13 setAccessTokensToServers, 13 setAccessTokensToServers,
14 setActorField,
15 setVideoField,
14 uploadVideo, 16 uploadVideo,
15 userLogin 17 userLogin,
18 waitJobs
16} from '../../../../shared/utils' 19} from '../../../../shared/utils'
17import * as chai from 'chai' 20import * as chai from 'chai'
18import { setActorField, setVideoField } from '../../utils/miscs/sql'
19import { waitJobs } from '../../../../shared/utils/server/jobs'
20import { Video } from '../../../../shared/models/videos' 21import { Video } from '../../../../shared/models/videos'
21 22
22const expect = chai.expect 23const expect = chai.expect
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts
index 4c42f3d67..ac6e755c3 100644
--- a/server/tests/api/activitypub/helpers.ts
+++ b/server/tests/api/activitypub/helpers.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { buildRequestStub } from '../../utils/miscs/stubs' 5import { buildRequestStub } from '../../../../shared/utils/miscs/stubs'
6import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' 6import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
7import { cloneDeep } from 'lodash' 7import { cloneDeep } from 'lodash'
8import { buildSignedActivity } from '../../../helpers/activitypub' 8import { buildSignedActivity } from '../../../helpers/activitypub'
@@ -91,7 +91,7 @@ describe('Test activity pub helpers', function () {
91 req.headers = mastodonObject.headers 91 req.headers = mastodonObject.headers
92 req.headers.signature = 'Signature ' + req.headers.signature 92 req.headers.signature = 'Signature ' + req.headers.signature
93 93
94 const parsed = parseHTTPSignature(req, 3600 * 365 * 3) 94 const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10)
95 const publicKey = require('./json/mastodon/public-key.json').publicKey 95 const publicKey = require('./json/mastodon/public-key.json').publicKey
96 96
97 const actor = { publicKey } 97 const actor = { publicKey }
@@ -110,7 +110,7 @@ describe('Test activity pub helpers', function () {
110 req.headers = mastodonObject.headers 110 req.headers = mastodonObject.headers
111 req.headers.signature = 'Signature ' + req.headers.signature 111 req.headers.signature = 'Signature ' + req.headers.signature
112 112
113 const parsed = parseHTTPSignature(req, 3600 * 365 * 3) 113 const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10)
114 const publicKey = require('./json/mastodon/bad-public-key.json').publicKey 114 const publicKey = require('./json/mastodon/bad-public-key.json').publicKey
115 115
116 const actor = { publicKey } 116 const actor = { publicKey }
@@ -150,7 +150,7 @@ describe('Test activity pub helpers', function () {
150 150
151 let errored = false 151 let errored = false
152 try { 152 try {
153 parseHTTPSignature(req, 3600 * 365 * 3) 153 parseHTTPSignature(req, 3600 * 1000 * 365 * 10)
154 } catch { 154 } catch {
155 errored = true 155 errored = true
156 } 156 }
@@ -168,7 +168,7 @@ describe('Test activity pub helpers', function () {
168 req.headers = mastodonObject.headers 168 req.headers = mastodonObject.headers
169 req.headers.signature = 'Signature ' + req.headers.signature 169 req.headers.signature = 'Signature ' + req.headers.signature
170 170
171 const parsed = parseHTTPSignature(req, 3600 * 365 * 3) 171 const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10)
172 const publicKey = require('./json/mastodon/public-key.json').publicKey 172 const publicKey = require('./json/mastodon/public-key.json').publicKey
173 173
174 const actor = { publicKey } 174 const actor = { publicKey }
diff --git a/server/tests/api/activitypub/index.ts b/server/tests/api/activitypub/index.ts
index e748f32e9..450053309 100644
--- a/server/tests/api/activitypub/index.ts
+++ b/server/tests/api/activitypub/index.ts
@@ -1,4 +1,5 @@
1import './client' 1import './client'
2import './fetch' 2import './fetch'
3import './helpers' 3import './helpers'
4import './refresher'
4import './security' 5import './security'
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
new file mode 100644
index 000000000..332ea7ed1
--- /dev/null
+++ b/server/tests/api/activitypub/refresher.ts
@@ -0,0 +1,93 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import {
5 doubleFollow,
6 flushAndRunMultipleServers,
7 getVideo,
8 killallServers,
9 reRunServer,
10 ServerInfo,
11 setAccessTokensToServers,
12 uploadVideo,
13 wait,
14 setVideoField,
15 waitJobs
16} from '../../../../shared/utils'
17
18describe('Test AP refresher', function () {
19 let servers: ServerInfo[] = []
20 let videoUUID1: string
21 let videoUUID2: string
22 let videoUUID3: string
23
24 before(async function () {
25 this.timeout(30000)
26
27 servers = await flushAndRunMultipleServers(2)
28
29 // Get the access tokens
30 await setAccessTokensToServers(servers)
31
32 {
33 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
34 videoUUID1 = res.body.video.uuid
35 }
36
37 {
38 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
39 videoUUID2 = res.body.video.uuid
40 }
41
42 {
43 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video3' })
44 videoUUID3 = res.body.video.uuid
45 }
46
47 await doubleFollow(servers[0], servers[1])
48 })
49
50 it('Should remove a deleted remote video', async function () {
51 this.timeout(60000)
52
53 await wait(10000)
54
55 // Change UUID so the remote server returns a 404
56 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
57
58 await getVideo(servers[0].url, videoUUID1)
59 await getVideo(servers[0].url, videoUUID2)
60
61 await waitJobs(servers)
62
63 await getVideo(servers[0].url, videoUUID1, 404)
64 await getVideo(servers[0].url, videoUUID2, 200)
65 })
66
67 it('Should not update a remote video if the remote instance is down', async function () {
68 this.timeout(60000)
69
70 killallServers([ servers[1] ])
71
72 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
73
74 // Video will need a refresh
75 await wait(10000)
76
77 await getVideo(servers[0].url, videoUUID3)
78 // The refresh should fail
79 await waitJobs([ servers[0] ])
80
81 await reRunServer(servers[1])
82
83 // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances)
84 await getVideo(servers[0].url, videoUUID3)
85 await waitJobs(servers)
86
87 await getVideo(servers[0].url, videoUUID3, 200)
88 })
89
90 after(async function () {
91 killallServers(servers)
92 })
93})
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index b71a61c8c..342ae0fa1 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -6,14 +6,15 @@ import {
6 flushAndRunMultipleServers, 6 flushAndRunMultipleServers,
7 flushTests, 7 flushTests,
8 killallServers, 8 killallServers,
9 ServerInfo 9 makeFollowRequest,
10 makePOSTAPRequest,
11 ServerInfo,
12 setActorField
10} from '../../../../shared/utils' 13} from '../../../../shared/utils'
11import { HTTP_SIGNATURE } from '../../../initializers' 14import { HTTP_SIGNATURE } from '../../../initializers'
12import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' 15import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
13import * as chai from 'chai' 16import * as chai from 'chai'
14import { setActorField } from '../../utils/miscs/sql'
15import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub' 17import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub'
16import { makeFollowRequest, makePOSTAPRequest } from '../../utils/requests/activitypub'
17 18
18const expect = chai.expect 19const expect = chai.expect
19 20
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index f4c177621..05f42bca9 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -103,13 +103,13 @@ describe('Test users API validators', function () {
103 } 103 }
104 104
105 it('Should fail with a too small username', async function () { 105 it('Should fail with a too small username', async function () {
106 const fields = immutableAssign(baseCorrectParams, { username: 'fi' }) 106 const fields = immutableAssign(baseCorrectParams, { username: '' })
107 107
108 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 108 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
109 }) 109 })
110 110
111 it('Should fail with a too long username', async function () { 111 it('Should fail with a too long username', async function () {
112 const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' }) 112 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(11) })
113 113
114 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 114 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
115 }) 115 })
@@ -432,6 +432,14 @@ describe('Test users API validators', function () {
432 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }) 432 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
433 }) 433 })
434 434
435 it('Should fail with an invalid emailVerified attribute', async function () {
436 const fields = {
437 emailVerified: 'yes'
438 }
439
440 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
441 })
442
435 it('Should fail with an invalid videoQuota attribute', async function () { 443 it('Should fail with an invalid videoQuota attribute', async function () {
436 const fields = { 444 const fields = {
437 videoQuota: -90 445 videoQuota: -90
@@ -467,6 +475,7 @@ describe('Test users API validators', function () {
467 it('Should succeed with the correct params', async function () { 475 it('Should succeed with the correct params', async function () {
468 const fields = { 476 const fields = {
469 email: 'email@example.com', 477 email: 'email@example.com',
478 emailVerified: true,
470 videoQuota: 42, 479 videoQuota: 42,
471 role: UserRole.MODERATOR 480 role: UserRole.MODERATOR
472 } 481 }
@@ -545,13 +554,13 @@ describe('Test users API validators', function () {
545 } 554 }
546 555
547 it('Should fail with a too small username', async function () { 556 it('Should fail with a too small username', async function () {
548 const fields = immutableAssign(baseCorrectParams, { username: 'ji' }) 557 const fields = immutableAssign(baseCorrectParams, { username: '' })
549 558
550 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 559 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
551 }) 560 })
552 561
553 it('Should fail with a too long username', async function () { 562 it('Should fail with a too long username', async function () {
554 const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' }) 563 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(11) })
555 564
556 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 565 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
557 }) 566 })
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 2bc1b60ce..9d3ce8153 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -137,7 +137,7 @@ async function check2Webseeds (strategy: VideoRedundancyStrategy, videoUUID?: st
137 if (!videoUUID) videoUUID = video1Server2UUID 137 if (!videoUUID) videoUUID = video1Server2UUID
138 138
139 const webseeds = [ 139 const webseeds = [
140 'http://localhost:9001/static/webseed/' + videoUUID, 140 'http://localhost:9001/static/redundancy/' + videoUUID,
141 'http://localhost:9002/static/webseed/' + videoUUID 141 'http://localhost:9002/static/webseed/' + videoUUID
142 ] 142 ]
143 143
@@ -149,20 +149,23 @@ async function check2Webseeds (strategy: VideoRedundancyStrategy, videoUUID?: st
149 for (const file of video.files) { 149 for (const file of video.files) {
150 checkMagnetWebseeds(file, webseeds, server) 150 checkMagnetWebseeds(file, webseeds, server)
151 151
152 // Only servers 1 and 2 have the video 152 await makeGetRequest({
153 if (server.serverNumber !== 3) { 153 url: servers[0].url,
154 await makeGetRequest({ 154 statusCodeExpected: 200,
155 url: server.url, 155 path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`,
156 statusCodeExpected: 200, 156 contentType: null
157 path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`, 157 })
158 contentType: null 158 await makeGetRequest({
159 }) 159 url: servers[1].url,
160 } 160 statusCodeExpected: 200,
161 path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`,
162 contentType: null
163 })
161 } 164 }
162 } 165 }
163 166
164 for (const directory of [ 'test1', 'test2' ]) { 167 for (const directory of [ 'test1/redundancy', 'test2/videos' ]) {
165 const files = await readdir(join(root(), directory, 'videos')) 168 const files = await readdir(join(root(), directory))
166 expect(files).to.have.length.at.least(4) 169 expect(files).to.have.length.at.least(4)
167 170
168 for (const resolution of [ 240, 360, 480, 720 ]) { 171 for (const resolution of [ 240, 360, 480, 720 ]) {
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 7dffbb0b1..4914c8ed5 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -478,6 +478,7 @@ describe('Test users', function () {
478 userId, 478 userId,
479 accessToken, 479 accessToken,
480 email: 'updated2@example.com', 480 email: 'updated2@example.com',
481 emailVerified: true,
481 videoQuota: 42, 482 videoQuota: 42,
482 role: UserRole.MODERATOR 483 role: UserRole.MODERATOR
483 }) 484 })
@@ -487,6 +488,7 @@ describe('Test users', function () {
487 488
488 expect(user.username).to.equal('user_1') 489 expect(user.username).to.equal('user_1')
489 expect(user.email).to.equal('updated2@example.com') 490 expect(user.email).to.equal('updated2@example.com')
491 expect(user.emailVerified).to.be.true
490 expect(user.nsfwPolicy).to.equal('do_not_list') 492 expect(user.nsfwPolicy).to.equal('do_not_list')
491 expect(user.videoQuota).to.equal(42) 493 expect(user.videoQuota).to.equal(42)
492 expect(user.roleLabel).to.equal('Moderator') 494 expect(user.roleLabel).to.equal('Moderator')
diff --git a/server/tests/cli/index.ts b/server/tests/cli/index.ts
index 6201314ce..c6b7ec078 100644
--- a/server/tests/cli/index.ts
+++ b/server/tests/cli/index.ts
@@ -1,6 +1,7 @@
1// Order of the tests we want to execute 1// Order of the tests we want to execute
2import './create-import-video-file-job' 2import './create-import-video-file-job'
3import './create-transcoding-job' 3import './create-transcoding-job'
4import './optimize-old-videos'
4import './peertube' 5import './peertube'
5import './reset-password' 6import './reset-password'
6import './update-host' 7import './update-host'
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index f948fdfd0..5f82719da 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -2,7 +2,18 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { flushTests, killallServers, makeGetRequest, runServer, ServerInfo } from '../../shared/utils' 5import {
6 addVideoChannel,
7 createUser,
8 flushTests,
9 killallServers,
10 makeGetRequest,
11 runServer,
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo
15} from '../../shared/utils'
16import { VideoPrivacy } from '../../shared/models/videos'
6 17
7const expect = chai.expect 18const expect = chai.expect
8 19
@@ -15,6 +26,7 @@ describe('Test misc endpoints', function () {
15 await flushTests() 26 await flushTests()
16 27
17 server = await runServer(1) 28 server = await runServer(1)
29 await setAccessTokensToServers([ server ])
18 }) 30 })
19 31
20 describe('Test a well known endpoints', function () { 32 describe('Test a well known endpoints', function () {
@@ -60,6 +72,16 @@ describe('Test misc endpoints', function () {
60 72
61 expect(res.body.tracking).to.equal('N') 73 expect(res.body.tracking).to.equal('N')
62 }) 74 })
75
76 it('Should get change-password location', async function () {
77 const res = await makeGetRequest({
78 url: server.url,
79 path: '/.well-known/change-password',
80 statusCodeExpected: 302
81 })
82
83 expect(res.header.location).to.equal('/my-account/settings')
84 })
63 }) 85 })
64 86
65 describe('Test classic static endpoints', function () { 87 describe('Test classic static endpoints', function () {
@@ -93,6 +115,64 @@ describe('Test misc endpoints', function () {
93 }) 115 })
94 }) 116 })
95 117
118 describe('Test bots endpoints', function () {
119
120 it('Should get the empty sitemap', async function () {
121 const res = await makeGetRequest({
122 url: server.url,
123 path: '/sitemap.xml',
124 statusCodeExpected: 200
125 })
126
127 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
128 expect(res.text).to.contain('<url><loc>http://localhost:9001/about/instance</loc></url>')
129 })
130
131 it('Should get the empty cached sitemap', async function () {
132 const res = await makeGetRequest({
133 url: server.url,
134 path: '/sitemap.xml',
135 statusCodeExpected: 200
136 })
137
138 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
139 expect(res.text).to.contain('<url><loc>http://localhost:9001/about/instance</loc></url>')
140 })
141
142 it('Should add videos, channel and accounts and get sitemap', async function () {
143 this.timeout(35000)
144
145 await uploadVideo(server.url, server.accessToken, { name: 'video 1', nsfw: false })
146 await uploadVideo(server.url, server.accessToken, { name: 'video 2', nsfw: false })
147 await uploadVideo(server.url, server.accessToken, { name: 'video 3', privacy: VideoPrivacy.PRIVATE })
148
149 await addVideoChannel(server.url, server.accessToken, { name: 'channel1', displayName: 'channel 1' })
150 await addVideoChannel(server.url, server.accessToken, { name: 'channel2', displayName: 'channel 2' })
151
152 await createUser(server.url, server.accessToken, 'user1', 'password')
153 await createUser(server.url, server.accessToken, 'user2', 'password')
154
155 const res = await makeGetRequest({
156 url: server.url,
157 path: '/sitemap.xml?t=1', // avoid using cache
158 statusCodeExpected: 200
159 })
160
161 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
162 expect(res.text).to.contain('<url><loc>http://localhost:9001/about/instance</loc></url>')
163
164 expect(res.text).to.contain('<video:title><![CDATA[video 1]]></video:title>')
165 expect(res.text).to.contain('<video:title><![CDATA[video 2]]></video:title>')
166 expect(res.text).to.not.contain('<video:title><![CDATA[video 3]]></video:title>')
167
168 expect(res.text).to.contain('<url><loc>http://localhost:9001/video-channels/channel1</loc></url>')
169 expect(res.text).to.contain('<url><loc>http://localhost:9001/video-channels/channel2</loc></url>')
170
171 expect(res.text).to.contain('<url><loc>http://localhost:9001/accounts/user1</loc></url>')
172 expect(res.text).to.contain('<url><loc>http://localhost:9001/accounts/user2</loc></url>')
173 })
174 })
175
96 after(async function () { 176 after(async function () {
97 killallServers([ server ]) 177 killallServers([ server ])
98 }) 178 })
diff --git a/server/tests/utils/miscs/sql.ts b/server/tests/utils/miscs/sql.ts
deleted file mode 100644
index 027f78131..000000000
--- a/server/tests/utils/miscs/sql.ts
+++ /dev/null
@@ -1,38 +0,0 @@
1import * as Sequelize from 'sequelize'
2
3function getSequelize (serverNumber: number) {
4 const dbname = 'peertube_test' + serverNumber
5 const username = 'peertube'
6 const password = 'peertube'
7 const host = 'localhost'
8 const port = 5432
9
10 return new Sequelize(dbname, username, password, {
11 dialect: 'postgres',
12 host,
13 port,
14 operatorsAliases: false,
15 logging: false
16 })
17}
18
19function setActorField (serverNumber: number, to: string, field: string, value: string) {
20 const seq = getSequelize(serverNumber)
21
22 const options = { type: Sequelize.QueryTypes.UPDATE }
23
24 return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
25}
26
27function setVideoField (serverNumber: number, uuid: string, field: string, value: string) {
28 const seq = getSequelize(serverNumber)
29
30 const options = { type: Sequelize.QueryTypes.UPDATE }
31
32 return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
33}
34
35export {
36 setVideoField,
37 setActorField
38}
diff --git a/server/tests/utils/miscs/stubs.ts b/server/tests/utils/miscs/stubs.ts
deleted file mode 100644
index d1eb0e3b2..000000000
--- a/server/tests/utils/miscs/stubs.ts
+++ /dev/null
@@ -1,14 +0,0 @@
1function buildRequestStub (): any {
2 return { }
3}
4
5function buildResponseStub (): any {
6 return {
7 locals: {}
8 }
9}
10
11export {
12 buildResponseStub,
13 buildRequestStub
14}
diff --git a/server/tests/utils/requests/activitypub.ts b/server/tests/utils/requests/activitypub.ts
deleted file mode 100644
index 96fee60a8..000000000
--- a/server/tests/utils/requests/activitypub.ts
+++ /dev/null
@@ -1,43 +0,0 @@
1import { doRequest } from '../../../helpers/requests'
2import { HTTP_SIGNATURE } from '../../../initializers'
3import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
4import { activityPubContextify } from '../../../helpers/activitypub'
5
6function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
7 const options = {
8 method: 'POST',
9 uri: url,
10 json: body,
11 httpSignature,
12 headers
13 }
14
15 return doRequest(options)
16}
17
18async function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) {
19 const follow = {
20 type: 'Follow',
21 id: by.url + '/toto',
22 actor: by.url,
23 object: to.url
24 }
25
26 const body = activityPubContextify(follow)
27
28 const httpSignature = {
29 algorithm: HTTP_SIGNATURE.ALGORITHM,
30 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
31 keyId: by.url,
32 key: by.privateKey,
33 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
34 }
35 const headers = buildGlobalHeaders(body)
36
37 return makePOSTAPRequest(to.url, body, httpSignature, headers)
38}
39
40export {
41 makePOSTAPRequest,
42 makeFollowRequest
43}