Skip to content

Commit

Permalink
Fix util test PKI options
Browse files Browse the repository at this point in the history
Signed-off-by: joshvanl <me@joshvanl.dev>
  • Loading branch information
JoshVanL committed Nov 28, 2023
1 parent abe8b80 commit f35c9f2
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405
google.golang.org/grpc v1.59.0
google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.26.9
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestProcessComponentSecrets(t *testing.T) {
func TestComponentUpdate(t *testing.T) {
appID := spiffeid.RequireFromString("spiffe://example.org/ns/ns1/app1")
serverID := spiffeid.RequireFromString("spiffe://example.org/ns/dapr-system/dapr-operator")
pki := util.GenPKI(t, util.Options{
pki := util.GenPKI(t, util.PKIOptions{
LeafID: serverID,
ClientID: appID,
})
Expand Down Expand Up @@ -317,7 +317,7 @@ func TestComponentUpdate(t *testing.T) {
func TestHTTPEndpointUpdate(t *testing.T) {
appID := spiffeid.RequireFromString("spiffe://example.org/ns/ns1/app1")
serverID := spiffeid.RequireFromString("spiffe://example.org/ns/dapr-system/dapr-operator")
pki := util.GenPKI(t, util.Options{
pki := util.GenPKI(t, util.PKIOptions{
LeafID: serverID,
ClientID: appID,
})
Expand Down Expand Up @@ -411,7 +411,7 @@ func TestHTTPEndpointUpdate(t *testing.T) {
func TestListsNamespaced(t *testing.T) {
appID := spiffeid.RequireFromString("spiffe://example.org/ns/namespace-a/app1")
serverID := spiffeid.RequireFromString("spiffe://example.org/ns/dapr-system/dapr-operator")
pki := util.GenPKI(t, util.Options{
pki := util.GenPKI(t, util.PKIOptions{
LeafID: serverID,
ClientID: appID,
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/api/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
func Test_authzRequest(t *testing.T) {
appID := spiffeid.RequireFromString("spiffe://example.org/ns/ns1/app1")
serverID := spiffeid.RequireFromString("spiffe://example.org/ns/dapr-system/dapr-operator")
pki := util.GenPKI(t, util.Options{LeafID: serverID, ClientID: appID})
pki := util.GenPKI(t, util.PKIOptions{LeafID: serverID, ClientID: appID})

t.Run("no auth context should error", func(t *testing.T) {
err := new(apiServer).authzRequest(context.Background(), "ns1")
Expand All @@ -50,7 +50,7 @@ func Test_authzRequest(t *testing.T) {

t.Run("invalid SPIFFE path should error", func(t *testing.T) {
appID := spiffeid.RequireFromString("spiffe://example.org/foo/bar")
pki2 := util.GenPKI(t, util.Options{LeafID: serverID, ClientID: appID})
pki2 := util.GenPKI(t, util.PKIOptions{LeafID: serverID, ClientID: appID})
err := new(apiServer).authzRequest(pki2.ClientGRPCCtx(t), "ns1")
assert.Error(t, err)
assert.Equal(t, codes.PermissionDenied, status.Code(err))
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/service_invocation/service_invocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func TestMain(m *testing.M) {
utils.SetupLogs("service_invocation")
utils.InitHTTPClient(false)

pki, err := util.GenPKI("service-invocation-external")
pki, err := util.GenPKI(t, util.PKIOptions{

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.23.13, ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.23.13, ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.23.13, ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.23.13, ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, non-ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, non-ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, non-ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.24.7, non-ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, non-ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, non-ha)

undefined: t

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, non-ha)

assignment mismatch: 2 variables but util.GenPKI returns 1 value

Check failure on line 83 in tests/e2e/service_invocation/service_invocation_test.go

View workflow job for this annotation

GitHub Actions / e2e (v1.25.3, non-ha)

undefined: t
LeafDNS: "service-invocation-external",
})
if err != nil {
fmt.Println(err)
os.Exit(-1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type httpendpoints struct {
}

func (h *httpendpoints) Setup(t *testing.T) []framework.Option {
pki1 := testsutil.GenPKI(t, testsutil.Options{LeafDNS: "localhost"})
pki2 := testsutil.GenPKI(t, testsutil.Options{LeafDNS: "localhost"})
pki1 := testsutil.GenPKI(t, testsutil.PKIOptions{LeafDNS: "localhost"})
pki2 := testsutil.GenPKI(t, testsutil.PKIOptions{LeafDNS: "localhost"})

newHTTPServer := func() *prochttp.HTTP {
handler := http.NewServeMux()
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/suite/operator/api/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func init() {
suite.Register(new(authz))
}

// authz tests the authz of the operator API
// authz tests the authz of the operator API which is based on client request
// namespace.
type authz struct {
sentry *procsentry.Sentry
kubeapi *kubernetes.Kubernetes
Expand Down
4 changes: 2 additions & 2 deletions tests/util/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"google.golang.org/grpc/peer"
)

type Options struct {
type PKIOptions struct {
LeafDNS string
LeafID spiffeid.ID
ClientDNS string
Expand All @@ -62,7 +62,7 @@ type PKI struct {
clientID spiffeid.ID
}

func GenPKI(t *testing.T, opts Options) PKI {
func GenPKI(t *testing.T, opts PKIOptions) PKI {
t.Helper()

rootPK, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
Expand Down

0 comments on commit f35c9f2

Please sign in to comment.