aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/activitypub
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-08 21:16:10 +0100
committerGitHub <noreply@github.com>2020-12-08 21:16:10 +0100
commitf2eb23cd87cf32b8fe545178143b5f49e06a58da (patch)
treeaf7d59945af70e28fd85047e2c688c59a908f548 /server/tests/api/activitypub
parentc977fd3ec931c059111ddb2b8d6ddbb20b6b99a1 (diff)
downloadPeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.gz
PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.zst
PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.zip
emit more specific status codes on video upload (#3423)
- reduce http status codes list to potentially useful codes - convert more codes to typed ones - factorize html generator for error responses
Diffstat (limited to 'server/tests/api/activitypub')
-rw-r--r--server/tests/api/activitypub/client.ts3
-rw-r--r--server/tests/api/activitypub/refresher.ts15
2 files changed, 10 insertions, 8 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index d16f05108..b6c538e19 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -11,6 +11,7 @@ import {
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 uploadVideo 12 uploadVideo
13} from '../../../../shared/extra-utils' 13} from '../../../../shared/extra-utils'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
14 15
15const expect = chai.expect 16const expect = chai.expect
16 17
@@ -53,7 +54,7 @@ describe('Test activitypub', function () {
53 }) 54 })
54 55
55 it('Should redirect to the origin video object', async function () { 56 it('Should redirect to the origin video object', async function () {
56 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302) 57 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302)
57 58
58 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) 59 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
59 }) 60 })
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 232c5d823..c717f1a30 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -24,6 +24,7 @@ import {
24} from '../../../../shared/extra-utils' 24} from '../../../../shared/extra-utils'
25import { getAccount } from '../../../../shared/extra-utils/users/accounts' 25import { getAccount } from '../../../../shared/extra-utils/users/accounts'
26import { VideoPlaylistPrivacy } from '../../../../shared/models/videos' 26import { VideoPlaylistPrivacy } from '../../../../shared/models/videos'
27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
27 28
28describe('Test AP refresher', function () { 29describe('Test AP refresher', function () {
29 let servers: ServerInfo[] = [] 30 let servers: ServerInfo[] = []
@@ -86,8 +87,8 @@ describe('Test AP refresher', function () {
86 87
87 await waitJobs(servers) 88 await waitJobs(servers)
88 89
89 await getVideo(servers[0].url, videoUUID1, 404) 90 await getVideo(servers[0].url, videoUUID1, HttpStatusCode.NOT_FOUND_404)
90 await getVideo(servers[0].url, videoUUID2, 200) 91 await getVideo(servers[0].url, videoUUID2, HttpStatusCode.OK_200)
91 }) 92 })
92 93
93 it('Should not update a remote video if the remote instance is down', async function () { 94 it('Should not update a remote video if the remote instance is down', async function () {
@@ -106,7 +107,7 @@ describe('Test AP refresher', function () {
106 107
107 await reRunServer(servers[1]) 108 await reRunServer(servers[1])
108 109
109 await getVideo(servers[0].url, videoUUID3, 200) 110 await getVideo(servers[0].url, videoUUID3, HttpStatusCode.OK_200)
110 }) 111 })
111 }) 112 })
112 113
@@ -126,8 +127,8 @@ describe('Test AP refresher', function () {
126 127
127 await waitJobs(servers) 128 await waitJobs(servers)
128 129
129 await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, 200) 130 await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, HttpStatusCode.OK_200)
130 await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, 404) 131 await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, HttpStatusCode.NOT_FOUND_404)
131 }) 132 })
132 }) 133 })
133 134
@@ -146,8 +147,8 @@ describe('Test AP refresher', function () {
146 147
147 await waitJobs(servers) 148 await waitJobs(servers)
148 149
149 await getVideoPlaylist(servers[0].url, playlistUUID1, 200) 150 await getVideoPlaylist(servers[0].url, playlistUUID1, HttpStatusCode.OK_200)
150 await getVideoPlaylist(servers[0].url, playlistUUID2, 404) 151 await getVideoPlaylist(servers[0].url, playlistUUID2, HttpStatusCode.NOT_FOUND_404)
151 }) 152 })
152 }) 153 })
153 154