From c18b8526cc45d5d16dddd4e6e4b3e21cdf6cc11b Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Thu, 24 Jun 2021 16:51:23 +0200 Subject: [PATCH] fix: Correctly render internal IDP errors --- src/identity/IdentityProviderFactory.ts | 2 ++ test/integration/Identity.test.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/identity/IdentityProviderFactory.ts b/src/identity/IdentityProviderFactory.ts index 35d2e5f52..57fec0d98 100644 --- a/src/identity/IdentityProviderFactory.ts +++ b/src/identity/IdentityProviderFactory.ts @@ -84,6 +84,8 @@ export class IdentityProviderFactory { }, renderError: async(ctx: KoaContextWithOIDC, out: ErrorOut, error: Error): Promise => { + // This allows us to stream directly to to the response object, see https://github.com/koajs/koa/issues/944 + ctx.respond = false; const preferences: RepresentationPreferences = { type: { 'text/plain': 1 }}; const result = await this.errorHandler.handleSafe({ error, preferences }); await this.responseWriter.handleSafe({ response: ctx.res, result }); diff --git a/test/integration/Identity.test.ts b/test/integration/Identity.test.ts index 8f805b344..247857d49 100644 --- a/test/integration/Identity.test.ts +++ b/test/integration/Identity.test.ts @@ -335,13 +335,20 @@ describe('A Solid server with IDP', (): void => { }); }); - describe('openid-configuration', (): void => { - it('should contain solid_oidc_supported key.', async(): Promise => { + describe('setup', (): void => { + it('should contain the required configuration keys.', async(): Promise => { const res = await fetch(`${baseUrl}.well-known/openid-configuration`); const jsonBody = await res.json(); expect(res.status).toBe(200); + // https://solid.github.io/authentication-panel/solid-oidc/#discovery expect(jsonBody.solid_oidc_supported).toEqual('https://solidproject.org/TR/solid-oidc'); }); + + it('should return correct error output.', async(): Promise => { + const res = await fetch(`${baseUrl}idp/auth`); + expect(res.status).toBe(400); + await expect(res.text()).resolves.toContain('InvalidRequest: invalid_request'); + }); }); });