From a4995eb7ac5745f62604d70f7b2225ff33916d49 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 30 Apr 2020 10:03:09 +0200 Subject: Add ability to unregister plugin auths --- server/tests/plugins/external-auth.ts | 38 +++++++++++++++++++++++++++++++- server/tests/plugins/id-and-pass-auth.ts | 26 +++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) (limited to 'server/tests/plugins') diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index a72b2829b..312561538 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts @@ -16,7 +16,9 @@ import { setAccessTokensToServers, uninstallPlugin, updateMyUser, - wait + wait, + userLogin, + updatePluginSettings } from '../../../shared/extra-utils' import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' @@ -258,6 +260,40 @@ describe('Test external auth plugins', function () { await getMyUserInformation(server.url, kefkaAccessToken, 401) }) + it('Should unregister external-auth-2 and do not login existing Kefka', async function () { + await updatePluginSettings({ + url: server.url, + accessToken: server.accessToken, + npmName: 'peertube-plugin-test-external-auth-one', + settings: { disableKefka: true } + }) + + await userLogin(server, { username: 'kefka', password: 'fake' }, 400) + + await loginExternal({ + server, + npmName: 'test-external-auth-one', + authName: 'external-auth-2', + query: { + username: 'kefka' + }, + username: 'kefka', + statusCodeExpected: 404 + }) + }) + + it('Should have disabled this auth', async function () { + const res = await getConfig(server.url) + + const config: ServerConfig = res.body + + const auths = config.plugin.registeredExternalAuths + expect(auths).to.have.lengthOf(2) + + const auth1 = auths.find(a => a.authName === 'external-auth-2') + expect(auth1).to.not.exist + }) + it('Should uninstall the plugin one and do not login Cyan', async function () { await uninstallPlugin({ url: server.url, diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 6c10730aa..97df4c1fd 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts @@ -12,7 +12,7 @@ import { updateMyUser, userLogin, wait, - login, refreshToken, getConfig + login, refreshToken, getConfig, updatePluginSettings } from '../../../shared/extra-utils' import { User, UserRole, ServerConfig } from '@shared/models' import { expect } from 'chai' @@ -179,6 +179,30 @@ describe('Test id and pass auth plugins', function () { await waitUntilLog(server, 'valid email') }) + it('Should unregister spyro-auth and do not login existing Spyro', async function () { + await updatePluginSettings({ + url: server.url, + accessToken: server.accessToken, + npmName: 'peertube-plugin-test-id-pass-auth-one', + settings: { disableSpyro: true } + }) + + await userLogin(server, { username: 'spyro', password: 'spyro password' }, 400) + await userLogin(server, { username: 'spyro', password: 'fake' }, 400) + }) + + it('Should have disabled this auth', async function () { + const res = await getConfig(server.url) + + const config: ServerConfig = res.body + + const auths = config.plugin.registeredIdAndPassAuths + expect(auths).to.have.lengthOf(7) + + const spyroAuth = auths.find(a => a.authName === 'spyro-auth') + expect(spyroAuth).to.not.exist + }) + it('Should uninstall the plugin one and do not login existing Crash', async function () { await uninstallPlugin({ url: server.url, -- cgit v1.2.3