Skip to content

Commit

Permalink
MG-2363 - Fix users with member relation being able to list things (#…
Browse files Browse the repository at this point in the history
…2364)

Signed-off-by: nyagamunene <[email protected]>
  • Loading branch information
nyagamunene authored Jul 30, 2024
1 parent 06cb004 commit 38386a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion things/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ func (svc service) ListClients(ctx context.Context, token, reqUserID string, pm
}
}

if len(ids) == 0 && pm.Domain == "" {
return mgclients.ClientsPage{}, nil
}
pm.IDs = ids

tp, err := svc.clients.SearchClients(ctx, pm)
if err != nil {
return mgclients.ClientsPage{}, errors.Wrap(svcerr.ErrViewEntity, err)
Expand Down
6 changes: 6 additions & 0 deletions things/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ func TestListClients(t *testing.T) {
Offset: 0,
Limit: 100,
ListPerms: true,
Domain: domainID,
},
identifyResponse: &magistrala.IdentityRes{Id: nonAdminID, UserId: nonAdminID, DomainId: domainID},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
Expand Down Expand Up @@ -703,6 +704,7 @@ func TestListClients(t *testing.T) {
Offset: 0,
Limit: 100,
ListPerms: true,
Domain: domainID,
},
identifyResponse: &magistrala.IdentityRes{Id: nonAdminID, UserId: nonAdminID, DomainId: domainID},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: false},
Expand All @@ -717,6 +719,7 @@ func TestListClients(t *testing.T) {
Offset: 0,
Limit: 100,
ListPerms: true,
Domain: domainID,
},
identifyResponse: &magistrala.IdentityRes{Id: nonAdminID, UserId: nonAdminID, DomainId: domainID},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
Expand All @@ -735,6 +738,7 @@ func TestListClients(t *testing.T) {
Offset: 0,
Limit: 100,
ListPerms: true,
Domain: domainID,
},
identifyResponse: &magistrala.IdentityRes{Id: nonAdminID, UserId: nonAdminID, DomainId: domainID},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
Expand All @@ -761,6 +765,7 @@ func TestListClients(t *testing.T) {
Offset: 0,
Limit: 100,
ListPerms: true,
Domain: domainID,
},
identifyResponse: &magistrala.IdentityRes{Id: nonAdminID, UserId: nonAdminID, DomainId: domainID},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
Expand All @@ -778,6 +783,7 @@ func TestListClients(t *testing.T) {
Offset: 0,
Limit: 100,
ListPerms: true,
Domain: domainID,
},
identifyResponse: &magistrala.IdentityRes{Id: nonAdminID, UserId: nonAdminID, DomainId: domainID},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
Expand Down

0 comments on commit 38386a3

Please sign in to comment.