diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:21:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:21:13 +0200 |
commit | 784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428 (patch) | |
tree | 29c46cfd6344065eb805680ed080cb05592ee1d4 /server/tests/api/object-storage | |
parent | c3030e944ad03c7fd7b5d668a2d88ff03e4cdf19 (diff) | |
download | PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.gz PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.zst PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.zip |
Prefer web videos in favour of webtorrent
Diffstat (limited to 'server/tests/api/object-storage')
-rw-r--r-- | server/tests/api/object-storage/video-static-file-privacy.ts | 30 | ||||
-rw-r--r-- | server/tests/api/object-storage/videos.ts | 38 |
2 files changed, 34 insertions, 34 deletions
diff --git a/server/tests/api/object-storage/video-static-file-privacy.ts b/server/tests/api/object-storage/video-static-file-privacy.ts index 2a7c3381d..18d30a2f5 100644 --- a/server/tests/api/object-storage/video-static-file-privacy.ts +++ b/server/tests/api/object-storage/video-static-file-privacy.ts | |||
@@ -120,7 +120,7 @@ describe('Object storage for video static file privacy', function () { | |||
120 | const video = await server.videos.getWithToken({ id: videoId }) | 120 | const video = await server.videos.getWithToken({ id: videoId }) |
121 | 121 | ||
122 | return { | 122 | return { |
123 | webTorrentFile: video.files[0].fileUrl, | 123 | webVideoFile: video.files[0].fileUrl, |
124 | hlsFile: getHLS(video).files[0].fileUrl | 124 | hlsFile: getHLS(video).files[0].fileUrl |
125 | } | 125 | } |
126 | } | 126 | } |
@@ -175,10 +175,10 @@ describe('Object storage for video static file privacy', function () { | |||
175 | it('Should not get files without appropriate OAuth token', async function () { | 175 | it('Should not get files without appropriate OAuth token', async function () { |
176 | this.timeout(60000) | 176 | this.timeout(60000) |
177 | 177 | ||
178 | const { webTorrentFile, hlsFile } = await getSampleFileUrls(privateVideoUUID) | 178 | const { webVideoFile, hlsFile } = await getSampleFileUrls(privateVideoUUID) |
179 | 179 | ||
180 | await makeRawRequest({ url: webTorrentFile, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 180 | await makeRawRequest({ url: webVideoFile, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
181 | await makeRawRequest({ url: webTorrentFile, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) | 181 | await makeRawRequest({ url: webVideoFile, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
182 | 182 | ||
183 | await makeRawRequest({ url: hlsFile, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 183 | await makeRawRequest({ url: hlsFile, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
184 | await makeRawRequest({ url: hlsFile, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) | 184 | await makeRawRequest({ url: hlsFile, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
@@ -187,18 +187,18 @@ describe('Object storage for video static file privacy', function () { | |||
187 | it('Should not get files without appropriate password or appropriate OAuth token', async function () { | 187 | it('Should not get files without appropriate password or appropriate OAuth token', async function () { |
188 | this.timeout(60000) | 188 | this.timeout(60000) |
189 | 189 | ||
190 | const { webTorrentFile, hlsFile } = await getSampleFileUrls(passwordProtectedVideoUUID) | 190 | const { webVideoFile, hlsFile } = await getSampleFileUrls(passwordProtectedVideoUUID) |
191 | 191 | ||
192 | await makeRawRequest({ url: webTorrentFile, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 192 | await makeRawRequest({ url: webVideoFile, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
193 | await makeRawRequest({ | 193 | await makeRawRequest({ |
194 | url: webTorrentFile, | 194 | url: webVideoFile, |
195 | token: null, | 195 | token: null, |
196 | headers: incorrectPasswordHeader, | 196 | headers: incorrectPasswordHeader, |
197 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | 197 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
198 | }) | 198 | }) |
199 | await makeRawRequest({ url: webTorrentFile, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) | 199 | await makeRawRequest({ url: webVideoFile, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
200 | await makeRawRequest({ | 200 | await makeRawRequest({ |
201 | url: webTorrentFile, | 201 | url: webVideoFile, |
202 | token: null, | 202 | token: null, |
203 | headers: correctPasswordHeader, | 203 | headers: correctPasswordHeader, |
204 | expectedStatus: HttpStatusCode.OK_200 | 204 | expectedStatus: HttpStatusCode.OK_200 |
@@ -239,9 +239,9 @@ describe('Object storage for video static file privacy', function () { | |||
239 | const badVideoFileToken = await server.videoToken.getVideoFileToken({ token: userToken, videoId: userPrivateVideoUUID }) | 239 | const badVideoFileToken = await server.videoToken.getVideoFileToken({ token: userToken, videoId: userPrivateVideoUUID }) |
240 | const goodVideoFileToken = await server.videoToken.getVideoFileToken({ videoId: privateVideoUUID }) | 240 | const goodVideoFileToken = await server.videoToken.getVideoFileToken({ videoId: privateVideoUUID }) |
241 | 241 | ||
242 | const { webTorrentFile, hlsFile } = await getSampleFileUrls(privateVideoUUID) | 242 | const { webVideoFile, hlsFile } = await getSampleFileUrls(privateVideoUUID) |
243 | 243 | ||
244 | for (const url of [ webTorrentFile, hlsFile ]) { | 244 | for (const url of [ webVideoFile, hlsFile ]) { |
245 | await makeRawRequest({ url, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 245 | await makeRawRequest({ url, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
246 | await makeRawRequest({ url, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 246 | await makeRawRequest({ url, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
247 | await makeRawRequest({ url, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) | 247 | await makeRawRequest({ url, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
@@ -261,9 +261,9 @@ describe('Object storage for video static file privacy', function () { | |||
261 | videoPassword: correctPassword | 261 | videoPassword: correctPassword |
262 | }) | 262 | }) |
263 | 263 | ||
264 | const { webTorrentFile, hlsFile } = await getSampleFileUrls(passwordProtectedVideoUUID) | 264 | const { webVideoFile, hlsFile } = await getSampleFileUrls(passwordProtectedVideoUUID) |
265 | 265 | ||
266 | for (const url of [ hlsFile, webTorrentFile ]) { | 266 | for (const url of [ hlsFile, webVideoFile ]) { |
267 | await makeRawRequest({ url, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 267 | await makeRawRequest({ url, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
268 | await makeRawRequest({ url, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 268 | await makeRawRequest({ url, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
269 | await makeRawRequest({ url, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) | 269 | await makeRawRequest({ url, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
@@ -534,11 +534,11 @@ describe('Object storage for video static file privacy', function () { | |||
534 | 534 | ||
535 | it('Should not be able to access object storage proxy', async function () { | 535 | it('Should not be able to access object storage proxy', async function () { |
536 | const privateVideo = await server.videos.getWithToken({ id: videoUUID }) | 536 | const privateVideo = await server.videos.getWithToken({ id: videoUUID }) |
537 | const webtorrentFilename = extractFilenameFromUrl(privateVideo.files[0].fileUrl) | 537 | const webVideoFilename = extractFilenameFromUrl(privateVideo.files[0].fileUrl) |
538 | const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl) | 538 | const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl) |
539 | 539 | ||
540 | await makeRawRequest({ | 540 | await makeRawRequest({ |
541 | url: server.url + '/object-storage-proxy/webseed/private/' + webtorrentFilename, | 541 | url: server.url + '/object-storage-proxy/webseed/private/' + webVideoFilename, |
542 | token: server.accessToken, | 542 | token: server.accessToken, |
543 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 543 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
544 | }) | 544 | }) |
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index f837d9966..c4f72bbe4 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts | |||
@@ -41,8 +41,8 @@ async function checkFiles (options: { | |||
41 | playlistBucket: string | 41 | playlistBucket: string |
42 | playlistPrefix?: string | 42 | playlistPrefix?: string |
43 | 43 | ||
44 | webtorrentBucket: string | 44 | webVideoBucket: string |
45 | webtorrentPrefix?: string | 45 | webVideoPrefix?: string |
46 | }) { | 46 | }) { |
47 | const { | 47 | const { |
48 | server, | 48 | server, |
@@ -50,20 +50,20 @@ async function checkFiles (options: { | |||
50 | originSQLCommand, | 50 | originSQLCommand, |
51 | video, | 51 | video, |
52 | playlistBucket, | 52 | playlistBucket, |
53 | webtorrentBucket, | 53 | webVideoBucket, |
54 | baseMockUrl, | 54 | baseMockUrl, |
55 | playlistPrefix, | 55 | playlistPrefix, |
56 | webtorrentPrefix | 56 | webVideoPrefix |
57 | } = options | 57 | } = options |
58 | 58 | ||
59 | let allFiles = video.files | 59 | let allFiles = video.files |
60 | 60 | ||
61 | for (const file of video.files) { | 61 | for (const file of video.files) { |
62 | const baseUrl = baseMockUrl | 62 | const baseUrl = baseMockUrl |
63 | ? `${baseMockUrl}/${webtorrentBucket}/` | 63 | ? `${baseMockUrl}/${webVideoBucket}/` |
64 | : `http://${webtorrentBucket}.${ObjectStorageCommand.getMockEndpointHost()}/` | 64 | : `http://${webVideoBucket}.${ObjectStorageCommand.getMockEndpointHost()}/` |
65 | 65 | ||
66 | const prefix = webtorrentPrefix || '' | 66 | const prefix = webVideoPrefix || '' |
67 | const start = baseUrl + prefix | 67 | const start = baseUrl + prefix |
68 | 68 | ||
69 | expectStartWith(file.fileUrl, start) | 69 | expectStartWith(file.fileUrl, start) |
@@ -134,8 +134,8 @@ function runTestSuite (options: { | |||
134 | playlistBucket: string | 134 | playlistBucket: string |
135 | playlistPrefix?: string | 135 | playlistPrefix?: string |
136 | 136 | ||
137 | webtorrentBucket: string | 137 | webVideoBucket: string |
138 | webtorrentPrefix?: string | 138 | webVideoPrefix?: string |
139 | 139 | ||
140 | useMockBaseUrl?: boolean | 140 | useMockBaseUrl?: boolean |
141 | }) { | 141 | }) { |
@@ -161,7 +161,7 @@ function runTestSuite (options: { | |||
161 | : undefined | 161 | : undefined |
162 | 162 | ||
163 | await objectStorage.createMockBucket(options.playlistBucket) | 163 | await objectStorage.createMockBucket(options.playlistBucket) |
164 | await objectStorage.createMockBucket(options.webtorrentBucket) | 164 | await objectStorage.createMockBucket(options.webVideoBucket) |
165 | 165 | ||
166 | const config = { | 166 | const config = { |
167 | object_storage: { | 167 | object_storage: { |
@@ -182,10 +182,10 @@ function runTestSuite (options: { | |||
182 | }, | 182 | }, |
183 | 183 | ||
184 | videos: { | 184 | videos: { |
185 | bucket_name: options.webtorrentBucket, | 185 | bucket_name: options.webVideoBucket, |
186 | prefix: options.webtorrentPrefix, | 186 | prefix: options.webVideoPrefix, |
187 | base_url: baseMockUrl | 187 | base_url: baseMockUrl |
188 | ? `${baseMockUrl}/${options.webtorrentBucket}` | 188 | ? `${baseMockUrl}/${options.webVideoBucket}` |
189 | : undefined | 189 | : undefined |
190 | } | 190 | } |
191 | } | 191 | } |
@@ -386,27 +386,27 @@ describe('Object storage for videos', function () { | |||
386 | describe('Test simple object storage', function () { | 386 | describe('Test simple object storage', function () { |
387 | runTestSuite({ | 387 | runTestSuite({ |
388 | playlistBucket: objectStorage.getMockBucketName('streaming-playlists'), | 388 | playlistBucket: objectStorage.getMockBucketName('streaming-playlists'), |
389 | webtorrentBucket: objectStorage.getMockBucketName('videos') | 389 | webVideoBucket: objectStorage.getMockBucketName('videos') |
390 | }) | 390 | }) |
391 | }) | 391 | }) |
392 | 392 | ||
393 | describe('Test object storage with prefix', function () { | 393 | describe('Test object storage with prefix', function () { |
394 | runTestSuite({ | 394 | runTestSuite({ |
395 | playlistBucket: objectStorage.getMockBucketName('mybucket'), | 395 | playlistBucket: objectStorage.getMockBucketName('mybucket'), |
396 | webtorrentBucket: objectStorage.getMockBucketName('mybucket'), | 396 | webVideoBucket: objectStorage.getMockBucketName('mybucket'), |
397 | 397 | ||
398 | playlistPrefix: 'streaming-playlists_', | 398 | playlistPrefix: 'streaming-playlists_', |
399 | webtorrentPrefix: 'webtorrent_' | 399 | webVideoPrefix: 'webvideo_' |
400 | }) | 400 | }) |
401 | }) | 401 | }) |
402 | 402 | ||
403 | describe('Test object storage with prefix and base URL', function () { | 403 | describe('Test object storage with prefix and base URL', function () { |
404 | runTestSuite({ | 404 | runTestSuite({ |
405 | playlistBucket: objectStorage.getMockBucketName('mybucket'), | 405 | playlistBucket: objectStorage.getMockBucketName('mybucket'), |
406 | webtorrentBucket: objectStorage.getMockBucketName('mybucket'), | 406 | webVideoBucket: objectStorage.getMockBucketName('mybucket'), |
407 | 407 | ||
408 | playlistPrefix: 'streaming-playlists/', | 408 | playlistPrefix: 'streaming-playlists/', |
409 | webtorrentPrefix: 'webtorrent/', | 409 | webVideoPrefix: 'webvideo/', |
410 | 410 | ||
411 | useMockBaseUrl: true | 411 | useMockBaseUrl: true |
412 | }) | 412 | }) |
@@ -431,7 +431,7 @@ describe('Object storage for videos', function () { | |||
431 | runTestSuite({ | 431 | runTestSuite({ |
432 | maxUploadPart, | 432 | maxUploadPart, |
433 | playlistBucket: objectStorage.getMockBucketName('streaming-playlists'), | 433 | playlistBucket: objectStorage.getMockBucketName('streaming-playlists'), |
434 | webtorrentBucket: objectStorage.getMockBucketName('videos'), | 434 | webVideoBucket: objectStorage.getMockBucketName('videos'), |
435 | fixture | 435 | fixture |
436 | }) | 436 | }) |
437 | }) | 437 | }) |