Skip to content

Commit

Permalink
fix(authz): build authz object without using constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan-pad committed Apr 26, 2024
1 parent aa81769 commit dd6f833
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/utils/authz/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"path/filepath"
"testing"
"time"

"net/http"
"net/http/httptest"
Expand All @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit dd6f833

Please sign in to comment.