aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-30 10:03:09 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commita4995eb7ac5745f62604d70f7b2225ff33916d49 (patch)
tree2dbed723d3f5a539e8f0847d914723cd7543b1b2 /server/tests/plugins
parente9b0fa5c16ca196a3ba3267af4008782a3e86875 (diff)
downloadPeerTube-a4995eb7ac5745f62604d70f7b2225ff33916d49.tar.gz
PeerTube-a4995eb7ac5745f62604d70f7b2225ff33916d49.tar.zst
PeerTube-a4995eb7ac5745f62604d70f7b2225ff33916d49.zip
Add ability to unregister plugin auths
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/external-auth.ts38
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts26
2 files changed, 62 insertions, 2 deletions
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 {
16 setAccessTokensToServers, 16 setAccessTokensToServers,
17 uninstallPlugin, 17 uninstallPlugin,
18 updateMyUser, 18 updateMyUser,
19 wait 19 wait,
20 userLogin,
21 updatePluginSettings
20} from '../../../shared/extra-utils' 22} from '../../../shared/extra-utils'
21import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' 23import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
22 24
@@ -258,6 +260,40 @@ describe('Test external auth plugins', function () {
258 await getMyUserInformation(server.url, kefkaAccessToken, 401) 260 await getMyUserInformation(server.url, kefkaAccessToken, 401)
259 }) 261 })
260 262
263 it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
264 await updatePluginSettings({
265 url: server.url,
266 accessToken: server.accessToken,
267 npmName: 'peertube-plugin-test-external-auth-one',
268 settings: { disableKefka: true }
269 })
270
271 await userLogin(server, { username: 'kefka', password: 'fake' }, 400)
272
273 await loginExternal({
274 server,
275 npmName: 'test-external-auth-one',
276 authName: 'external-auth-2',
277 query: {
278 username: 'kefka'
279 },
280 username: 'kefka',
281 statusCodeExpected: 404
282 })
283 })
284
285 it('Should have disabled this auth', async function () {
286 const res = await getConfig(server.url)
287
288 const config: ServerConfig = res.body
289
290 const auths = config.plugin.registeredExternalAuths
291 expect(auths).to.have.lengthOf(2)
292
293 const auth1 = auths.find(a => a.authName === 'external-auth-2')
294 expect(auth1).to.not.exist
295 })
296
261 it('Should uninstall the plugin one and do not login Cyan', async function () { 297 it('Should uninstall the plugin one and do not login Cyan', async function () {
262 await uninstallPlugin({ 298 await uninstallPlugin({
263 url: server.url, 299 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 {
12 updateMyUser, 12 updateMyUser,
13 userLogin, 13 userLogin,
14 wait, 14 wait,
15 login, refreshToken, getConfig 15 login, refreshToken, getConfig, updatePluginSettings
16} from '../../../shared/extra-utils' 16} from '../../../shared/extra-utils'
17import { User, UserRole, ServerConfig } from '@shared/models' 17import { User, UserRole, ServerConfig } from '@shared/models'
18import { expect } from 'chai' 18import { expect } from 'chai'
@@ -179,6 +179,30 @@ describe('Test id and pass auth plugins', function () {
179 await waitUntilLog(server, 'valid email') 179 await waitUntilLog(server, 'valid email')
180 }) 180 })
181 181
182 it('Should unregister spyro-auth and do not login existing Spyro', async function () {
183 await updatePluginSettings({
184 url: server.url,
185 accessToken: server.accessToken,
186 npmName: 'peertube-plugin-test-id-pass-auth-one',
187 settings: { disableSpyro: true }
188 })
189
190 await userLogin(server, { username: 'spyro', password: 'spyro password' }, 400)
191 await userLogin(server, { username: 'spyro', password: 'fake' }, 400)
192 })
193
194 it('Should have disabled this auth', async function () {
195 const res = await getConfig(server.url)
196
197 const config: ServerConfig = res.body
198
199 const auths = config.plugin.registeredIdAndPassAuths
200 expect(auths).to.have.lengthOf(7)
201
202 const spyroAuth = auths.find(a => a.authName === 'spyro-auth')
203 expect(spyroAuth).to.not.exist
204 })
205
182 it('Should uninstall the plugin one and do not login existing Crash', async function () { 206 it('Should uninstall the plugin one and do not login existing Crash', async function () {
183 await uninstallPlugin({ 207 await uninstallPlugin({
184 url: server.url, 208 url: server.url,