From 74fd2643b43057c25558b3da79398efe104e2660 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 20 Nov 2020 15:36:43 +0100 Subject: Provide express request to onLogout call + pluginInfo related changes --- server/tests/plugins/external-auth.ts | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'server/tests/plugins/external-auth.ts') 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 () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - for (const suffix of [ 'one', 'two' ]) { + for (const suffix of [ 'one', 'two', 'three' ]) { await installPlugin({ url: server.url, accessToken: server.accessToken, @@ -88,7 +88,7 @@ describe('Test external auth plugins', function () { const config: ServerConfig = res.body const auths = config.plugin.registeredExternalAuths - expect(auths).to.have.lengthOf(6) + expect(auths).to.have.lengthOf(8) const auth2 = auths.find((a) => a.authName === 'external-auth-2') expect(auth2).to.exist @@ -301,7 +301,7 @@ describe('Test external auth plugins', function () { const config: ServerConfig = res.body const auths = config.plugin.registeredExternalAuths - expect(auths).to.have.lengthOf(5) + expect(auths).to.have.lengthOf(7) const auth1 = auths.find(a => a.authName === 'external-auth-2') expect(auth1).to.not.exist @@ -371,7 +371,7 @@ describe('Test external auth plugins', function () { const config: ServerConfig = res.body const auths = config.plugin.registeredExternalAuths - expect(auths).to.have.lengthOf(4) + expect(auths).to.have.lengthOf(6) const auth2 = auths.find((a) => a.authName === 'external-auth-2') expect(auth2).to.not.exist @@ -380,4 +380,30 @@ describe('Test external auth plugins', function () { after(async function () { await cleanupTests([ server ]) }) + + it('Should forward the redirectUrl if the plugin returns one', async function () { + const resLogin = await loginExternal({ + server, + npmName: 'test-external-auth-three', + authName: 'external-auth-7', + username: 'cid' + }) + + const resLogout = await logout(server.url, resLogin.access_token) + + expect(resLogout.body.redirectUrl).to.equal('https://example.com/redirectUrl') + }) + + it('Should call the plugin\'s onLogout method with the request', async function () { + const resLogin = await loginExternal({ + server, + npmName: 'test-external-auth-three', + authName: 'external-auth-8', + username: 'cid' + }) + + const resLogout = await logout(server.url, resLogin.access_token) + + expect(resLogout.body.redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token) + }) }) -- cgit v1.2.3