From dd6f833951d919d10a56e257ad22a7bd616a28ec Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 26 Apr 2024 07:44:44 +0200 Subject: [PATCH] fix(authz): build authz object without using constructor --- internal/utils/authz/middleware_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/utils/authz/middleware_test.go b/internal/utils/authz/middleware_test.go index 0dd4ce49..54ef7e4b 100644 --- a/internal/utils/authz/middleware_test.go +++ b/internal/utils/authz/middleware_test.go @@ -5,6 +5,7 @@ import ( "context" "path/filepath" "testing" + "time" "net/http" "net/http/httptest" @@ -13,6 +14,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/padok-team/burrito/internal/utils/authz" + "github.com/patrickmn/go-cache" v1 "k8s.io/api/authentication/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -71,13 +73,15 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) Expect(err).NotTo(HaveOccurred()) + Client, err = client.NewForConfig(cfg) - Authz = authz.NewAuthz() + Authz = &authz.Authz{ + Cache: cache.New(5*time.Minute, 10*time.Minute), + Client: *Client, + Audience: "datastore", + } Expect(err).NotTo(HaveOccurred()) - Client, err = client.NewForConfig(cfg) Expect(err).NotTo(HaveOccurred()) - Authz.Client = *Client - Authz.SetAudience("datastore") Authz.AddServiceAccount("default", "authorized") createServiceAccount("default", "unauthorized") createServiceAccount("default", "authorized")