From 8b306a40bcfe409e57233c18a90284aa92ff3119 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Thu, 30 Nov 2023 20:02:09 +0000 Subject: [PATCH] feat: add system key not found error --- internal/authenticator/builder_test.go | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/authenticator/builder_test.go b/internal/authenticator/builder_test.go index 1d377d5..cf7a4e8 100644 --- a/internal/authenticator/builder_test.go +++ b/internal/authenticator/builder_test.go @@ -47,3 +47,40 @@ func TestBuilderInternalAuthenticator(t *testing.T) { require.Len(vendors, 1) require.Contains(vendors, "internal") } + +func TestBuilderInternalAuthenticatorWithInvalidKey(t *testing.T) { + t.Parallel() + + require := require.New(t) + + b := authenticator.Builder{ + Vendors: []config.Vendor{ + { + Company: "internal", + Jwt: config.Jwt{ + IssName: "iss", + SubName: "sub", + SigningMethod: "HS512", + }, + IsInternal: true, + UseValidator: false, + AllowedAccessTypes: nil, + Topics: nil, + HashIDMap: nil, + IssEntityMap: nil, + IssPeerMap: nil, + Keys: map[string]string{ + "not-system": "c2VjcmV0", + }, + }, + }, + Logger: zap.NewNop(), + ValidatorConfig: config.Validator{ + URL: "", + Timeout: 0, + }, + } + + _, err := b.Authenticators() + require.ErrorIs(err, authenticator.ErrAdminAuthenticatorSystemKey) +}