From 71e410bf73711a6532512f967373a855bf3d6898 Mon Sep 17 00:00:00 2001 From: Agustin Mendez Date: Mon, 26 Apr 2021 13:17:41 -0300 Subject: [PATCH] fix: invalid tokens were not being rejected --- src/index.ts | 2 +- test/authentication.spec.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 725c454..3d66a19 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,7 +60,7 @@ export async function createMetricsComponent { const res = await fetch.fetch("/a/metrics", { headers: { authorization: "Bearer asd" } }) expect(res.status).toEqual(200) }) + + it("responds the /a/metrics endpoint with 401 with invalid token", async () => { + const { fetch } = getComponents() + const res = await fetch.fetch("/a/metrics", { headers: { authorization: "Bearer xxxxxxxxx" } }) + expect(res.status).toEqual(401) + }) })