3
0

Fix tests for AuthClient

Added meta.name to test to avoid, missing error
This commit is contained in:
Vivek Patel
2023-02-22 14:53:29 +05:30
parent 76d8212e10
commit e8b6117fe5
2 changed files with 6 additions and 4 deletions

View File

@@ -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()
}

View File

@@ -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")