From a9bfa85d2cdf13670aaced740da5b493fbeddfce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Dec 2021 15:58:10 +0100 Subject: Add ability for admins to set default p2p policy --- server/tests/api/server/config-defaults.ts | 69 ++++++++++++++++++++++++------ server/tests/api/server/follows.ts | 2 +- server/tests/api/users/users.ts | 22 ++++++++++ 3 files changed, 80 insertions(+), 13 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/server/config-defaults.ts b/server/tests/api/server/config-defaults.ts index 3dff7bfb7..340d4b44b 100644 --- a/server/tests/api/server/config-defaults.ts +++ b/server/tests/api/server/config-defaults.ts @@ -21,18 +21,7 @@ describe('Test config defaults', function () { before(async function () { this.timeout(30000) - const overrideConfig = { - defaults: { - publish: { - comments_enabled: false, - download_enabled: false, - privacy: VideoPrivacy.INTERNAL, - licence: 4 - } - } - } - - server = await createSingleServer(1, overrideConfig) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) @@ -40,6 +29,23 @@ describe('Test config defaults', function () { }) describe('Default publish values', function () { + + before(async function () { + const overrideConfig = { + defaults: { + publish: { + comments_enabled: false, + download_enabled: false, + privacy: VideoPrivacy.INTERNAL, + licence: 4 + } + } + } + + await server.kill() + await server.run(overrideConfig) + }) + const attributes = { name: 'video', downloadEnabled: undefined, @@ -117,6 +123,45 @@ describe('Test config defaults', function () { }) }) + describe('Default P2P values', function () { + + before(async function () { + const overrideConfig = { + defaults: { + p2p: { + enabled: false + } + } + } + + await server.kill() + await server.run(overrideConfig) + }) + + it('Should not have P2P enabled', async function () { + const config = await server.config.getConfig() + + expect(config.defaults.p2p.enabled).to.be.false + }) + + it('Should create a user with this default setting', async function () { + await server.users.create({ username: 'user_p2p_1' }) + const userToken = await server.login.getAccessToken('user_p2p_1') + + const { p2pEnabled } = await server.users.getMyInfo({ token: userToken }) + expect(p2pEnabled).to.be.false + }) + + it('Should register a user with this default setting', async function () { + await server.users.register({ username: 'user_p2p_2' }) + + const userToken = await server.login.getAccessToken('user_p2p_2') + + const { p2pEnabled } = await server.users.getMyInfo({ token: userToken }) + expect(p2pEnabled).to.be.false + }) + }) + after(async function () { await cleanupTests([ server ]) }) diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 748f4cd35..c132d99ea 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts @@ -292,7 +292,7 @@ describe('Test follows', function () { }) it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { - this.timeout(60000) + this.timeout(120000) await servers[1].videos.upload({ attributes: { name: 'server2' } }) await servers[2].videos.upload({ attributes: { name: 'server3' } }) diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 6c41e7d56..f00cbab5a 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -559,6 +559,28 @@ describe('Test users', function () { expect(user.autoPlayNextVideo).to.be.true }) + it('Should be able to change the p2p attribute', async function () { + { + await server.users.updateMe({ + token: userToken, + webTorrentEnabled: false + }) + + const user = await server.users.getMyInfo({ token: userToken }) + expect(user.p2pEnabled).to.be.false + } + + { + await server.users.updateMe({ + token: userToken, + p2pEnabled: true + }) + + const user = await server.users.getMyInfo({ token: userToken }) + expect(user.p2pEnabled).to.be.true + } + }) + it('Should be able to change the email attribute', async function () { await server.users.updateMe({ token: userToken, -- cgit v1.2.3