From b25f35897ae365bf7f14de2fb8c0f34415c0ad84 Mon Sep 17 00:00:00 2001 From: Ben Francis Date: Tue, 6 Aug 2024 21:13:37 +0100 Subject: [PATCH] Add integration test --- src/test/integration/oauth-test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/integration/oauth-test.ts b/src/test/integration/oauth-test.ts index a86f1aed5..b25a8e3d3 100644 --- a/src/test/integration/oauth-test.ts +++ b/src/test/integration/oauth-test.ts @@ -162,6 +162,27 @@ describe('oauth/', function () { customCallbackHandler = customCallbackHandlerProvided || null; } + it('serves OAuth metadata', async () => { + const res = await chai + .request(server) + .keepOpen() + .get('/.well-known/oauth-authorization-server') + .set('Accept', 'application/json'); + expect(res.status).toEqual(200); + expect(res.body).toHaveProperty('issuer'); + expect(res.body).toHaveProperty('authorization_endpoint'); + expect(res.body.authorization_endpoint).toEqual(expect.stringContaining('authorize')); + expect(res.body).toHaveProperty('token_endpoint'); + expect(res.body.token_endpoint).toEqual(expect.stringContaining('token')); + expect(res.body).toHaveProperty('response_types_supported'); + expect(res.body.response_types_supported.length).toEqual(1); + expect(res.body.response_types_supported[0]).toEqual('code'); + expect(res.body).toHaveProperty('scopes_supported'); + expect(res.body.scopes_supported.length).toEqual(2); + expect(res.body.scopes_supported).toContain('/things'); + expect(res.body.scopes_supported).toContain('/things:readwrite'); + }); + it('rejects request with no JWT', async () => { setupOAuth();