From 648961d640bfc92d8c7f013a8406aa33c2dcaf31 Mon Sep 17 00:00:00 2001 From: Roman Dmytrenko Date: Tue, 10 Dec 2024 23:29:50 +0200 Subject: [PATCH 1/2] fix: remove default namespace as a requirement to list namespaces v2 Ninja has more tricks :( Signed-off-by: Roman Dmytrenko --- rpc/flipt/request.go | 8 +++++++- rpc/flipt/request_test.go | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rpc/flipt/request.go b/rpc/flipt/request.go index 94fe0fde7..0429b4d75 100644 --- a/rpc/flipt/request.go +++ b/rpc/flipt/request.go @@ -49,6 +49,12 @@ type Request struct { Status Status `json:"status"` } +func WithNoNamespace() func(*Request) { + return func(r *Request) { + r.Namespace = "" + } +} + func WithNamespace(ns string) func(*Request) { return func(r *Request) { if ns != "" { @@ -98,7 +104,7 @@ func (req *GetNamespaceRequest) Request() []Request { } func (req *ListNamespaceRequest) Request() []Request { - return []Request{NewRequest(ResourceNamespace, ActionRead, WithNamespace(""))} + return []Request{NewRequest(ResourceNamespace, ActionRead, WithNoNamespace())} } func (req *CreateNamespaceRequest) Request() []Request { diff --git a/rpc/flipt/request_test.go b/rpc/flipt/request_test.go index b630ae488..fec2e4c56 100644 --- a/rpc/flipt/request_test.go +++ b/rpc/flipt/request_test.go @@ -8,5 +8,7 @@ import ( func TestListNamespaceRequest_Request(t *testing.T) { req := &ListNamespaceRequest{} - assert.Equal(t, []Request{NewRequest(ResourceNamespace, ActionRead)}, req.Request()) + expected := NewRequest(ResourceNamespace, ActionRead) + expected.Namespace = "" + assert.Equal(t, []Request{expected}, req.Request()) } From 81edf653e48cbf836616382c7b3abc6b03a60aa6 Mon Sep 17 00:00:00 2001 From: Roman Dmytrenko Date: Fri, 13 Dec 2024 00:05:18 +0200 Subject: [PATCH 2/2] research the issues with tests Signed-off-by: Roman Dmytrenko --- build/testing/integration/authz/auth.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/testing/integration/authz/auth.go b/build/testing/integration/authz/auth.go index 95076ae54..14a8e6546 100644 --- a/build/testing/integration/authz/auth.go +++ b/build/testing/integration/authz/auth.go @@ -281,6 +281,9 @@ func (s clientCallSet) assert(t *testing.T, ctx context.Context, client sdk.SDK) type clientCall func(*testing.T, context.Context, sdk.SDK) error func GetNamespace(in *flipt.GetNamespaceRequest) clientCall { + if in.GetNamespaceKey() == "" { + in.Key = "default" + } return func(t *testing.T, ctx context.Context, s sdk.SDK) error { _, err := s.Flipt().GetNamespace(ctx, in) return fmt.Errorf("GetNamespace: %w", err) @@ -434,6 +437,7 @@ func CreateRollout(in *flipt.CreateRolloutRequest) clientCall { return fmt.Errorf("CreateRollout: %w", err) } } + func UpdateRollout(in *flipt.UpdateRolloutRequest) clientCall { return func(t *testing.T, ctx context.Context, s sdk.SDK) error { _, err := s.Flipt().UpdateRollout(ctx, in)