X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Fproxy.ts;h=e238edaf42c3a5e62238113a20a04a9ddb1db7e8;hb=073deef8862f462de5f159a57877ef415ebe4c69;hp=626a0d860308fcf7ba6db4242052f7b56820ab3f;hpb=bf54587a3e2ad9c2c186828f2a5682b91ee2cc00;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.ts index 626a0d860..e238edaf4 100644 --- a/server/tests/api/server/proxy.ts +++ b/server/tests/api/server/proxy.ts @@ -2,18 +2,19 @@ import 'mocha' import * as chai 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, - FIXTURE_URLS, + ObjectStorageCommand, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, waitJobs } from '@shared/server-commands' -import { MockProxy } from '@shared/server-commands/mock-servers/mock-proxy' -import { HttpStatusCode, VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -97,7 +98,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 }) @@ -112,7 +113,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 }) @@ -121,6 +122,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()