Skip to content

Commit

Permalink
Add tests cases for ListMembers
Browse files Browse the repository at this point in the history
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
  • Loading branch information
nyagamunene authored and dborovcanin committed Aug 1, 2024
1 parent 5e1eccf commit b329a41
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions users/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,50 @@ func TestListMembers(t *testing.T) {
},
err: nil,
},
{
desc: "list members with policies successsfully of the groups kind and name query",
token: validToken,
groupID: validID,
objectKind: authsvc.GroupsKind,
objectID: validID,
page: mgclients.Page{Offset: 0, Limit: 100, Permission: "read", Name: client.Name},
identifyResponse: &magistrala.IdentityRes{UserId: client.ID},
authorizeReq: &magistrala.AuthorizeReq{
SubjectType: authsvc.UserType,
SubjectKind: authsvc.TokenKind,
Subject: validToken,
Permission: "read",
ObjectType: authsvc.GroupType,
Object: validID,
},
listAllSubjectsReq: &magistrala.ListSubjectsReq{
SubjectType: authsvc.UserType,
Permission: "read",
Object: validID,
ObjectType: authsvc.GroupType,
},
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
listAllSubjectsResponse: &magistrala.ListSubjectsRes{
Policies: []string{validPolicy},
},
retrieveAllResponse: mgclients.ClientsPage{
Page: mgclients.Page{
Total: 1,
Offset: 0,
Limit: 100,
},
Clients: []mgclients.Client{client},
},
response: mgclients.MembersPage{
Page: mgclients.Page{
Total: 1,
Offset: 0,
Limit: 100,
},
Members: []mgclients.Client{basicClient},
},
err: nil,
},
{
desc: "list members with invalid token",
token: inValidToken,
Expand Down

0 comments on commit b329a41

Please sign in to comment.