aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/activitypub/index.ts1
-rw-r--r--server/tests/api/activitypub/refresher.ts84
2 files changed, 85 insertions, 0 deletions
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..67e04f79e
--- /dev/null
+++ b/server/tests/api/activitypub/refresher.ts
@@ -0,0 +1,84 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import { doubleFollow, getVideo, reRunServer } from '../../utils'
5import { flushAndRunMultipleServers, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '../../utils/index'
6import { waitJobs } from '../../utils/server/jobs'
7import { setVideoField } from '../../utils/miscs/sql'
8
9describe('Test AP refresher', function () {
10 let servers: ServerInfo[] = []
11 let videoUUID1: string
12 let videoUUID2: string
13 let videoUUID3: string
14
15 before(async function () {
16 this.timeout(30000)
17
18 servers = await flushAndRunMultipleServers(2)
19
20 // Get the access tokens
21 await setAccessTokensToServers(servers)
22
23 {
24 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
25 videoUUID1 = res.body.video.uuid
26 }
27
28 {
29 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
30 videoUUID2 = res.body.video.uuid
31 }
32
33 {
34 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video3' })
35 videoUUID3 = res.body.video.uuid
36 }
37
38 await doubleFollow(servers[0], servers[1])
39 })
40
41 it('Should remove a deleted remote video', async function () {
42 this.timeout(60000)
43
44 await wait(10000)
45
46 // Change UUID so the remote server returns a 404
47 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
48
49 await getVideo(servers[0].url, videoUUID1)
50 await getVideo(servers[0].url, videoUUID2)
51
52 await waitJobs(servers)
53
54 await getVideo(servers[0].url, videoUUID1, 404)
55 await getVideo(servers[0].url, videoUUID2, 200)
56 })
57
58 it('Should not update a remote video if the remote instance is down', async function () {
59 this.timeout(60000)
60
61 killallServers([ servers[1] ])
62
63 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
64
65 // Video will need a refresh
66 await wait(10000)
67
68 await getVideo(servers[0].url, videoUUID3)
69 // The refresh should fail
70 await waitJobs([ servers[0] ])
71
72 await reRunServer(servers[1])
73
74 // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances)
75 await getVideo(servers[0].url, videoUUID3)
76 await waitJobs(servers)
77
78 await getVideo(servers[0].url, videoUUID3, 200)
79 })
80
81 after(async function () {
82 killallServers(servers)
83 })
84})