From 0e3355677551a14b59b727da8f3110163599d39d Mon Sep 17 00:00:00 2001 From: TwiN Date: Sat, 8 Jul 2023 21:26:53 -0400 Subject: [PATCH] test(security): Make sure router behaves as intended when authn is required --- api/api_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/api/api_test.go b/api/api_test.go index ab4f16ce..c8fdcd70 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -67,6 +67,30 @@ func TestNew(t *testing.T) { Path: "/index.html", ExpectedCode: fiber.StatusMovedPermanently, }, + { + Name: "index-should-return-200-even-if-not-authenticated", + Path: "/", + ExpectedCode: fiber.StatusOK, + WithSecurity: true, + }, + { + Name: "endpoints-should-return-401-if-not-authenticated", + Path: "/api/v1/endpoints/statuses", + ExpectedCode: fiber.StatusUnauthorized, + WithSecurity: true, + }, + { + Name: "config-should-return-200-even-if-not-authenticated", + Path: "/api/v1/config", + ExpectedCode: fiber.StatusOK, + WithSecurity: true, + }, + { + Name: "config-should-always-return-200", + Path: "/api/v1/config", + ExpectedCode: fiber.StatusOK, + WithSecurity: false, + }, } for _, scenario := range scenarios { t.Run(scenario.Name, func(t *testing.T) {