aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
authorChocobozzz <chocobozzz@framasoft.org>2020-11-20 15:36:43 +0100
committerChocobozzz <chocobozzz@framasoft.org>2020-11-20 15:36:43 +0100
commit74fd2643b43057c25558b3da79398efe104e2660 (patch)
tree4fd7dd84775780eed82bc4b3caaa328c3526a14c /server/tests/plugins
parent8f3ad70874f8769f5340632754dc2ca7f4c82733 (diff)
downloadPeerTube-74fd2643b43057c25558b3da79398efe104e2660.tar.gz
PeerTube-74fd2643b43057c25558b3da79398efe104e2660.tar.zst
PeerTube-74fd2643b43057c25558b3da79398efe104e2660.zip
Provide express request to onLogout call
+ pluginInfo related changes
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/external-auth.ts34
1 files changed, 30 insertions, 4 deletions
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 57361be05..6d907cc51 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -73,7 +73,7 @@ describe('Test external auth plugins', function () {
73 server = await flushAndRunServer(1) 73 server = await flushAndRunServer(1)
74 await setAccessTokensToServers([ server ]) 74 await setAccessTokensToServers([ server ])
75 75
76 for (const suffix of [ 'one', 'two' ]) { 76 for (const suffix of [ 'one', 'two', 'three' ]) {
77 await installPlugin({ 77 await installPlugin({
78 url: server.url, 78 url: server.url,
79 accessToken: server.accessToken, 79 accessToken: server.accessToken,
@@ -88,7 +88,7 @@ describe('Test external auth plugins', function () {
88 const config: ServerConfig = res.body 88 const config: ServerConfig = res.body
89 89
90 const auths = config.plugin.registeredExternalAuths 90 const auths = config.plugin.registeredExternalAuths
91 expect(auths).to.have.lengthOf(6) 91 expect(auths).to.have.lengthOf(8)
92 92
93 const auth2 = auths.find((a) => a.authName === 'external-auth-2') 93 const auth2 = auths.find((a) => a.authName === 'external-auth-2')
94 expect(auth2).to.exist 94 expect(auth2).to.exist
@@ -301,7 +301,7 @@ describe('Test external auth plugins', function () {
301 const config: ServerConfig = res.body 301 const config: ServerConfig = res.body
302 302
303 const auths = config.plugin.registeredExternalAuths 303 const auths = config.plugin.registeredExternalAuths
304 expect(auths).to.have.lengthOf(5) 304 expect(auths).to.have.lengthOf(7)
305 305
306 const auth1 = auths.find(a => a.authName === 'external-auth-2') 306 const auth1 = auths.find(a => a.authName === 'external-auth-2')
307 expect(auth1).to.not.exist 307 expect(auth1).to.not.exist
@@ -371,7 +371,7 @@ describe('Test external auth plugins', function () {
371 const config: ServerConfig = res.body 371 const config: ServerConfig = res.body
372 372
373 const auths = config.plugin.registeredExternalAuths 373 const auths = config.plugin.registeredExternalAuths
374 expect(auths).to.have.lengthOf(4) 374 expect(auths).to.have.lengthOf(6)
375 375
376 const auth2 = auths.find((a) => a.authName === 'external-auth-2') 376 const auth2 = auths.find((a) => a.authName === 'external-auth-2')
377 expect(auth2).to.not.exist 377 expect(auth2).to.not.exist
@@ -380,4 +380,30 @@ describe('Test external auth plugins', function () {
380 after(async function () { 380 after(async function () {
381 await cleanupTests([ server ]) 381 await cleanupTests([ server ])
382 }) 382 })
383
384 it('Should forward the redirectUrl if the plugin returns one', async function () {
385 const resLogin = await loginExternal({
386 server,
387 npmName: 'test-external-auth-three',
388 authName: 'external-auth-7',
389 username: 'cid'
390 })
391
392 const resLogout = await logout(server.url, resLogin.access_token)
393
394 expect(resLogout.body.redirectUrl).to.equal('https://example.com/redirectUrl')
395 })
396
397 it('Should call the plugin\'s onLogout method with the request', async function () {
398 const resLogin = await loginExternal({
399 server,
400 npmName: 'test-external-auth-three',
401 authName: 'external-auth-8',
402 username: 'cid'
403 })
404
405 const resLogout = await logout(server.url, resLogin.access_token)
406
407 expect(resLogout.body.redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token)
408 })
383}) 409})