]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/proxy.ts
Cleanup tests imports
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / proxy.ts
index c40a4f9b8ff75d8bfbb431469ef98975b91b1770..a4151ebdda26d9afd0d639e0f237888137ee1978 100644 (file)
@@ -1,21 +1,20 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
-import { FIXTURE_URLS, MockProxy } from '@server/tests/shared'
+import { expect } from 'chai'
+import { expectNotStartWith, expectStartWith, FIXTURE_URLS, MockProxy } from '@server/tests/shared'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
 import { HttpStatusCode, VideoPrivacy } from '@shared/models'
 import {
   cleanupTests,
   createMultipleServers,
   doubleFollow,
+  ObjectStorageCommand,
   PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel,
   waitJobs
 } from '@shared/server-commands'
 
-const expect = chai.expect
-
 describe('Test proxy', function () {
   let servers: PeerTubeServer[] = []
   let proxy: MockProxy
@@ -96,7 +95,7 @@ describe('Test proxy', function () {
     }
 
     it('Should succeed import with the appropriate proxy config', async function () {
-      this.timeout(40000)
+      this.timeout(120000)
 
       await servers[0].kill()
       await servers[0].run({}, { env: goodEnv })
@@ -111,7 +110,7 @@ describe('Test proxy', function () {
     })
 
     it('Should fail import with a wrong proxy config', async function () {
-      this.timeout(40000)
+      this.timeout(120000)
 
       await servers[0].kill()
       await servers[0].run({}, { env: badEnv })
@@ -120,6 +119,44 @@ describe('Test proxy', function () {
     })
   })
 
+  describe('Object storage', function () {
+    if (areObjectStorageTestsDisabled()) return
+
+    before(async function () {
+      this.timeout(30000)
+
+      await ObjectStorageCommand.prepareDefaultBuckets()
+    })
+
+    it('Should succeed to upload to object storage with the appropriate proxy config', async function () {
+      this.timeout(120000)
+
+      await servers[0].kill()
+      await servers[0].run(ObjectStorageCommand.getDefaultConfig(), { env: goodEnv })
+
+      const { uuid } = await servers[0].videos.quickUpload({ name: 'video' })
+      await waitJobs(servers)
+
+      const video = await servers[0].videos.get({ id: uuid })
+
+      expectStartWith(video.files[0].fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
+    })
+
+    it('Should fail to upload to object storage with a wrong proxy config', async function () {
+      this.timeout(120000)
+
+      await servers[0].kill()
+      await servers[0].run(ObjectStorageCommand.getDefaultConfig(), { env: badEnv })
+
+      const { uuid } = await servers[0].videos.quickUpload({ name: 'video' })
+      await waitJobs(servers)
+
+      const video = await servers[0].videos.get({ id: uuid })
+
+      expectNotStartWith(video.files[0].fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
+    })
+  })
+
   after(async function () {
     await proxy.terminate()