From e8b6117fe5375dca749c7060ea49882814951076 Mon Sep 17 00:00:00 2001 From: Vivek Patel Date: Wed, 22 Feb 2023 14:53:29 +0530 Subject: [PATCH] Fix tests for AuthClient Added meta.name to test to avoid, missing error --- server/system/service/auth_client.go | 8 ++++---- server/tests/system/auth_client_test.go | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/system/service/auth_client.go b/server/system/service/auth_client.go index 942e1f167..c1033127b 100644 --- a/server/system/service/auth_client.go +++ b/server/system/service/auth_client.go @@ -137,9 +137,9 @@ func (svc *authClient) Search(ctx context.Context, af types.AuthClientFilter) (a // // not the best solution but ATM it allows us to have at least // some kind of control over who can see deleted authClients - //if !svc.ac.CanAccess(ctx) { + // if !svc.ac.CanAccess(ctx) { // return AuthClientErrNotAllowedToListAuthClients() - //} + // } } if len(af.Labels) > 0 { @@ -187,7 +187,7 @@ func (svc *authClient) Create(ctx context.Context, new *types.AuthClient) (res * ) err = func() (err error) { - if new.Meta.Name == "" { + if new.Meta == nil || new.Meta.Name == "" { return AuthClientErrMissingName() } @@ -264,7 +264,7 @@ func (svc *authClient) Update(ctx context.Context, upd *types.AuthClient) (res * if upd.ID == 0 { return AuthClientErrInvalidID() } - if upd.Meta.Name == "" { + if upd.Meta == nil || upd.Meta.Name == "" { return AuthClientErrMissingName() } diff --git a/server/tests/system/auth_client_test.go b/server/tests/system/auth_client_test.go index fa56b38b7..05e21b40c 100644 --- a/server/tests/system/auth_client_test.go +++ b/server/tests/system/auth_client_test.go @@ -95,6 +95,7 @@ func TestAuthClientCreate(t *testing.T) { h.apiInit(). Post("/auth/clients/"). Header("Accept", "application/json"). + FormData("meta", fmt.Sprintf(`{"name": "%s"}`, rs())). FormData("handle", handle). FormData("scope", "profile api"). Expect(t). @@ -112,6 +113,7 @@ func TestAuthClientUpdate(t *testing.T) { h.clearAuthClients() client := h.repoMakeAuthClient() + client.Meta = &types.AuthClientMeta{Name: rs()} client.Handle = rs() helpers.AllowMe(h, types.AuthClientRbacResource(0), "update")