From c8e51de67c711598aa4f1535832766c4611c6729 Mon Sep 17 00:00:00 2001 From: Arvindh Date: Fri, 20 Dec 2024 23:47:56 +0530 Subject: [PATCH 1/5] change: role name to role id Signed-off-by: Arvindh --- api/http/util/errors.go | 3 ++ pkg/roles/provisionmanage.go | 52 +++++++++---------- pkg/roles/repo/postgres/roles.go | 6 +-- pkg/roles/rolemanager/api/decoders.go | 22 ++++---- pkg/roles/rolemanager/api/endpoints.go | 22 ++++---- pkg/roles/rolemanager/api/requests.go | 67 ++++++++++++------------ pkg/roles/rolemanager/api/router.go | 2 +- pkg/roles/roles.go | 71 +++++--------------------- 8 files changed, 103 insertions(+), 142 deletions(-) diff --git a/api/http/util/errors.go b/api/http/util/errors.go index e4b05abf7f..d722556d89 100644 --- a/api/http/util/errors.go +++ b/api/http/util/errors.go @@ -81,6 +81,9 @@ var ( // ErrMissingRoleName indicates that role name are empty. ErrMissingRoleName = errors.New("empty role name") + // ErrMissingRoleID indicates that role name are empty. + ErrMissingRoleID = errors.New("empty role id") + // ErrMissingRoleOperations indicates that role operations are empty. ErrMissingRoleOperations = errors.New("empty role operations") diff --git a/pkg/roles/provisionmanage.go b/pkg/roles/provisionmanage.go index df9b00944b..8c41c47eb7 100644 --- a/pkg/roles/provisionmanage.go +++ b/pkg/roles/provisionmanage.go @@ -292,8 +292,8 @@ func (r ProvisionManageService) AddRole(ctx context.Context, session authn.Sessi return newRoles[0], nil } -func (r ProvisionManageService) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return errors.Wrap(svcerr.ErrRemoveEntity, err) } @@ -311,8 +311,8 @@ func (r ProvisionManageService) RemoveRole(ctx context.Context, session authn.Se return nil } -func (r ProvisionManageService) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (Role, error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, oldRoleName) +func (r ProvisionManageService) UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (Role, error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return Role{}, errors.Wrap(svcerr.ErrUpdateEntity, err) } @@ -329,8 +329,8 @@ func (r ProvisionManageService) UpdateRoleName(ctx context.Context, session auth return ro, nil } -func (r ProvisionManageService) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (Role, error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (Role, error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return Role{}, errors.Wrap(svcerr.ErrViewEntity, err) } @@ -353,8 +353,8 @@ func (r ProvisionManageService) ListAvailableActions(ctx context.Context, sessio return acts, nil } -func (r ProvisionManageService) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (retActs []string, retErr error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (retActs []string, retErr error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return []string{}, errors.Wrap(svcerr.ErrUpdateEntity, err) } @@ -401,8 +401,8 @@ func (r ProvisionManageService) RoleAddActions(ctx context.Context, session auth return resActs, nil } -func (r ProvisionManageService) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) ([]string, error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return []string{}, errors.Wrap(svcerr.ErrViewEntity, err) } @@ -414,8 +414,8 @@ func (r ProvisionManageService) RoleListActions(ctx context.Context, session aut return acts, nil } -func (r ProvisionManageService) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return false, errors.Wrap(svcerr.ErrViewEntity, err) } @@ -427,8 +427,8 @@ func (r ProvisionManageService) RoleCheckActionsExists(ctx context.Context, sess return result, nil } -func (r ProvisionManageService) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return errors.Wrap(svcerr.ErrRemoveEntity, err) } @@ -460,8 +460,8 @@ func (r ProvisionManageService) RoleRemoveActions(ctx context.Context, session a return nil } -func (r ProvisionManageService) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) error { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return errors.Wrap(svcerr.ErrRemoveEntity, err) } @@ -484,8 +484,8 @@ func (r ProvisionManageService) RoleRemoveAllActions(ctx context.Context, sessio return nil } -func (r ProvisionManageService) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (retMems []string, retErr error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (retMems []string, retErr error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return []string{}, errors.Wrap(svcerr.ErrUpdateEntity, err) } @@ -527,8 +527,8 @@ func (r ProvisionManageService) RoleAddMembers(ctx context.Context, session auth return mems, nil } -func (r ProvisionManageService) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (MembersPage, error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (MembersPage, error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return MembersPage{}, errors.Wrap(svcerr.ErrViewEntity, err) } @@ -540,8 +540,8 @@ func (r ProvisionManageService) RoleListMembers(ctx context.Context, session aut return mp, nil } -func (r ProvisionManageService) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return false, errors.Wrap(svcerr.ErrViewEntity, err) } @@ -553,8 +553,8 @@ func (r ProvisionManageService) RoleCheckMembersExists(ctx context.Context, sess return result, nil } -func (r ProvisionManageService) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return errors.Wrap(svcerr.ErrRemoveEntity, err) } @@ -586,8 +586,8 @@ func (r ProvisionManageService) RoleRemoveMembers(ctx context.Context, session a return nil } -func (r ProvisionManageService) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { - ro, err := r.repo.RetrieveRoleByEntityIDAndName(ctx, entityID, roleName) +func (r ProvisionManageService) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { + ro, err := r.repo.RetrieveEntityRole(ctx, entityID, roleID) if err != nil { return errors.Wrap(svcerr.ErrRemoveEntity, err) } diff --git a/pkg/roles/repo/postgres/roles.go b/pkg/roles/repo/postgres/roles.go index ad95626e7e..77e7229fe2 100644 --- a/pkg/roles/repo/postgres/roles.go +++ b/pkg/roles/repo/postgres/roles.go @@ -304,13 +304,13 @@ func (repo *Repository) RetrieveRole(ctx context.Context, roleID string) (roles. return roles.Role{}, repoerr.ErrNotFound } -func (repo *Repository) RetrieveRoleByEntityIDAndName(ctx context.Context, entityID, roleName string) (roles.Role, error) { +func (repo *Repository) RetrieveEntityRole(ctx context.Context, entityID, roleID string) (roles.Role, error) { q := fmt.Sprintf(`SELECT id, name, entity_id, created_by, created_at, updated_by, updated_at - FROM %s_roles WHERE entity_id = :entity_id and name = :name`, repo.tableNamePrefix) + FROM %s_roles WHERE entity_id = :entity_id and id = :id`, repo.tableNamePrefix) dbr := dbRole{ EntityID: entityID, - Name: roleName, + ID: roleID, } rows, err := repo.db.NamedQueryContext(ctx, q, dbr) diff --git a/pkg/roles/rolemanager/api/decoders.go b/pkg/roles/rolemanager/api/decoders.go index d8c6e23d21..289818121a 100644 --- a/pkg/roles/rolemanager/api/decoders.go +++ b/pkg/roles/rolemanager/api/decoders.go @@ -59,7 +59,7 @@ func (d Decoder) DecodeViewRole(_ context.Context, r *http.Request) (interface{} req := viewRoleReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } return req, nil } @@ -71,7 +71,7 @@ func (d Decoder) DecodeUpdateRole(_ context.Context, r *http.Request) (interface req := updateRoleReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { return nil, errors.Wrap(apiutil.ErrValidation, errors.Wrap(errors.ErrMalformedEntity, err)) @@ -83,7 +83,7 @@ func (d Decoder) DecodeDeleteRole(_ context.Context, r *http.Request) (interface req := deleteRoleReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } return req, nil } @@ -102,7 +102,7 @@ func (d Decoder) DecodeAddRoleActions(_ context.Context, r *http.Request) (inter req := addRoleActionsReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { return nil, errors.Wrap(apiutil.ErrValidation, errors.Wrap(errors.ErrMalformedEntity, err)) @@ -114,7 +114,7 @@ func (d Decoder) DecodeListRoleActions(_ context.Context, r *http.Request) (inte req := listRoleActionsReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } return req, nil } @@ -126,7 +126,7 @@ func (d Decoder) DecodeDeleteRoleActions(_ context.Context, r *http.Request) (in req := deleteRoleActionsReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { return nil, errors.Wrap(apiutil.ErrValidation, errors.Wrap(errors.ErrMalformedEntity, err)) @@ -138,7 +138,7 @@ func (d Decoder) DecodeDeleteAllRoleActions(_ context.Context, r *http.Request) req := deleteAllRoleActionsReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } return req, nil } @@ -150,7 +150,7 @@ func (d Decoder) DecodeAddRoleMembers(_ context.Context, r *http.Request) (inter req := addRoleMembersReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { return nil, errors.Wrap(apiutil.ErrValidation, errors.Wrap(errors.ErrMalformedEntity, err)) @@ -170,7 +170,7 @@ func (d Decoder) DecodeListRoleMembers(_ context.Context, r *http.Request) (inte req := listRoleMembersReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), limit: l, offset: o, } @@ -184,7 +184,7 @@ func (d Decoder) DecodeDeleteRoleMembers(_ context.Context, r *http.Request) (in req := deleteRoleMembersReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { return nil, errors.Wrap(apiutil.ErrValidation, errors.Wrap(errors.ErrMalformedEntity, err)) @@ -196,7 +196,7 @@ func (d Decoder) DecodeDeleteAllRoleMembers(_ context.Context, r *http.Request) req := deleteAllRoleMembersReq{ token: apiutil.ExtractBearerToken(r), entityID: chi.URLParam(r, d.entityIDTemplate), - roleName: chi.URLParam(r, "roleName"), + roleID: chi.URLParam(r, "roleID"), } return req, nil } diff --git a/pkg/roles/rolemanager/api/endpoints.go b/pkg/roles/rolemanager/api/endpoints.go index 5e35d68826..566d728f33 100644 --- a/pkg/roles/rolemanager/api/endpoints.go +++ b/pkg/roles/rolemanager/api/endpoints.go @@ -67,7 +67,7 @@ func ViewRoleEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - ro, err := svc.RetrieveRole(ctx, session, req.entityID, req.roleName) + ro, err := svc.RetrieveRole(ctx, session, req.entityID, req.roleID) if err != nil { return nil, err } @@ -87,7 +87,7 @@ func UpdateRoleEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - ro, err := svc.UpdateRoleName(ctx, session, req.entityID, req.roleName, req.Name) + ro, err := svc.UpdateRoleName(ctx, session, req.entityID, req.roleID, req.Name) if err != nil { return nil, err } @@ -107,7 +107,7 @@ func DeleteRoleEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - if err := svc.RemoveRole(ctx, session, req.entityID, req.roleName); err != nil { + if err := svc.RemoveRole(ctx, session, req.entityID, req.roleID); err != nil { return nil, err } return deleteRoleRes{}, nil @@ -146,7 +146,7 @@ func AddRoleActionsEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - caps, err := svc.RoleAddActions(ctx, session, req.entityID, req.roleName, req.Actions) + caps, err := svc.RoleAddActions(ctx, session, req.entityID, req.roleID, req.Actions) if err != nil { return nil, err } @@ -166,7 +166,7 @@ func ListRoleActionsEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - caps, err := svc.RoleListActions(ctx, session, req.entityID, req.roleName) + caps, err := svc.RoleListActions(ctx, session, req.entityID, req.roleID) if err != nil { return nil, err } @@ -186,7 +186,7 @@ func DeleteRoleActionsEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - if err := svc.RoleRemoveActions(ctx, session, req.entityID, req.roleName, req.Actions); err != nil { + if err := svc.RoleRemoveActions(ctx, session, req.entityID, req.roleID, req.Actions); err != nil { return nil, err } return deleteRoleActionsRes{}, nil @@ -205,7 +205,7 @@ func DeleteAllRoleActionsEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - if err := svc.RoleRemoveAllActions(ctx, session, req.entityID, req.roleName); err != nil { + if err := svc.RoleRemoveAllActions(ctx, session, req.entityID, req.roleID); err != nil { return nil, err } return deleteAllRoleActionsRes{}, nil @@ -224,7 +224,7 @@ func AddRoleMembersEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - members, err := svc.RoleAddMembers(ctx, session, req.entityID, req.roleName, req.Members) + members, err := svc.RoleAddMembers(ctx, session, req.entityID, req.roleID, req.Members) if err != nil { return nil, err } @@ -244,7 +244,7 @@ func ListRoleMembersEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - mp, err := svc.RoleListMembers(ctx, session, req.entityID, req.roleName, req.limit, req.offset) + mp, err := svc.RoleListMembers(ctx, session, req.entityID, req.roleID, req.limit, req.offset) if err != nil { return nil, err } @@ -264,7 +264,7 @@ func DeleteRoleMembersEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - if err := svc.RoleRemoveMembers(ctx, session, req.entityID, req.roleName, req.Members); err != nil { + if err := svc.RoleRemoveMembers(ctx, session, req.entityID, req.roleID, req.Members); err != nil { return nil, err } return deleteRoleMembersRes{}, nil @@ -283,7 +283,7 @@ func DeleteAllRoleMembersEndpoint(svc roles.RoleManager) endpoint.Endpoint { return nil, svcerr.ErrAuthentication } - if err := svc.RoleRemoveAllMembers(ctx, session, req.entityID, req.roleName); err != nil { + if err := svc.RoleRemoveAllMembers(ctx, session, req.entityID, req.roleID); err != nil { return nil, err } return deleteAllRoleMemberRes{}, nil diff --git a/pkg/roles/rolemanager/api/requests.go b/pkg/roles/rolemanager/api/requests.go index a607ad5e89..cf8bc611cb 100644 --- a/pkg/roles/rolemanager/api/requests.go +++ b/pkg/roles/rolemanager/api/requests.go @@ -56,7 +56,7 @@ func (req listRolesReq) validate() error { type viewRoleReq struct { token string entityID string - roleName string + roleID string } func (req viewRoleReq) validate() error { @@ -66,8 +66,8 @@ func (req viewRoleReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } return nil } @@ -75,7 +75,7 @@ func (req viewRoleReq) validate() error { type updateRoleReq struct { token string entityID string - roleName string + roleID string Name string `json:"name"` } @@ -86,7 +86,10 @@ func (req updateRoleReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" || req.Name == "" { + if req.roleID == "" { + return apiutil.ErrMissingRoleID + } + if req.Name == "" { return apiutil.ErrMissingRoleName } return nil @@ -95,7 +98,7 @@ func (req updateRoleReq) validate() error { type deleteRoleReq struct { token string entityID string - roleName string + roleID string } func (req deleteRoleReq) validate() error { @@ -105,8 +108,8 @@ func (req deleteRoleReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } return nil } @@ -125,7 +128,7 @@ func (req listAvailableActionsReq) validate() error { type addRoleActionsReq struct { token string entityID string - roleName string + roleID string Actions []string `json:"actions"` } @@ -136,8 +139,8 @@ func (req addRoleActionsReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } if len(req.Actions) == 0 { @@ -149,7 +152,7 @@ func (req addRoleActionsReq) validate() error { type listRoleActionsReq struct { token string entityID string - roleName string + roleID string } func (req listRoleActionsReq) validate() error { @@ -159,8 +162,8 @@ func (req listRoleActionsReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } return nil } @@ -168,7 +171,7 @@ func (req listRoleActionsReq) validate() error { type deleteRoleActionsReq struct { token string entityID string - roleName string + roleID string Actions []string `json:"actions"` } @@ -179,8 +182,8 @@ func (req deleteRoleActionsReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } if len(req.Actions) == 0 { @@ -192,7 +195,7 @@ func (req deleteRoleActionsReq) validate() error { type deleteAllRoleActionsReq struct { token string entityID string - roleName string + roleID string } func (req deleteAllRoleActionsReq) validate() error { @@ -202,8 +205,8 @@ func (req deleteAllRoleActionsReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } return nil } @@ -211,7 +214,7 @@ func (req deleteAllRoleActionsReq) validate() error { type addRoleMembersReq struct { token string entityID string - roleName string + roleID string Members []string `json:"members"` } @@ -222,8 +225,8 @@ func (req addRoleMembersReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } if len(req.Members) == 0 { return apiutil.ErrMissingRoleMembers @@ -234,7 +237,7 @@ func (req addRoleMembersReq) validate() error { type listRoleMembersReq struct { token string entityID string - roleName string + roleID string limit uint64 offset uint64 } @@ -246,8 +249,8 @@ func (req listRoleMembersReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } if req.limit > api.MaxLimitSize || req.limit < 1 { return apiutil.ErrLimitSize @@ -258,7 +261,7 @@ func (req listRoleMembersReq) validate() error { type deleteRoleMembersReq struct { token string entityID string - roleName string + roleID string Members []string `json:"members"` } @@ -269,8 +272,8 @@ func (req deleteRoleMembersReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } if len(req.Members) == 0 { return apiutil.ErrMissingRoleMembers @@ -281,7 +284,7 @@ func (req deleteRoleMembersReq) validate() error { type deleteAllRoleMembersReq struct { token string entityID string - roleName string + roleID string } func (req deleteAllRoleMembersReq) validate() error { @@ -291,8 +294,8 @@ func (req deleteAllRoleMembersReq) validate() error { if req.entityID == "" { return apiutil.ErrMissingID } - if req.roleName == "" { - return apiutil.ErrMissingRoleName + if req.roleID == "" { + return apiutil.ErrMissingRoleID } return nil } diff --git a/pkg/roles/rolemanager/api/router.go b/pkg/roles/rolemanager/api/router.go index d47b7b3692..1effdd6b0f 100644 --- a/pkg/roles/rolemanager/api/router.go +++ b/pkg/roles/rolemanager/api/router.go @@ -27,7 +27,7 @@ func EntityRoleMangerRouter(svc roles.RoleManager, d Decoder, r chi.Router, opts opts..., ), "list_roles").ServeHTTP) - r.Route("/{roleName}", func(r chi.Router) { + r.Route("/{roleID}", func(r chi.Router) { r.Get("/", otelhttp.NewHandler(kithttp.NewServer( ViewRoleEndpoint(svc), d.DecodeViewRole, diff --git a/pkg/roles/roles.go b/pkg/roles/roles.go index c4e11d9007..458fd459ae 100644 --- a/pkg/roles/roles.go +++ b/pkg/roles/roles.go @@ -96,33 +96,33 @@ type RoleManager interface { RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error // UpdateName update the name of the entity role. - UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (Role, error) + UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (Role, error) - RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (Role, error) + RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (Role, error) RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (RolePage, error) ListAvailableActions(ctx context.Context, session authn.Session) ([]string, error) - RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (ops []string, err error) + RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (ops []string, err error) - RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) + RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) ([]string, error) - RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) + RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) - RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) + RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) - RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error + RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) error - RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error) + RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) ([]string, error) - RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (MembersPage, error) + RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (MembersPage, error) - RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) + RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) - RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) + RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) - RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) + RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) RemoveMemberFromAllRoles(ctx context.Context, session authn.Session, memberID string) (err error) } @@ -133,7 +133,7 @@ type Repository interface { RemoveRoles(ctx context.Context, roleIDs []string) error UpdateRole(ctx context.Context, ro Role) (Role, error) RetrieveRole(ctx context.Context, roleID string) (Role, error) - RetrieveRoleByEntityIDAndName(ctx context.Context, entityID, roleName string) (Role, error) + RetrieveEntityRole(ctx context.Context, entityID, roleID string) (Role, error) RetrieveAllRoles(ctx context.Context, entityID string, limit, offset uint64) (RolePage, error) RoleAddActions(ctx context.Context, role Role, actions []string) (ops []string, err error) RoleListActions(ctx context.Context, roleID string) ([]string, error) @@ -149,51 +149,6 @@ type Repository interface { RemoveMemberFromAllRoles(ctx context.Context, memberID string) (err error) } -type Roles interface { - // Add New role to entity - AddRole(ctx context.Context, session authn.Session, entityID, roleName string, optionalActions []string, optionalMembers []string) (Role, error) - - // Remove removes the roles of entity. - RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error - - // UpdateName update the name of the entity role. - UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (Role, error) - - RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (Role, error) - - RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (RolePage, error) - - ListAvailableActions(ctx context.Context, session authn.Session) ([]string, error) - - RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (ops []string, err error) - - RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) - - RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) - - RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) - - RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error - - RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error) - - RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (MembersPage, error) - - RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) - - RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) - - RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) - - RemoveMembersFromAllRoles(ctx context.Context, session authn.Session, members []string) (err error) - - RemoveMembersFromRoles(ctx context.Context, session authn.Session, members []string, roleNames []string) (err error) - - RemoveActionsFromAllRoles(ctx context.Context, session authn.Session, actions []string) (err error) - - RemoveActionsFromRoles(ctx context.Context, session authn.Session, actions []string, roleNames []string) (err error) -} - const ( OpAddRole svcutil.Operation = iota OpRemoveRole From 486384314343c1c9d08f188d56c2be0bd76ecdff Mon Sep 17 00:00:00 2001 From: Arvindh Date: Sat, 21 Dec 2024 00:10:06 +0530 Subject: [PATCH 2/5] change: role name to role id Signed-off-by: Arvindh --- channels/mocks/repository.go | 56 ++++---- channels/mocks/service.go | 136 +++++++++--------- clients/mocks/repository.go | 56 ++++---- clients/mocks/service.go | 136 +++++++++--------- domains/mocks/repository.go | 40 +++--- domains/mocks/service.go | 136 +++++++++--------- groups/mocks/repository.go | 56 ++++---- groups/mocks/service.go | 136 +++++++++--------- pkg/roles/mocks/rolemanager.go | 136 +++++++++--------- pkg/roles/mocks/rolesRepo.go | 40 +++--- pkg/roles/rolemanager/events/events.go | 22 --- pkg/roles/rolemanager/events/streams.go | 74 +++++----- .../rolemanager/middleware/authoirzation.go | 52 +++---- pkg/roles/rolemanager/middleware/logging.go | 76 +++++----- pkg/roles/rolemanager/middleware/meterics.go | 52 +++---- pkg/roles/rolemanager/tracing/tracing.go | 52 +++---- pkg/roles/roles.go | 2 +- 17 files changed, 618 insertions(+), 640 deletions(-) diff --git a/channels/mocks/repository.go b/channels/mocks/repository.go index 6feb79682f..930f8b52c1 100644 --- a/channels/mocks/repository.go +++ b/channels/mocks/repository.go @@ -443,6 +443,34 @@ func (_m *Repository) RetrieveEntitiesRolesActionsMembers(ctx context.Context, e return r0, r1, r2 } +// RetrieveEntityRole provides a mock function with given fields: ctx, entityID, roleID +func (_m *Repository) RetrieveEntityRole(ctx context.Context, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, entityID, roleID) + + if len(ret) == 0 { + panic("no return value specified for RetrieveEntityRole") + } + + var r0 roles.Role + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { + return rf(ctx, entityID, roleID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { + r0 = rf(ctx, entityID, roleID) + } else { + r0 = ret.Get(0).(roles.Role) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, entityID, roleID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // RetrieveParentGroupChannels provides a mock function with given fields: ctx, parentGroupID func (_m *Repository) RetrieveParentGroupChannels(ctx context.Context, parentGroupID string) ([]channels.Channel, error) { ret := _m.Called(ctx, parentGroupID) @@ -501,34 +529,6 @@ func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Ro return r0, r1 } -// RetrieveRoleByEntityIDAndName provides a mock function with given fields: ctx, entityID, roleName -func (_m *Repository) RetrieveRoleByEntityIDAndName(ctx context.Context, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, entityID, roleName) - - if len(ret) == 0 { - panic("no return value specified for RetrieveRoleByEntityIDAndName") - } - - var r0 roles.Role - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { - return rf(ctx, entityID, roleName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { - r0 = rf(ctx, entityID, roleName) - } else { - r0 = ret.Get(0).(roles.Role) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, entityID, roleName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // RoleAddActions provides a mock function with given fields: ctx, role, actions func (_m *Repository) RoleAddActions(ctx context.Context, role roles.Role, actions []string) ([]string, error) { ret := _m.Called(ctx, role, actions) diff --git a/channels/mocks/service.go b/channels/mocks/service.go index 464b19dd17..0f625b81d7 100644 --- a/channels/mocks/service.go +++ b/channels/mocks/service.go @@ -319,9 +319,9 @@ func (_m *Service) RemoveParentGroup(ctx context.Context, session authn.Session, return r0 } -// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RemoveRole") @@ -329,7 +329,7 @@ func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entity var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -365,9 +365,9 @@ func (_m *Service) RetrieveAllRoles(ctx context.Context, session authn.Session, return r0, r1 } -// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RetrieveRole") @@ -376,16 +376,16 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -393,9 +393,9 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti return r0, r1 } -// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleAddActions") @@ -404,10 +404,10 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -415,7 +415,7 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -423,9 +423,9 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleAddMembers") @@ -434,10 +434,10 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -445,7 +445,7 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -453,9 +453,9 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleCheckActionsExists") @@ -464,16 +464,16 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -481,9 +481,9 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleCheckMembersExists") @@ -492,16 +492,16 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -509,9 +509,9 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleName string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleID string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleListActions") @@ -520,10 +520,10 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) []string); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -531,7 +531,7 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -539,9 +539,9 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleName, limit, offset -func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleName string, limit uint64, offset uint64) (roles.MembersPage, error) { - ret := _m.Called(ctx, session, entityID, roleName, limit, offset) +// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleID, limit, offset +func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleID string, limit uint64, offset uint64) (roles.MembersPage, error) { + ret := _m.Called(ctx, session, entityID, roleID, limit, offset) if len(ret) == 0 { panic("no return value specified for RoleListMembers") @@ -550,16 +550,16 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e var r0 roles.MembersPage var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) (roles.MembersPage, error)); ok { - return rf(ctx, session, entityID, roleName, limit, offset) + return rf(ctx, session, entityID, roleID, limit, offset) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) roles.MembersPage); ok { - r0 = rf(ctx, session, entityID, roleName, limit, offset) + r0 = rf(ctx, session, entityID, roleID, limit, offset) } else { r0 = ret.Get(0).(roles.MembersPage) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, uint64, uint64) error); ok { - r1 = rf(ctx, session, entityID, roleName, limit, offset) + r1 = rf(ctx, session, entityID, roleID, limit, offset) } else { r1 = ret.Error(1) } @@ -567,9 +567,9 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) error { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) error { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleRemoveActions") @@ -577,7 +577,7 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Error(0) } @@ -585,9 +585,9 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, return r0 } -// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllActions") @@ -595,7 +595,7 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -603,9 +603,9 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllMembers") @@ -613,7 +613,7 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -621,9 +621,9 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) error { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) error { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleRemoveMembers") @@ -631,7 +631,7 @@ func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Error(0) } @@ -713,9 +713,9 @@ func (_m *Service) UpdateChannelTags(ctx context.Context, session authn.Session, return r0, r1 } -// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, oldRoleName, newRoleName -func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, oldRoleName string, newRoleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, oldRoleName, newRoleName) +// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, roleID, newRoleName +func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, roleID string, newRoleName string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID, newRoleName) if len(ret) == 0 { panic("no return value specified for UpdateRoleName") @@ -724,16 +724,16 @@ func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, en var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, oldRoleName, newRoleName) + return rf(ctx, session, entityID, roleID, newRoleName) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r0 = rf(ctx, session, entityID, roleID, newRoleName) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string) error); ok { - r1 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r1 = rf(ctx, session, entityID, roleID, newRoleName) } else { r1 = ret.Error(1) } diff --git a/clients/mocks/repository.go b/clients/mocks/repository.go index 22f57e651d..501a9e9807 100644 --- a/clients/mocks/repository.go +++ b/clients/mocks/repository.go @@ -491,6 +491,34 @@ func (_m *Repository) RetrieveEntitiesRolesActionsMembers(ctx context.Context, e return r0, r1, r2 } +// RetrieveEntityRole provides a mock function with given fields: ctx, entityID, roleID +func (_m *Repository) RetrieveEntityRole(ctx context.Context, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, entityID, roleID) + + if len(ret) == 0 { + panic("no return value specified for RetrieveEntityRole") + } + + var r0 roles.Role + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { + return rf(ctx, entityID, roleID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { + r0 = rf(ctx, entityID, roleID) + } else { + r0 = ret.Get(0).(roles.Role) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, entityID, roleID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // RetrieveParentGroupClients provides a mock function with given fields: ctx, parentGroupID func (_m *Repository) RetrieveParentGroupClients(ctx context.Context, parentGroupID string) ([]clients.Client, error) { ret := _m.Called(ctx, parentGroupID) @@ -549,34 +577,6 @@ func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Ro return r0, r1 } -// RetrieveRoleByEntityIDAndName provides a mock function with given fields: ctx, entityID, roleName -func (_m *Repository) RetrieveRoleByEntityIDAndName(ctx context.Context, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, entityID, roleName) - - if len(ret) == 0 { - panic("no return value specified for RetrieveRoleByEntityIDAndName") - } - - var r0 roles.Role - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { - return rf(ctx, entityID, roleName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { - r0 = rf(ctx, entityID, roleName) - } else { - r0 = ret.Get(0).(roles.Role) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, entityID, roleName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // RoleAddActions provides a mock function with given fields: ctx, role, actions func (_m *Repository) RoleAddActions(ctx context.Context, role roles.Role, actions []string) ([]string, error) { ret := _m.Called(ctx, role, actions) diff --git a/clients/mocks/service.go b/clients/mocks/service.go index 595af58fff..f93aac6425 100644 --- a/clients/mocks/service.go +++ b/clients/mocks/service.go @@ -253,9 +253,9 @@ func (_m *Service) RemoveParentGroup(ctx context.Context, session authn.Session, return r0 } -// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RemoveRole") @@ -263,7 +263,7 @@ func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entity var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -299,9 +299,9 @@ func (_m *Service) RetrieveAllRoles(ctx context.Context, session authn.Session, return r0, r1 } -// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RetrieveRole") @@ -310,16 +310,16 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -327,9 +327,9 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti return r0, r1 } -// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleAddActions") @@ -338,10 +338,10 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -349,7 +349,7 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -357,9 +357,9 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleAddMembers") @@ -368,10 +368,10 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -379,7 +379,7 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -387,9 +387,9 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleCheckActionsExists") @@ -398,16 +398,16 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -415,9 +415,9 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleCheckMembersExists") @@ -426,16 +426,16 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -443,9 +443,9 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleName string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleID string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleListActions") @@ -454,10 +454,10 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) []string); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -465,7 +465,7 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -473,9 +473,9 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleName, limit, offset -func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleName string, limit uint64, offset uint64) (roles.MembersPage, error) { - ret := _m.Called(ctx, session, entityID, roleName, limit, offset) +// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleID, limit, offset +func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleID string, limit uint64, offset uint64) (roles.MembersPage, error) { + ret := _m.Called(ctx, session, entityID, roleID, limit, offset) if len(ret) == 0 { panic("no return value specified for RoleListMembers") @@ -484,16 +484,16 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e var r0 roles.MembersPage var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) (roles.MembersPage, error)); ok { - return rf(ctx, session, entityID, roleName, limit, offset) + return rf(ctx, session, entityID, roleID, limit, offset) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) roles.MembersPage); ok { - r0 = rf(ctx, session, entityID, roleName, limit, offset) + r0 = rf(ctx, session, entityID, roleID, limit, offset) } else { r0 = ret.Get(0).(roles.MembersPage) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, uint64, uint64) error); ok { - r1 = rf(ctx, session, entityID, roleName, limit, offset) + r1 = rf(ctx, session, entityID, roleID, limit, offset) } else { r1 = ret.Error(1) } @@ -501,9 +501,9 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) error { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) error { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleRemoveActions") @@ -511,7 +511,7 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Error(0) } @@ -519,9 +519,9 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, return r0 } -// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllActions") @@ -529,7 +529,7 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -537,9 +537,9 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllMembers") @@ -547,7 +547,7 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -555,9 +555,9 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) error { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) error { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleRemoveMembers") @@ -565,7 +565,7 @@ func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Error(0) } @@ -619,9 +619,9 @@ func (_m *Service) Update(ctx context.Context, session authn.Session, client cli return r0, r1 } -// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, oldRoleName, newRoleName -func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, oldRoleName string, newRoleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, oldRoleName, newRoleName) +// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, roleID, newRoleName +func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, roleID string, newRoleName string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID, newRoleName) if len(ret) == 0 { panic("no return value specified for UpdateRoleName") @@ -630,16 +630,16 @@ func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, en var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, oldRoleName, newRoleName) + return rf(ctx, session, entityID, roleID, newRoleName) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r0 = rf(ctx, session, entityID, roleID, newRoleName) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string) error); ok { - r1 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r1 = rf(ctx, session, entityID, roleID, newRoleName) } else { r1 = ret.Error(1) } diff --git a/domains/mocks/repository.go b/domains/mocks/repository.go index a8dae642f7..8fadf76968 100644 --- a/domains/mocks/repository.go +++ b/domains/mocks/repository.go @@ -281,27 +281,27 @@ func (_m *Repository) RetrieveEntitiesRolesActionsMembers(ctx context.Context, e return r0, r1, r2 } -// RetrieveRole provides a mock function with given fields: ctx, roleID -func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Role, error) { - ret := _m.Called(ctx, roleID) +// RetrieveEntityRole provides a mock function with given fields: ctx, entityID, roleID +func (_m *Repository) RetrieveEntityRole(ctx context.Context, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, entityID, roleID) if len(ret) == 0 { - panic("no return value specified for RetrieveRole") + panic("no return value specified for RetrieveEntityRole") } var r0 roles.Role var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (roles.Role, error)); ok { - return rf(ctx, roleID) + if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { + return rf(ctx, entityID, roleID) } - if rf, ok := ret.Get(0).(func(context.Context, string) roles.Role); ok { - r0 = rf(ctx, roleID) + if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { + r0 = rf(ctx, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, roleID) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, entityID, roleID) } else { r1 = ret.Error(1) } @@ -309,27 +309,27 @@ func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Ro return r0, r1 } -// RetrieveRoleByEntityIDAndName provides a mock function with given fields: ctx, entityID, roleName -func (_m *Repository) RetrieveRoleByEntityIDAndName(ctx context.Context, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, roleID +func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, roleID) if len(ret) == 0 { - panic("no return value specified for RetrieveRoleByEntityIDAndName") + panic("no return value specified for RetrieveRole") } var r0 roles.Role var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { - return rf(ctx, entityID, roleName) + if rf, ok := ret.Get(0).(func(context.Context, string) (roles.Role, error)); ok { + return rf(ctx, roleID) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { - r0 = rf(ctx, entityID, roleName) + if rf, ok := ret.Get(0).(func(context.Context, string) roles.Role); ok { + r0 = rf(ctx, roleID) } else { r0 = ret.Get(0).(roles.Role) } - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, entityID, roleName) + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, roleID) } else { r1 = ret.Error(1) } diff --git a/domains/mocks/service.go b/domains/mocks/service.go index 15486badd6..23f9f2d3e0 100644 --- a/domains/mocks/service.go +++ b/domains/mocks/service.go @@ -237,9 +237,9 @@ func (_m *Service) RemoveMemberFromAllRoles(ctx context.Context, session authn.S return r0 } -// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RemoveRole") @@ -247,7 +247,7 @@ func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entity var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -311,9 +311,9 @@ func (_m *Service) RetrieveDomain(ctx context.Context, sesssion authn.Session, i return r0, r1 } -// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RetrieveRole") @@ -322,16 +322,16 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -339,9 +339,9 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti return r0, r1 } -// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleAddActions") @@ -350,10 +350,10 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -361,7 +361,7 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -369,9 +369,9 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleAddMembers") @@ -380,10 +380,10 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -391,7 +391,7 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -399,9 +399,9 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleCheckActionsExists") @@ -410,16 +410,16 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -427,9 +427,9 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleCheckMembersExists") @@ -438,16 +438,16 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -455,9 +455,9 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleName string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleID string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleListActions") @@ -466,10 +466,10 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) []string); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -477,7 +477,7 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -485,9 +485,9 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleName, limit, offset -func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleName string, limit uint64, offset uint64) (roles.MembersPage, error) { - ret := _m.Called(ctx, session, entityID, roleName, limit, offset) +// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleID, limit, offset +func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleID string, limit uint64, offset uint64) (roles.MembersPage, error) { + ret := _m.Called(ctx, session, entityID, roleID, limit, offset) if len(ret) == 0 { panic("no return value specified for RoleListMembers") @@ -496,16 +496,16 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e var r0 roles.MembersPage var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) (roles.MembersPage, error)); ok { - return rf(ctx, session, entityID, roleName, limit, offset) + return rf(ctx, session, entityID, roleID, limit, offset) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) roles.MembersPage); ok { - r0 = rf(ctx, session, entityID, roleName, limit, offset) + r0 = rf(ctx, session, entityID, roleID, limit, offset) } else { r0 = ret.Get(0).(roles.MembersPage) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, uint64, uint64) error); ok { - r1 = rf(ctx, session, entityID, roleName, limit, offset) + r1 = rf(ctx, session, entityID, roleID, limit, offset) } else { r1 = ret.Error(1) } @@ -513,9 +513,9 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) error { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) error { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleRemoveActions") @@ -523,7 +523,7 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Error(0) } @@ -531,9 +531,9 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, return r0 } -// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllActions") @@ -541,7 +541,7 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -549,9 +549,9 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllMembers") @@ -559,7 +559,7 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -567,9 +567,9 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) error { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) error { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleRemoveMembers") @@ -577,7 +577,7 @@ func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Error(0) } @@ -613,9 +613,9 @@ func (_m *Service) UpdateDomain(ctx context.Context, sesssion authn.Session, id return r0, r1 } -// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, oldRoleName, newRoleName -func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, oldRoleName string, newRoleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, oldRoleName, newRoleName) +// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, roleID, newRoleName +func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, roleID string, newRoleName string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID, newRoleName) if len(ret) == 0 { panic("no return value specified for UpdateRoleName") @@ -624,16 +624,16 @@ func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, en var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, oldRoleName, newRoleName) + return rf(ctx, session, entityID, roleID, newRoleName) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r0 = rf(ctx, session, entityID, roleID, newRoleName) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string) error); ok { - r1 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r1 = rf(ctx, session, entityID, roleID, newRoleName) } else { r1 = ret.Error(1) } diff --git a/groups/mocks/repository.go b/groups/mocks/repository.go index 867680c2ca..c8d9cd6c31 100644 --- a/groups/mocks/repository.go +++ b/groups/mocks/repository.go @@ -383,6 +383,34 @@ func (_m *Repository) RetrieveEntitiesRolesActionsMembers(ctx context.Context, e return r0, r1, r2 } +// RetrieveEntityRole provides a mock function with given fields: ctx, entityID, roleID +func (_m *Repository) RetrieveEntityRole(ctx context.Context, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, entityID, roleID) + + if len(ret) == 0 { + panic("no return value specified for RetrieveEntityRole") + } + + var r0 roles.Role + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { + return rf(ctx, entityID, roleID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { + r0 = rf(ctx, entityID, roleID) + } else { + r0 = ret.Get(0).(roles.Role) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, entityID, roleID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // RetrieveHierarchy provides a mock function with given fields: ctx, id, hm func (_m *Repository) RetrieveHierarchy(ctx context.Context, id string, hm groups.HierarchyPageMeta) (groups.HierarchyPage, error) { ret := _m.Called(ctx, id, hm) @@ -439,34 +467,6 @@ func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Ro return r0, r1 } -// RetrieveRoleByEntityIDAndName provides a mock function with given fields: ctx, entityID, roleName -func (_m *Repository) RetrieveRoleByEntityIDAndName(ctx context.Context, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, entityID, roleName) - - if len(ret) == 0 { - panic("no return value specified for RetrieveRoleByEntityIDAndName") - } - - var r0 roles.Role - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { - return rf(ctx, entityID, roleName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { - r0 = rf(ctx, entityID, roleName) - } else { - r0 = ret.Get(0).(roles.Role) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, entityID, roleName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // RetrieveUserGroups provides a mock function with given fields: ctx, domainID, userID, pm func (_m *Repository) RetrieveUserGroups(ctx context.Context, domainID string, userID string, pm groups.PageMeta) (groups.Page, error) { ret := _m.Called(ctx, domainID, userID, pm) diff --git a/groups/mocks/service.go b/groups/mocks/service.go index b45ff45422..6e02c7316b 100644 --- a/groups/mocks/service.go +++ b/groups/mocks/service.go @@ -373,9 +373,9 @@ func (_m *Service) RemoveParentGroup(ctx context.Context, session authn.Session, return r0 } -// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RemoveRole") @@ -383,7 +383,7 @@ func (_m *Service) RemoveRole(ctx context.Context, session authn.Session, entity var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -447,9 +447,9 @@ func (_m *Service) RetrieveGroupHierarchy(ctx context.Context, session authn.Ses return r0, r1 } -// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RetrieveRole") @@ -458,16 +458,16 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -475,9 +475,9 @@ func (_m *Service) RetrieveRole(ctx context.Context, session authn.Session, enti return r0, r1 } -// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleAddActions") @@ -486,10 +486,10 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -497,7 +497,7 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -505,9 +505,9 @@ func (_m *Service) RoleAddActions(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleAddMembers") @@ -516,10 +516,10 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -527,7 +527,7 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -535,9 +535,9 @@ func (_m *Service) RoleAddMembers(ctx context.Context, session authn.Session, en return r0, r1 } -// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleCheckActionsExists") @@ -546,16 +546,16 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -563,9 +563,9 @@ func (_m *Service) RoleCheckActionsExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleCheckMembersExists") @@ -574,16 +574,16 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -591,9 +591,9 @@ func (_m *Service) RoleCheckMembersExists(ctx context.Context, session authn.Ses return r0, r1 } -// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleName string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleID string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleListActions") @@ -602,10 +602,10 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) []string); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -613,7 +613,7 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -621,9 +621,9 @@ func (_m *Service) RoleListActions(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleName, limit, offset -func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleName string, limit uint64, offset uint64) (roles.MembersPage, error) { - ret := _m.Called(ctx, session, entityID, roleName, limit, offset) +// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleID, limit, offset +func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleID string, limit uint64, offset uint64) (roles.MembersPage, error) { + ret := _m.Called(ctx, session, entityID, roleID, limit, offset) if len(ret) == 0 { panic("no return value specified for RoleListMembers") @@ -632,16 +632,16 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e var r0 roles.MembersPage var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) (roles.MembersPage, error)); ok { - return rf(ctx, session, entityID, roleName, limit, offset) + return rf(ctx, session, entityID, roleID, limit, offset) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) roles.MembersPage); ok { - r0 = rf(ctx, session, entityID, roleName, limit, offset) + r0 = rf(ctx, session, entityID, roleID, limit, offset) } else { r0 = ret.Get(0).(roles.MembersPage) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, uint64, uint64) error); ok { - r1 = rf(ctx, session, entityID, roleName, limit, offset) + r1 = rf(ctx, session, entityID, roleID, limit, offset) } else { r1 = ret.Error(1) } @@ -649,9 +649,9 @@ func (_m *Service) RoleListMembers(ctx context.Context, session authn.Session, e return r0, r1 } -// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) error { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) error { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleRemoveActions") @@ -659,7 +659,7 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Error(0) } @@ -667,9 +667,9 @@ func (_m *Service) RoleRemoveActions(ctx context.Context, session authn.Session, return r0 } -// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllActions") @@ -677,7 +677,7 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -685,9 +685,9 @@ func (_m *Service) RoleRemoveAllActions(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllMembers") @@ -695,7 +695,7 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -703,9 +703,9 @@ func (_m *Service) RoleRemoveAllMembers(ctx context.Context, session authn.Sessi return r0 } -// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) error { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) error { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleRemoveMembers") @@ -713,7 +713,7 @@ func (_m *Service) RoleRemoveMembers(ctx context.Context, session authn.Session, var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Error(0) } @@ -749,9 +749,9 @@ func (_m *Service) UpdateGroup(ctx context.Context, session authn.Session, g gro return r0, r1 } -// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, oldRoleName, newRoleName -func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, oldRoleName string, newRoleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, oldRoleName, newRoleName) +// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, roleID, newRoleName +func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, roleID string, newRoleName string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID, newRoleName) if len(ret) == 0 { panic("no return value specified for UpdateRoleName") @@ -760,16 +760,16 @@ func (_m *Service) UpdateRoleName(ctx context.Context, session authn.Session, en var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, oldRoleName, newRoleName) + return rf(ctx, session, entityID, roleID, newRoleName) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r0 = rf(ctx, session, entityID, roleID, newRoleName) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string) error); ok { - r1 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r1 = rf(ctx, session, entityID, roleID, newRoleName) } else { r1 = ret.Error(1) } diff --git a/pkg/roles/mocks/rolemanager.go b/pkg/roles/mocks/rolemanager.go index 636ad5c004..ff16fe9f93 100644 --- a/pkg/roles/mocks/rolemanager.go +++ b/pkg/roles/mocks/rolemanager.go @@ -95,9 +95,9 @@ func (_m *RoleManager) RemoveMemberFromAllRoles(ctx context.Context, session aut return r0 } -// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *RoleManager) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RemoveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *RoleManager) RemoveRole(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RemoveRole") @@ -105,7 +105,7 @@ func (_m *RoleManager) RemoveRole(ctx context.Context, session authn.Session, en var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -141,9 +141,9 @@ func (_m *RoleManager) RetrieveAllRoles(ctx context.Context, session authn.Sessi return r0, r1 } -// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *RoleManager) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *RoleManager) RetrieveRole(ctx context.Context, session authn.Session, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RetrieveRole") @@ -152,16 +152,16 @@ func (_m *RoleManager) RetrieveRole(ctx context.Context, session authn.Session, var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -169,9 +169,9 @@ func (_m *RoleManager) RetrieveRole(ctx context.Context, session authn.Session, return r0, r1 } -// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *RoleManager) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleAddActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *RoleManager) RoleAddActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleAddActions") @@ -180,10 +180,10 @@ func (_m *RoleManager) RoleAddActions(ctx context.Context, session authn.Session var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -191,7 +191,7 @@ func (_m *RoleManager) RoleAddActions(ctx context.Context, session authn.Session } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -199,9 +199,9 @@ func (_m *RoleManager) RoleAddActions(ctx context.Context, session authn.Session return r0, r1 } -// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *RoleManager) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleAddMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *RoleManager) RoleAddMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleAddMembers") @@ -210,10 +210,10 @@ func (_m *RoleManager) RoleAddMembers(ctx context.Context, session authn.Session var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) []string); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -221,7 +221,7 @@ func (_m *RoleManager) RoleAddMembers(ctx context.Context, session authn.Session } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -229,9 +229,9 @@ func (_m *RoleManager) RoleAddMembers(ctx context.Context, session authn.Session return r0, r1 } -// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *RoleManager) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleCheckActionsExists provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *RoleManager) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleCheckActionsExists") @@ -240,16 +240,16 @@ func (_m *RoleManager) RoleCheckActionsExists(ctx context.Context, session authn var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, actions) + return rf(ctx, session, entityID, roleID, actions) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, actions) + r1 = rf(ctx, session, entityID, roleID, actions) } else { r1 = ret.Error(1) } @@ -257,9 +257,9 @@ func (_m *RoleManager) RoleCheckActionsExists(ctx context.Context, session authn return r0, r1 } -// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *RoleManager) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) (bool, error) { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleCheckMembersExists provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *RoleManager) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) (bool, error) { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleCheckMembersExists") @@ -268,16 +268,16 @@ func (_m *RoleManager) RoleCheckMembersExists(ctx context.Context, session authn var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) (bool, error)); ok { - return rf(ctx, session, entityID, roleName, members) + return rf(ctx, session, entityID, roleID, members) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) bool); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Get(0).(bool) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, []string) error); ok { - r1 = rf(ctx, session, entityID, roleName, members) + r1 = rf(ctx, session, entityID, roleID, members) } else { r1 = ret.Error(1) } @@ -285,9 +285,9 @@ func (_m *RoleManager) RoleCheckMembersExists(ctx context.Context, session authn return r0, r1 } -// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *RoleManager) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleName string) ([]string, error) { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleListActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *RoleManager) RoleListActions(ctx context.Context, session authn.Session, entityID string, roleID string) ([]string, error) { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleListActions") @@ -296,10 +296,10 @@ func (_m *RoleManager) RoleListActions(ctx context.Context, session authn.Sessio var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) ([]string, error)); ok { - return rf(ctx, session, entityID, roleName) + return rf(ctx, session, entityID, roleID) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) []string); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -307,7 +307,7 @@ func (_m *RoleManager) RoleListActions(ctx context.Context, session authn.Sessio } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string) error); ok { - r1 = rf(ctx, session, entityID, roleName) + r1 = rf(ctx, session, entityID, roleID) } else { r1 = ret.Error(1) } @@ -315,9 +315,9 @@ func (_m *RoleManager) RoleListActions(ctx context.Context, session authn.Sessio return r0, r1 } -// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleName, limit, offset -func (_m *RoleManager) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleName string, limit uint64, offset uint64) (roles.MembersPage, error) { - ret := _m.Called(ctx, session, entityID, roleName, limit, offset) +// RoleListMembers provides a mock function with given fields: ctx, session, entityID, roleID, limit, offset +func (_m *RoleManager) RoleListMembers(ctx context.Context, session authn.Session, entityID string, roleID string, limit uint64, offset uint64) (roles.MembersPage, error) { + ret := _m.Called(ctx, session, entityID, roleID, limit, offset) if len(ret) == 0 { panic("no return value specified for RoleListMembers") @@ -326,16 +326,16 @@ func (_m *RoleManager) RoleListMembers(ctx context.Context, session authn.Sessio var r0 roles.MembersPage var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) (roles.MembersPage, error)); ok { - return rf(ctx, session, entityID, roleName, limit, offset) + return rf(ctx, session, entityID, roleID, limit, offset) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, uint64, uint64) roles.MembersPage); ok { - r0 = rf(ctx, session, entityID, roleName, limit, offset) + r0 = rf(ctx, session, entityID, roleID, limit, offset) } else { r0 = ret.Get(0).(roles.MembersPage) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, uint64, uint64) error); ok { - r1 = rf(ctx, session, entityID, roleName, limit, offset) + r1 = rf(ctx, session, entityID, roleID, limit, offset) } else { r1 = ret.Error(1) } @@ -343,9 +343,9 @@ func (_m *RoleManager) RoleListMembers(ctx context.Context, session authn.Sessio return r0, r1 } -// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleName, actions -func (_m *RoleManager) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleName string, actions []string) error { - ret := _m.Called(ctx, session, entityID, roleName, actions) +// RoleRemoveActions provides a mock function with given fields: ctx, session, entityID, roleID, actions +func (_m *RoleManager) RoleRemoveActions(ctx context.Context, session authn.Session, entityID string, roleID string, actions []string) error { + ret := _m.Called(ctx, session, entityID, roleID, actions) if len(ret) == 0 { panic("no return value specified for RoleRemoveActions") @@ -353,7 +353,7 @@ func (_m *RoleManager) RoleRemoveActions(ctx context.Context, session authn.Sess var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, actions) + r0 = rf(ctx, session, entityID, roleID, actions) } else { r0 = ret.Error(0) } @@ -361,9 +361,9 @@ func (_m *RoleManager) RoleRemoveActions(ctx context.Context, session authn.Sess return r0 } -// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *RoleManager) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllActions provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *RoleManager) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllActions") @@ -371,7 +371,7 @@ func (_m *RoleManager) RoleRemoveAllActions(ctx context.Context, session authn.S var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -379,9 +379,9 @@ func (_m *RoleManager) RoleRemoveAllActions(ctx context.Context, session authn.S return r0 } -// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleName -func (_m *RoleManager) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleName string) error { - ret := _m.Called(ctx, session, entityID, roleName) +// RoleRemoveAllMembers provides a mock function with given fields: ctx, session, entityID, roleID +func (_m *RoleManager) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID string, roleID string) error { + ret := _m.Called(ctx, session, entityID, roleID) if len(ret) == 0 { panic("no return value specified for RoleRemoveAllMembers") @@ -389,7 +389,7 @@ func (_m *RoleManager) RoleRemoveAllMembers(ctx context.Context, session authn.S var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string) error); ok { - r0 = rf(ctx, session, entityID, roleName) + r0 = rf(ctx, session, entityID, roleID) } else { r0 = ret.Error(0) } @@ -397,9 +397,9 @@ func (_m *RoleManager) RoleRemoveAllMembers(ctx context.Context, session authn.S return r0 } -// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleName, members -func (_m *RoleManager) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleName string, members []string) error { - ret := _m.Called(ctx, session, entityID, roleName, members) +// RoleRemoveMembers provides a mock function with given fields: ctx, session, entityID, roleID, members +func (_m *RoleManager) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID string, roleID string, members []string) error { + ret := _m.Called(ctx, session, entityID, roleID, members) if len(ret) == 0 { panic("no return value specified for RoleRemoveMembers") @@ -407,7 +407,7 @@ func (_m *RoleManager) RoleRemoveMembers(ctx context.Context, session authn.Sess var r0 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok { - r0 = rf(ctx, session, entityID, roleName, members) + r0 = rf(ctx, session, entityID, roleID, members) } else { r0 = ret.Error(0) } @@ -415,9 +415,9 @@ func (_m *RoleManager) RoleRemoveMembers(ctx context.Context, session authn.Sess return r0 } -// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, oldRoleName, newRoleName -func (_m *RoleManager) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, oldRoleName string, newRoleName string) (roles.Role, error) { - ret := _m.Called(ctx, session, entityID, oldRoleName, newRoleName) +// UpdateRoleName provides a mock function with given fields: ctx, session, entityID, roleID, newRoleName +func (_m *RoleManager) UpdateRoleName(ctx context.Context, session authn.Session, entityID string, roleID string, newRoleName string) (roles.Role, error) { + ret := _m.Called(ctx, session, entityID, roleID, newRoleName) if len(ret) == 0 { panic("no return value specified for UpdateRoleName") @@ -426,16 +426,16 @@ func (_m *RoleManager) UpdateRoleName(ctx context.Context, session authn.Session var r0 roles.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) (roles.Role, error)); ok { - return rf(ctx, session, entityID, oldRoleName, newRoleName) + return rf(ctx, session, entityID, roleID, newRoleName) } if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string) roles.Role); ok { - r0 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r0 = rf(ctx, session, entityID, roleID, newRoleName) } else { r0 = ret.Get(0).(roles.Role) } if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string) error); ok { - r1 = rf(ctx, session, entityID, oldRoleName, newRoleName) + r1 = rf(ctx, session, entityID, roleID, newRoleName) } else { r1 = ret.Error(1) } diff --git a/pkg/roles/mocks/rolesRepo.go b/pkg/roles/mocks/rolesRepo.go index 995c629f20..9679e50d36 100644 --- a/pkg/roles/mocks/rolesRepo.go +++ b/pkg/roles/mocks/rolesRepo.go @@ -149,27 +149,27 @@ func (_m *Repository) RetrieveEntitiesRolesActionsMembers(ctx context.Context, e return r0, r1, r2 } -// RetrieveRole provides a mock function with given fields: ctx, roleID -func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Role, error) { - ret := _m.Called(ctx, roleID) +// RetrieveEntityRole provides a mock function with given fields: ctx, entityID, roleID +func (_m *Repository) RetrieveEntityRole(ctx context.Context, entityID string, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, entityID, roleID) if len(ret) == 0 { - panic("no return value specified for RetrieveRole") + panic("no return value specified for RetrieveEntityRole") } var r0 roles.Role var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (roles.Role, error)); ok { - return rf(ctx, roleID) + if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { + return rf(ctx, entityID, roleID) } - if rf, ok := ret.Get(0).(func(context.Context, string) roles.Role); ok { - r0 = rf(ctx, roleID) + if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { + r0 = rf(ctx, entityID, roleID) } else { r0 = ret.Get(0).(roles.Role) } - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, roleID) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, entityID, roleID) } else { r1 = ret.Error(1) } @@ -177,27 +177,27 @@ func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Ro return r0, r1 } -// RetrieveRoleByEntityIDAndName provides a mock function with given fields: ctx, entityID, roleName -func (_m *Repository) RetrieveRoleByEntityIDAndName(ctx context.Context, entityID string, roleName string) (roles.Role, error) { - ret := _m.Called(ctx, entityID, roleName) +// RetrieveRole provides a mock function with given fields: ctx, roleID +func (_m *Repository) RetrieveRole(ctx context.Context, roleID string) (roles.Role, error) { + ret := _m.Called(ctx, roleID) if len(ret) == 0 { - panic("no return value specified for RetrieveRoleByEntityIDAndName") + panic("no return value specified for RetrieveRole") } var r0 roles.Role var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (roles.Role, error)); ok { - return rf(ctx, entityID, roleName) + if rf, ok := ret.Get(0).(func(context.Context, string) (roles.Role, error)); ok { + return rf(ctx, roleID) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) roles.Role); ok { - r0 = rf(ctx, entityID, roleName) + if rf, ok := ret.Get(0).(func(context.Context, string) roles.Role); ok { + r0 = rf(ctx, roleID) } else { r0 = ret.Get(0).(roles.Role) } - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, entityID, roleName) + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, roleID) } else { r1 = ret.Error(1) } diff --git a/pkg/roles/rolemanager/events/events.go b/pkg/roles/rolemanager/events/events.go index 6039810a49..93da93573e 100644 --- a/pkg/roles/rolemanager/events/events.go +++ b/pkg/roles/rolemanager/events/events.go @@ -71,7 +71,6 @@ type removeRoleEvent struct { operationPrefix string entityID string roleID string - roleName string } func (rre removeRoleEvent) Encode() (map[string]interface{}, error) { @@ -79,7 +78,6 @@ func (rre removeRoleEvent) Encode() (map[string]interface{}, error) { "operation": rre.operationPrefix + removeRole, "entity_id": rre.entityID, "role_id": rre.roleID, - "role_name": rre.roleName, } return val, nil } @@ -154,7 +152,6 @@ type roleAddActionsEvent struct { operationPrefix string entityID string roleID string - roleName string actions []string } @@ -163,7 +160,6 @@ func (raae roleAddActionsEvent) Encode() (map[string]interface{}, error) { "operation": raae.operationPrefix + addRoleActions, "entity_id": raae.entityID, "role_id": raae.roleID, - "role_name": raae.roleName, "actions": raae.actions, } return val, nil @@ -173,7 +169,6 @@ type roleListActionsEvent struct { operationPrefix string entityID string roleID string - roleName string } func (rlae roleListActionsEvent) Encode() (map[string]interface{}, error) { @@ -181,7 +176,6 @@ func (rlae roleListActionsEvent) Encode() (map[string]interface{}, error) { "operation": rlae.operationPrefix + listRoleActions, "entity_id": rlae.entityID, "role_id": rlae.roleID, - "role_name": rlae.roleName, } return val, nil } @@ -190,7 +184,6 @@ type roleCheckActionsExistsEvent struct { operationPrefix string entityID string roleID string - roleName string actions []string isAllExists bool } @@ -200,7 +193,6 @@ func (rcaee roleCheckActionsExistsEvent) Encode() (map[string]interface{}, error "operation": rcaee.operationPrefix + checkRoleActions, "entity_id": rcaee.entityID, "role_id": rcaee.roleID, - "role_name": rcaee.roleName, "actions": rcaee.actions, "is_all_exists": rcaee.isAllExists, } @@ -211,7 +203,6 @@ type roleRemoveActionsEvent struct { operationPrefix string entityID string roleID string - roleName string actions []string } @@ -220,7 +211,6 @@ func (rrae roleRemoveActionsEvent) Encode() (map[string]interface{}, error) { "operation": rrae.operationPrefix + removeRoleActions, "entity_id": rrae.entityID, "role_id": rrae.roleID, - "role_name": rrae.roleName, "actions": rrae.actions, } return val, nil @@ -230,7 +220,6 @@ type roleRemoveAllActionsEvent struct { operationPrefix string entityID string roleID string - roleName string } func (rraae roleRemoveAllActionsEvent) Encode() (map[string]interface{}, error) { @@ -238,7 +227,6 @@ func (rraae roleRemoveAllActionsEvent) Encode() (map[string]interface{}, error) "operation": rraae.operationPrefix + removeAllRoleActions, "entity_id": rraae.entityID, "role_id": rraae.roleID, - "role_name": rraae.roleName, } return val, nil } @@ -247,7 +235,6 @@ type roleAddMembersEvent struct { operationPrefix string entityID string roleID string - roleName string members []string } @@ -256,7 +243,6 @@ func (rame roleAddMembersEvent) Encode() (map[string]interface{}, error) { "operation": rame.operationPrefix + addRoleMembers, "entity_id": rame.entityID, "role_id": rame.roleID, - "role_name": rame.roleName, "members": rame.members, } return val, nil @@ -266,7 +252,6 @@ type roleListMembersEvent struct { operationPrefix string entityID string roleID string - roleName string limit uint64 offset uint64 } @@ -276,7 +261,6 @@ func (rlme roleListMembersEvent) Encode() (map[string]interface{}, error) { "operation": rlme.operationPrefix + listRoleMembers, "entity_id": rlme.entityID, "role_id": rlme.roleID, - "role_name": rlme.roleName, "limit": rlme.limit, "offset": rlme.offset, } @@ -287,7 +271,6 @@ type roleCheckMembersExistsEvent struct { operationPrefix string entityID string roleID string - roleName string members []string } @@ -296,7 +279,6 @@ func (rcmee roleCheckMembersExistsEvent) Encode() (map[string]interface{}, error "operation": rcmee.operationPrefix + checkRoleMembers, "entity_id": rcmee.entityID, "role_id": rcmee.roleID, - "role_name": rcmee.roleName, "members": rcmee.members, } return val, nil @@ -306,7 +288,6 @@ type roleRemoveMembersEvent struct { operationPrefix string entityID string roleID string - roleName string members []string } @@ -315,7 +296,6 @@ func (rrme roleRemoveMembersEvent) Encode() (map[string]interface{}, error) { "operation": rrme.operationPrefix + removeRoleMembers, "entity_id": rrme.entityID, "role_id": rrme.roleID, - "role_name": rrme.roleName, "members": rrme.members, } return val, nil @@ -325,7 +305,6 @@ type roleRemoveAllMembersEvent struct { operationPrefix string entityID string roleID string - roleName string } func (rrame roleRemoveAllMembersEvent) Encode() (map[string]interface{}, error) { @@ -333,7 +312,6 @@ func (rrame roleRemoveAllMembersEvent) Encode() (map[string]interface{}, error) "operation": rrame.operationPrefix + removeRoleAllMembers, "entity_id": rrame.entityID, "role_id": rrame.roleID, - "role_name": rrame.roleName, } return val, nil } diff --git a/pkg/roles/rolemanager/events/streams.go b/pkg/roles/rolemanager/events/streams.go index 12e687cdcc..a72a193ead 100644 --- a/pkg/roles/rolemanager/events/streams.go +++ b/pkg/roles/rolemanager/events/streams.go @@ -46,13 +46,13 @@ func (rmes *RoleManagerEventStore) AddRole(ctx context.Context, session authn.Se return ro, nil } -func (rmes *RoleManagerEventStore) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error { - if err := rmes.svc.RemoveRole(ctx, session, entityID, roleName); err != nil { +func (rmes *RoleManagerEventStore) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error { + if err := rmes.svc.RemoveRole(ctx, session, entityID, roleID); err != nil { return err } e := removeRoleEvent{ operationPrefix: rmes.operationPrefix, - roleName: roleName, + roleID: roleID, entityID: entityID, } if err := rmes.Publish(ctx, e); err != nil { @@ -61,8 +61,8 @@ func (rmes *RoleManagerEventStore) RemoveRole(ctx context.Context, session authn return nil } -func (rmes *RoleManagerEventStore) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (roles.Role, error) { - ro, err := rmes.svc.UpdateRoleName(ctx, session, entityID, oldRoleName, newRoleName) +func (rmes *RoleManagerEventStore) UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (roles.Role, error) { + ro, err := rmes.svc.UpdateRoleName(ctx, session, entityID, roleID, newRoleName) if err != nil { return ro, err } @@ -77,8 +77,8 @@ func (rmes *RoleManagerEventStore) UpdateRoleName(ctx context.Context, session a return ro, nil } -func (rmes *RoleManagerEventStore) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (roles.Role, error) { - ro, err := rmes.svc.RetrieveRole(ctx, session, entityID, roleName) +func (rmes *RoleManagerEventStore) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (roles.Role, error) { + ro, err := rmes.svc.RetrieveRole(ctx, session, entityID, roleID) if err != nil { return ro, err } @@ -124,15 +124,15 @@ func (rmes *RoleManagerEventStore) ListAvailableActions(ctx context.Context, ses return actions, nil } -func (rmes *RoleManagerEventStore) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) ([]string, error) { - actions, err := rmes.svc.RoleAddActions(ctx, session, entityID, roleName, actions) +func (rmes *RoleManagerEventStore) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) ([]string, error) { + actions, err := rmes.svc.RoleAddActions(ctx, session, entityID, roleID, actions) if err != nil { return actions, err } e := roleAddActionsEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, actions: actions, } if err := rmes.Publish(ctx, e); err != nil { @@ -141,8 +141,8 @@ func (rmes *RoleManagerEventStore) RoleAddActions(ctx context.Context, session a return actions, nil } -func (rmes *RoleManagerEventStore) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) { - actions, err := rmes.svc.RoleListActions(ctx, session, entityID, roleName) +func (rmes *RoleManagerEventStore) RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) ([]string, error) { + actions, err := rmes.svc.RoleListActions(ctx, session, entityID, roleID) if err != nil { return actions, err } @@ -150,7 +150,7 @@ func (rmes *RoleManagerEventStore) RoleListActions(ctx context.Context, session e := roleListActionsEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, } if err := rmes.Publish(ctx, e); err != nil { return actions, err @@ -158,8 +158,8 @@ func (rmes *RoleManagerEventStore) RoleListActions(ctx context.Context, session return actions, nil } -func (rmes *RoleManagerEventStore) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) { - isAllExists, err := rmes.svc.RoleCheckActionsExists(ctx, session, entityID, roleName, actions) +func (rmes *RoleManagerEventStore) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) { + isAllExists, err := rmes.svc.RoleCheckActionsExists(ctx, session, entityID, roleID, actions) if err != nil { return isAllExists, err } @@ -167,7 +167,7 @@ func (rmes *RoleManagerEventStore) RoleCheckActionsExists(ctx context.Context, s e := roleCheckActionsExistsEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, actions: actions, isAllExists: isAllExists, } @@ -177,15 +177,15 @@ func (rmes *RoleManagerEventStore) RoleCheckActionsExists(ctx context.Context, s return isAllExists, nil } -func (rmes *RoleManagerEventStore) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) { - if err := rmes.svc.RoleRemoveActions(ctx, session, entityID, roleName, actions); err != nil { +func (rmes *RoleManagerEventStore) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) { + if err := rmes.svc.RoleRemoveActions(ctx, session, entityID, roleID, actions); err != nil { return err } e := roleRemoveActionsEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, actions: actions, } if err := rmes.Publish(ctx, e); err != nil { @@ -194,15 +194,15 @@ func (rmes *RoleManagerEventStore) RoleRemoveActions(ctx context.Context, sessio return nil } -func (rmes *RoleManagerEventStore) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error { - if err := rmes.svc.RoleRemoveAllActions(ctx, session, entityID, roleName); err != nil { +func (rmes *RoleManagerEventStore) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) error { + if err := rmes.svc.RoleRemoveAllActions(ctx, session, entityID, roleID); err != nil { return err } e := roleRemoveAllActionsEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, } if err := rmes.Publish(ctx, e); err != nil { return err @@ -210,8 +210,8 @@ func (rmes *RoleManagerEventStore) RoleRemoveAllActions(ctx context.Context, ses return nil } -func (rmes *RoleManagerEventStore) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error) { - mems, err := rmes.svc.RoleAddMembers(ctx, session, entityID, roleName, members) +func (rmes *RoleManagerEventStore) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) ([]string, error) { + mems, err := rmes.svc.RoleAddMembers(ctx, session, entityID, roleID, members) if err != nil { return mems, err } @@ -219,7 +219,7 @@ func (rmes *RoleManagerEventStore) RoleAddMembers(ctx context.Context, session a e := roleAddMembersEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, members: members, } if err := rmes.Publish(ctx, e); err != nil { @@ -228,8 +228,8 @@ func (rmes *RoleManagerEventStore) RoleAddMembers(ctx context.Context, session a return mems, nil } -func (rmes *RoleManagerEventStore) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (roles.MembersPage, error) { - mp, err := rmes.svc.RoleListMembers(ctx, session, entityID, roleName, limit, offset) +func (rmes *RoleManagerEventStore) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (roles.MembersPage, error) { + mp, err := rmes.svc.RoleListMembers(ctx, session, entityID, roleID, limit, offset) if err != nil { return mp, err } @@ -237,7 +237,7 @@ func (rmes *RoleManagerEventStore) RoleListMembers(ctx context.Context, session e := roleListMembersEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, limit: limit, offset: offset, } @@ -247,8 +247,8 @@ func (rmes *RoleManagerEventStore) RoleListMembers(ctx context.Context, session return mp, nil } -func (rmes *RoleManagerEventStore) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) { - isAllExists, err := rmes.svc.RoleCheckMembersExists(ctx, session, entityID, roleName, members) +func (rmes *RoleManagerEventStore) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) { + isAllExists, err := rmes.svc.RoleCheckMembersExists(ctx, session, entityID, roleID, members) if err != nil { return isAllExists, err } @@ -256,7 +256,7 @@ func (rmes *RoleManagerEventStore) RoleCheckMembersExists(ctx context.Context, s e := roleCheckMembersExistsEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, members: members, } if err := rmes.Publish(ctx, e); err != nil { @@ -265,15 +265,15 @@ func (rmes *RoleManagerEventStore) RoleCheckMembersExists(ctx context.Context, s return isAllExists, nil } -func (rmes *RoleManagerEventStore) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) { - if err := rmes.svc.RoleRemoveMembers(ctx, session, entityID, roleName, members); err != nil { +func (rmes *RoleManagerEventStore) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) { + if err := rmes.svc.RoleRemoveMembers(ctx, session, entityID, roleID, members); err != nil { return err } e := roleRemoveMembersEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, members: members, } if err := rmes.Publish(ctx, e); err != nil { @@ -282,15 +282,15 @@ func (rmes *RoleManagerEventStore) RoleRemoveMembers(ctx context.Context, sessio return nil } -func (rmes *RoleManagerEventStore) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { - if err := rmes.svc.RoleRemoveAllMembers(ctx, session, entityID, roleName); err != nil { +func (rmes *RoleManagerEventStore) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { + if err := rmes.svc.RoleRemoveAllMembers(ctx, session, entityID, roleID); err != nil { return err } e := roleRemoveAllMembersEvent{ operationPrefix: rmes.operationPrefix, entityID: entityID, - roleName: roleName, + roleID: roleID, } if err := rmes.Publish(ctx, e); err != nil { return err diff --git a/pkg/roles/rolemanager/middleware/authoirzation.go b/pkg/roles/rolemanager/middleware/authoirzation.go index 893ef6468e..c54235fedc 100644 --- a/pkg/roles/rolemanager/middleware/authoirzation.go +++ b/pkg/roles/rolemanager/middleware/authoirzation.go @@ -66,7 +66,7 @@ func (ram RoleManagerAuthorizationMiddleware) AddRole(ctx context.Context, sessi return ram.svc.AddRole(ctx, session, entityID, roleName, optionalActions, optionalMembers) } -func (ram RoleManagerAuthorizationMiddleware) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error { +func (ram RoleManagerAuthorizationMiddleware) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error { if err := ram.authorize(ctx, roles.OpRemoveRole, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -77,10 +77,10 @@ func (ram RoleManagerAuthorizationMiddleware) RemoveRole(ctx context.Context, se }); err != nil { return err } - return ram.svc.RemoveRole(ctx, session, entityID, roleName) + return ram.svc.RemoveRole(ctx, session, entityID, roleID) } -func (ram RoleManagerAuthorizationMiddleware) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (roles.Role, error) { +func (ram RoleManagerAuthorizationMiddleware) UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (roles.Role, error) { if err := ram.authorize(ctx, roles.OpUpdateRoleName, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -91,10 +91,10 @@ func (ram RoleManagerAuthorizationMiddleware) UpdateRoleName(ctx context.Context }); err != nil { return roles.Role{}, err } - return ram.svc.UpdateRoleName(ctx, session, entityID, oldRoleName, newRoleName) + return ram.svc.UpdateRoleName(ctx, session, entityID, roleID, newRoleName) } -func (ram RoleManagerAuthorizationMiddleware) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (roles.Role, error) { +func (ram RoleManagerAuthorizationMiddleware) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (roles.Role, error) { if err := ram.authorize(ctx, roles.OpRetrieveRole, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -105,7 +105,7 @@ func (ram RoleManagerAuthorizationMiddleware) RetrieveRole(ctx context.Context, }); err != nil { return roles.Role{}, err } - return ram.svc.RetrieveRole(ctx, session, entityID, roleName) + return ram.svc.RetrieveRole(ctx, session, entityID, roleID) } func (ram RoleManagerAuthorizationMiddleware) RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (roles.RolePage, error) { @@ -126,7 +126,7 @@ func (ram RoleManagerAuthorizationMiddleware) ListAvailableActions(ctx context.C return ram.svc.ListAvailableActions(ctx, session) } -func (ram RoleManagerAuthorizationMiddleware) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (ops []string, err error) { +func (ram RoleManagerAuthorizationMiddleware) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (ops []string, err error) { if err := ram.authorize(ctx, roles.OpRoleAddActions, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -138,10 +138,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleAddActions(ctx context.Context return []string{}, err } - return ram.svc.RoleAddActions(ctx, session, entityID, roleName, actions) + return ram.svc.RoleAddActions(ctx, session, entityID, roleID, actions) } -func (ram RoleManagerAuthorizationMiddleware) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) { +func (ram RoleManagerAuthorizationMiddleware) RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) ([]string, error) { if err := ram.authorize(ctx, roles.OpRoleListActions, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -153,10 +153,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleListActions(ctx context.Contex return []string{}, err } - return ram.svc.RoleListActions(ctx, session, entityID, roleName) + return ram.svc.RoleListActions(ctx, session, entityID, roleID) } -func (ram RoleManagerAuthorizationMiddleware) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) { +func (ram RoleManagerAuthorizationMiddleware) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) { if err := ram.authorize(ctx, roles.OpRoleCheckActionsExists, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -167,10 +167,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleCheckActionsExists(ctx context }); err != nil { return false, err } - return ram.svc.RoleCheckActionsExists(ctx, session, entityID, roleName, actions) + return ram.svc.RoleCheckActionsExists(ctx, session, entityID, roleID, actions) } -func (ram RoleManagerAuthorizationMiddleware) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) { +func (ram RoleManagerAuthorizationMiddleware) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) { if err := ram.authorize(ctx, roles.OpRoleRemoveActions, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -181,10 +181,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleRemoveActions(ctx context.Cont }); err != nil { return err } - return ram.svc.RoleRemoveActions(ctx, session, entityID, roleName, actions) + return ram.svc.RoleRemoveActions(ctx, session, entityID, roleID, actions) } -func (ram RoleManagerAuthorizationMiddleware) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error { +func (ram RoleManagerAuthorizationMiddleware) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) error { if err := ram.authorize(ctx, roles.OpRoleRemoveAllActions, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -195,10 +195,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleRemoveAllActions(ctx context.C }); err != nil { return err } - return ram.svc.RoleRemoveAllActions(ctx, session, entityID, roleName) + return ram.svc.RoleRemoveAllActions(ctx, session, entityID, roleID) } -func (ram RoleManagerAuthorizationMiddleware) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error) { +func (ram RoleManagerAuthorizationMiddleware) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) ([]string, error) { if err := ram.authorize(ctx, roles.OpRoleAddMembers, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -209,10 +209,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleAddMembers(ctx context.Context }); err != nil { return []string{}, err } - return ram.svc.RoleAddMembers(ctx, session, entityID, roleName, members) + return ram.svc.RoleAddMembers(ctx, session, entityID, roleID, members) } -func (ram RoleManagerAuthorizationMiddleware) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (roles.MembersPage, error) { +func (ram RoleManagerAuthorizationMiddleware) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (roles.MembersPage, error) { if err := ram.authorize(ctx, roles.OpRoleListMembers, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -223,10 +223,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleListMembers(ctx context.Contex }); err != nil { return roles.MembersPage{}, err } - return ram.svc.RoleListMembers(ctx, session, entityID, roleName, limit, offset) + return ram.svc.RoleListMembers(ctx, session, entityID, roleID, limit, offset) } -func (ram RoleManagerAuthorizationMiddleware) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) { +func (ram RoleManagerAuthorizationMiddleware) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) { if err := ram.authorize(ctx, roles.OpRoleCheckMembersExists, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -237,10 +237,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleCheckMembersExists(ctx context }); err != nil { return false, err } - return ram.svc.RoleCheckMembersExists(ctx, session, entityID, roleName, members) + return ram.svc.RoleCheckMembersExists(ctx, session, entityID, roleID, members) } -func (ram RoleManagerAuthorizationMiddleware) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) { +func (ram RoleManagerAuthorizationMiddleware) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) { if err := ram.authorize(ctx, roles.OpRoleRemoveMembers, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -251,10 +251,10 @@ func (ram RoleManagerAuthorizationMiddleware) RoleRemoveMembers(ctx context.Cont }); err != nil { return err } - return ram.svc.RoleRemoveMembers(ctx, session, entityID, roleName, members) + return ram.svc.RoleRemoveMembers(ctx, session, entityID, roleID, members) } -func (ram RoleManagerAuthorizationMiddleware) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { +func (ram RoleManagerAuthorizationMiddleware) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { if err := ram.authorize(ctx, roles.OpRoleRemoveAllMembers, smqauthz.PolicyReq{ Domain: session.DomainID, Subject: session.DomainUserID, @@ -265,7 +265,7 @@ func (ram RoleManagerAuthorizationMiddleware) RoleRemoveAllMembers(ctx context.C }); err != nil { return err } - return ram.svc.RoleRemoveAllMembers(ctx, session, entityID, roleName) + return ram.svc.RoleRemoveAllMembers(ctx, session, entityID, roleID) } func (ram RoleManagerAuthorizationMiddleware) authorize(ctx context.Context, op svcutil.Operation, pr smqauthz.PolicyReq) error { diff --git a/pkg/roles/rolemanager/middleware/logging.go b/pkg/roles/rolemanager/middleware/logging.go index a5cb9076a8..951e430dad 100644 --- a/pkg/roles/rolemanager/middleware/logging.go +++ b/pkg/roles/rolemanager/middleware/logging.go @@ -53,14 +53,14 @@ func (lm *RoleManagerLoggingMiddleware) AddRole(ctx context.Context, session aut return lm.svc.AddRole(ctx, session, entityID, roleName, optionalActions, optionalMembers) } -func (lm *RoleManagerLoggingMiddleware) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { +func (lm *RoleManagerLoggingMiddleware) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { prefix := fmt.Sprintf("Delete %s role", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_delete_role", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), ), } if err != nil { @@ -70,17 +70,17 @@ func (lm *RoleManagerLoggingMiddleware) RemoveRole(ctx context.Context, session } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RemoveRole(ctx, session, entityID, roleName) + return lm.svc.RemoveRole(ctx, session, entityID, roleID) } -func (lm *RoleManagerLoggingMiddleware) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (ro roles.Role, err error) { +func (lm *RoleManagerLoggingMiddleware) UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (ro roles.Role, err error) { prefix := fmt.Sprintf("Update %s role name", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_update_role_name", slog.String("entity_id", entityID), - slog.String("old_role_name", oldRoleName), + slog.String("role_id", roleID), slog.String("new_role_name", newRoleName), ), } @@ -91,17 +91,17 @@ func (lm *RoleManagerLoggingMiddleware) UpdateRoleName(ctx context.Context, sess } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.UpdateRoleName(ctx, session, entityID, oldRoleName, newRoleName) + return lm.svc.UpdateRoleName(ctx, session, entityID, roleID, newRoleName) } -func (lm *RoleManagerLoggingMiddleware) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (ro roles.Role, err error) { +func (lm *RoleManagerLoggingMiddleware) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (ro roles.Role, err error) { prefix := fmt.Sprintf("Retrieve %s role", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), - slog.Group(lm.svcName+"_update_role_name", + slog.Group(lm.svcName+"_retrieve_role", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), ), } if err != nil { @@ -111,7 +111,7 @@ func (lm *RoleManagerLoggingMiddleware) RetrieveRole(ctx context.Context, sessio } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RetrieveRole(ctx, session, entityID, roleName) + return lm.svc.RetrieveRole(ctx, session, entityID, roleID) } func (lm *RoleManagerLoggingMiddleware) RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (rp roles.RolePage, err error) { @@ -152,14 +152,14 @@ func (lm *RoleManagerLoggingMiddleware) ListAvailableActions(ctx context.Context return lm.svc.ListAvailableActions(ctx, session) } -func (lm *RoleManagerLoggingMiddleware) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (caps []string, err error) { +func (lm *RoleManagerLoggingMiddleware) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (caps []string, err error) { prefix := fmt.Sprintf("%s role add actions", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_add_actions", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), slog.Any("actions", actions), ), } @@ -170,17 +170,17 @@ func (lm *RoleManagerLoggingMiddleware) RoleAddActions(ctx context.Context, sess } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleAddActions(ctx, session, entityID, roleName, actions) + return lm.svc.RoleAddActions(ctx, session, entityID, roleID, actions) } -func (lm *RoleManagerLoggingMiddleware) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) (roOps []string, err error) { +func (lm *RoleManagerLoggingMiddleware) RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) (roOps []string, err error) { prefix := fmt.Sprintf("%s role list actions", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_list_role_actions", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), ), } if err != nil { @@ -190,21 +190,21 @@ func (lm *RoleManagerLoggingMiddleware) RoleListActions(ctx context.Context, ses } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleListActions(ctx, session, entityID, roleName) + return lm.svc.RoleListActions(ctx, session, entityID, roleID) } -func (lm *RoleManagerLoggingMiddleware) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) { - return lm.svc.RoleCheckActionsExists(ctx, session, entityID, roleName, actions) +func (lm *RoleManagerLoggingMiddleware) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) { + return lm.svc.RoleCheckActionsExists(ctx, session, entityID, roleID, actions) } -func (lm *RoleManagerLoggingMiddleware) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) { +func (lm *RoleManagerLoggingMiddleware) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) { prefix := fmt.Sprintf("%s role remove actions", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_remove_actions", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), slog.Any("actions", actions), ), } @@ -215,17 +215,17 @@ func (lm *RoleManagerLoggingMiddleware) RoleRemoveActions(ctx context.Context, s } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleRemoveActions(ctx, session, entityID, roleName, actions) + return lm.svc.RoleRemoveActions(ctx, session, entityID, roleID, actions) } -func (lm *RoleManagerLoggingMiddleware) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { +func (lm *RoleManagerLoggingMiddleware) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { prefix := fmt.Sprintf("%s role remove all actions", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_remove_all_actions", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), ), } if err != nil { @@ -235,17 +235,17 @@ func (lm *RoleManagerLoggingMiddleware) RoleRemoveAllActions(ctx context.Context } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleRemoveAllActions(ctx, session, entityID, roleName) + return lm.svc.RoleRemoveAllActions(ctx, session, entityID, roleID) } -func (lm *RoleManagerLoggingMiddleware) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (mems []string, err error) { +func (lm *RoleManagerLoggingMiddleware) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (mems []string, err error) { prefix := fmt.Sprintf("%s role add members", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_add_members", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), slog.Any("members", members), ), } @@ -256,17 +256,17 @@ func (lm *RoleManagerLoggingMiddleware) RoleAddMembers(ctx context.Context, sess } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleAddMembers(ctx, session, entityID, roleName, members) + return lm.svc.RoleAddMembers(ctx, session, entityID, roleID, members) } -func (lm *RoleManagerLoggingMiddleware) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (mp roles.MembersPage, err error) { +func (lm *RoleManagerLoggingMiddleware) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (mp roles.MembersPage, err error) { prefix := fmt.Sprintf("%s role list members", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_add_members", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), slog.Uint64("limit", limit), slog.Uint64("offset", offset), ), @@ -278,21 +278,21 @@ func (lm *RoleManagerLoggingMiddleware) RoleListMembers(ctx context.Context, ses } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleListMembers(ctx, session, entityID, roleName, limit, offset) + return lm.svc.RoleListMembers(ctx, session, entityID, roleID, limit, offset) } -func (lm *RoleManagerLoggingMiddleware) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) { - return lm.svc.RoleCheckMembersExists(ctx, session, entityID, roleName, members) +func (lm *RoleManagerLoggingMiddleware) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) { + return lm.svc.RoleCheckMembersExists(ctx, session, entityID, roleID, members) } -func (lm *RoleManagerLoggingMiddleware) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) { +func (lm *RoleManagerLoggingMiddleware) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) { prefix := fmt.Sprintf("%s role remove members", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_remove_members", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), slog.Any("members", members), ), } @@ -303,17 +303,17 @@ func (lm *RoleManagerLoggingMiddleware) RoleRemoveMembers(ctx context.Context, s } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleRemoveMembers(ctx, session, entityID, roleName, members) + return lm.svc.RoleRemoveMembers(ctx, session, entityID, roleID, members) } -func (lm *RoleManagerLoggingMiddleware) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { +func (lm *RoleManagerLoggingMiddleware) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { prefix := fmt.Sprintf("%s role remove all members", lm.svcName) defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), slog.Group(lm.svcName+"_role_remove_all_members", slog.String("entity_id", entityID), - slog.String("role_name", roleName), + slog.String("role_id", roleID), ), } if err != nil { @@ -323,7 +323,7 @@ func (lm *RoleManagerLoggingMiddleware) RoleRemoveAllMembers(ctx context.Context } lm.logger.Info(prefix+" completed successfully", args...) }(time.Now()) - return lm.svc.RoleRemoveAllMembers(ctx, session, entityID, roleName) + return lm.svc.RoleRemoveAllMembers(ctx, session, entityID, roleID) } func (lm *RoleManagerLoggingMiddleware) RemoveMemberFromAllRoles(ctx context.Context, session authn.Session, memberID string) (err error) { diff --git a/pkg/roles/rolemanager/middleware/meterics.go b/pkg/roles/rolemanager/middleware/meterics.go index 4314920a13..fd8e1f31f1 100644 --- a/pkg/roles/rolemanager/middleware/meterics.go +++ b/pkg/roles/rolemanager/middleware/meterics.go @@ -35,16 +35,16 @@ func (rmm *RoleManagerMetricsMiddleware) AddRole(ctx context.Context, session au return rmm.svc.AddRole(ctx, session, entityID, roleName, optionalActions, optionalMembers) } -func (rmm *RoleManagerMetricsMiddleware) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error { - return rmm.svc.RemoveRole(ctx, session, entityID, roleName) +func (rmm *RoleManagerMetricsMiddleware) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error { + return rmm.svc.RemoveRole(ctx, session, entityID, roleID) } -func (rmm *RoleManagerMetricsMiddleware) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (roles.Role, error) { - return rmm.svc.UpdateRoleName(ctx, session, entityID, oldRoleName, newRoleName) +func (rmm *RoleManagerMetricsMiddleware) UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (roles.Role, error) { + return rmm.svc.UpdateRoleName(ctx, session, entityID, roleID, newRoleName) } -func (rmm *RoleManagerMetricsMiddleware) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (roles.Role, error) { - return rmm.svc.RetrieveRole(ctx, session, entityID, roleName) +func (rmm *RoleManagerMetricsMiddleware) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (roles.Role, error) { + return rmm.svc.RetrieveRole(ctx, session, entityID, roleID) } func (rmm *RoleManagerMetricsMiddleware) RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (roles.RolePage, error) { @@ -55,44 +55,44 @@ func (rmm *RoleManagerMetricsMiddleware) ListAvailableActions(ctx context.Contex return rmm.svc.ListAvailableActions(ctx, session) } -func (rmm *RoleManagerMetricsMiddleware) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (caps []string, err error) { - return rmm.svc.RoleAddActions(ctx, session, entityID, roleName, actions) +func (rmm *RoleManagerMetricsMiddleware) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (caps []string, err error) { + return rmm.svc.RoleAddActions(ctx, session, entityID, roleID, actions) } -func (rmm *RoleManagerMetricsMiddleware) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) { - return rmm.svc.RoleListActions(ctx, session, entityID, roleName) +func (rmm *RoleManagerMetricsMiddleware) RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) ([]string, error) { + return rmm.svc.RoleListActions(ctx, session, entityID, roleID) } -func (rmm *RoleManagerMetricsMiddleware) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) { - return rmm.svc.RoleCheckActionsExists(ctx, session, entityID, roleName, actions) +func (rmm *RoleManagerMetricsMiddleware) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) { + return rmm.svc.RoleCheckActionsExists(ctx, session, entityID, roleID, actions) } -func (rmm *RoleManagerMetricsMiddleware) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) { - return rmm.svc.RoleRemoveActions(ctx, session, entityID, roleName, actions) +func (rmm *RoleManagerMetricsMiddleware) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) { + return rmm.svc.RoleRemoveActions(ctx, session, entityID, roleID, actions) } -func (rmm *RoleManagerMetricsMiddleware) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error { - return rmm.svc.RoleRemoveAllActions(ctx, session, entityID, roleName) +func (rmm *RoleManagerMetricsMiddleware) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) error { + return rmm.svc.RoleRemoveAllActions(ctx, session, entityID, roleID) } -func (rmm *RoleManagerMetricsMiddleware) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error) { - return rmm.svc.RoleAddMembers(ctx, session, entityID, roleName, members) +func (rmm *RoleManagerMetricsMiddleware) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) ([]string, error) { + return rmm.svc.RoleAddMembers(ctx, session, entityID, roleID, members) } -func (rmm *RoleManagerMetricsMiddleware) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (roles.MembersPage, error) { - return rmm.svc.RoleListMembers(ctx, session, entityID, roleName, limit, offset) +func (rmm *RoleManagerMetricsMiddleware) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (roles.MembersPage, error) { + return rmm.svc.RoleListMembers(ctx, session, entityID, roleID, limit, offset) } -func (rmm *RoleManagerMetricsMiddleware) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) { - return rmm.svc.RoleCheckMembersExists(ctx, session, entityID, roleName, members) +func (rmm *RoleManagerMetricsMiddleware) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) { + return rmm.svc.RoleCheckMembersExists(ctx, session, entityID, roleID, members) } -func (rmm *RoleManagerMetricsMiddleware) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) { - return rmm.svc.RoleRemoveMembers(ctx, session, entityID, roleName, members) +func (rmm *RoleManagerMetricsMiddleware) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) { + return rmm.svc.RoleRemoveMembers(ctx, session, entityID, roleID, members) } -func (rmm *RoleManagerMetricsMiddleware) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { - return rmm.svc.RoleRemoveAllMembers(ctx, session, entityID, roleName) +func (rmm *RoleManagerMetricsMiddleware) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { + return rmm.svc.RoleRemoveAllMembers(ctx, session, entityID, roleID) } func (rmm *RoleManagerMetricsMiddleware) RemoveMemberFromAllRoles(ctx context.Context, session authn.Session, memberID string) (err error) { diff --git a/pkg/roles/rolemanager/tracing/tracing.go b/pkg/roles/rolemanager/tracing/tracing.go index 4a16570919..15b3ce5b10 100644 --- a/pkg/roles/rolemanager/tracing/tracing.go +++ b/pkg/roles/rolemanager/tracing/tracing.go @@ -27,16 +27,16 @@ func (rtm *RoleManagerTracing) AddRole(ctx context.Context, session authn.Sessio return rtm.roles.AddRole(ctx, session, entityID, roleName, optionalActions, optionalMembers) } -func (rtm *RoleManagerTracing) RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error { - return rtm.roles.RemoveRole(ctx, session, entityID, roleName) +func (rtm *RoleManagerTracing) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error { + return rtm.roles.RemoveRole(ctx, session, entityID, roleID) } -func (rtm *RoleManagerTracing) UpdateRoleName(ctx context.Context, session authn.Session, entityID, oldRoleName, newRoleName string) (roles.Role, error) { - return rtm.roles.UpdateRoleName(ctx, session, entityID, oldRoleName, newRoleName) +func (rtm *RoleManagerTracing) UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (roles.Role, error) { + return rtm.roles.UpdateRoleName(ctx, session, entityID, roleID, newRoleName) } -func (rtm *RoleManagerTracing) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleName string) (roles.Role, error) { - return rtm.roles.RetrieveRole(ctx, session, entityID, roleName) +func (rtm *RoleManagerTracing) RetrieveRole(ctx context.Context, session authn.Session, entityID, roleID string) (roles.Role, error) { + return rtm.roles.RetrieveRole(ctx, session, entityID, roleID) } func (rtm *RoleManagerTracing) RetrieveAllRoles(ctx context.Context, session authn.Session, entityID string, limit, offset uint64) (roles.RolePage, error) { @@ -47,44 +47,44 @@ func (rtm *RoleManagerTracing) ListAvailableActions(ctx context.Context, session return rtm.roles.ListAvailableActions(ctx, session) } -func (rtm *RoleManagerTracing) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (ops []string, err error) { - return rtm.roles.RoleAddActions(ctx, session, entityID, roleName, actions) +func (rtm *RoleManagerTracing) RoleAddActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (ops []string, err error) { + return rtm.roles.RoleAddActions(ctx, session, entityID, roleID, actions) } -func (rtm *RoleManagerTracing) RoleListActions(ctx context.Context, session authn.Session, entityID, roleName string) ([]string, error) { - return rtm.roles.RoleListActions(ctx, session, entityID, roleName) +func (rtm *RoleManagerTracing) RoleListActions(ctx context.Context, session authn.Session, entityID, roleID string) ([]string, error) { + return rtm.roles.RoleListActions(ctx, session, entityID, roleID) } -func (rtm *RoleManagerTracing) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (bool, error) { - return rtm.roles.RoleCheckActionsExists(ctx, session, entityID, roleName, actions) +func (rtm *RoleManagerTracing) RoleCheckActionsExists(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (bool, error) { + return rtm.roles.RoleCheckActionsExists(ctx, session, entityID, roleID, actions) } -func (rtm *RoleManagerTracing) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleName string, actions []string) (err error) { - return rtm.roles.RoleRemoveActions(ctx, session, entityID, roleName, actions) +func (rtm *RoleManagerTracing) RoleRemoveActions(ctx context.Context, session authn.Session, entityID, roleID string, actions []string) (err error) { + return rtm.roles.RoleRemoveActions(ctx, session, entityID, roleID, actions) } -func (rtm *RoleManagerTracing) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleName string) error { - return rtm.roles.RoleRemoveAllActions(ctx, session, entityID, roleName) +func (rtm *RoleManagerTracing) RoleRemoveAllActions(ctx context.Context, session authn.Session, entityID, roleID string) error { + return rtm.roles.RoleRemoveAllActions(ctx, session, entityID, roleID) } -func (rtm *RoleManagerTracing) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) ([]string, error) { - return rtm.roles.RoleAddMembers(ctx, session, entityID, roleName, members) +func (rtm *RoleManagerTracing) RoleAddMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) ([]string, error) { + return rtm.roles.RoleAddMembers(ctx, session, entityID, roleID, members) } -func (rtm *RoleManagerTracing) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleName string, limit, offset uint64) (roles.MembersPage, error) { - return rtm.roles.RoleListMembers(ctx, session, entityID, roleName, limit, offset) +func (rtm *RoleManagerTracing) RoleListMembers(ctx context.Context, session authn.Session, entityID, roleID string, limit, offset uint64) (roles.MembersPage, error) { + return rtm.roles.RoleListMembers(ctx, session, entityID, roleID, limit, offset) } -func (rtm *RoleManagerTracing) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (bool, error) { - return rtm.roles.RoleCheckMembersExists(ctx, session, entityID, roleName, members) +func (rtm *RoleManagerTracing) RoleCheckMembersExists(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (bool, error) { + return rtm.roles.RoleCheckMembersExists(ctx, session, entityID, roleID, members) } -func (rtm *RoleManagerTracing) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleName string, members []string) (err error) { - return rtm.roles.RoleRemoveMembers(ctx, session, entityID, roleName, members) +func (rtm *RoleManagerTracing) RoleRemoveMembers(ctx context.Context, session authn.Session, entityID, roleID string, members []string) (err error) { + return rtm.roles.RoleRemoveMembers(ctx, session, entityID, roleID, members) } -func (rtm *RoleManagerTracing) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleName string) (err error) { - return rtm.roles.RoleRemoveAllMembers(ctx, session, entityID, roleName) +func (rtm *RoleManagerTracing) RoleRemoveAllMembers(ctx context.Context, session authn.Session, entityID, roleID string) (err error) { + return rtm.roles.RoleRemoveAllMembers(ctx, session, entityID, roleID) } func (rtm *RoleManagerTracing) RemoveMemberFromAllRoles(ctx context.Context, session authn.Session, memberID string) (err error) { diff --git a/pkg/roles/roles.go b/pkg/roles/roles.go index 458fd459ae..347b871e0c 100644 --- a/pkg/roles/roles.go +++ b/pkg/roles/roles.go @@ -93,7 +93,7 @@ type RoleManager interface { AddRole(ctx context.Context, session authn.Session, entityID, roleName string, optionalActions []string, optionalMembers []string) (Role, error) // Remove removes the roles of entity. - RemoveRole(ctx context.Context, session authn.Session, entityID, roleName string) error + RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error // UpdateName update the name of the entity role. UpdateRoleName(ctx context.Context, session authn.Session, entityID, roleID, newRoleName string) (Role, error) From 2e145643075bc6c310ea9a867d034322d9bcec6c Mon Sep 17 00:00:00 2001 From: Arvindh Date: Mon, 23 Dec 2024 14:47:19 +0530 Subject: [PATCH 3/5] change: role name to role id Signed-off-by: Arvindh --- api/http/util/errors.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/http/util/errors.go b/api/http/util/errors.go index d722556d89..2d0330c7d3 100644 --- a/api/http/util/errors.go +++ b/api/http/util/errors.go @@ -78,10 +78,10 @@ var ( // ErrEmptyList indicates that entity data is empty. ErrEmptyList = errors.New("empty list provided") - // ErrMissingRoleName indicates that role name are empty. + // ErrMissingRoleName indicates that role name is empty. ErrMissingRoleName = errors.New("empty role name") - // ErrMissingRoleID indicates that role name are empty. + // ErrMissingRoleID indicates that role id is empty. ErrMissingRoleID = errors.New("empty role id") // ErrMissingRoleOperations indicates that role operations are empty. From b0011a827afc4598138c09814dd5e7457a8e6aea Mon Sep 17 00:00:00 2001 From: Arvindh Date: Tue, 24 Dec 2024 17:59:29 +0530 Subject: [PATCH 4/5] change: role name to role id Signed-off-by: Arvindh --- apidocs/openapi/clients.yml | 66 ++-- apidocs/openapi/domains.yml | 68 ++-- apidocs/openapi/groups.yml | 80 ++-- apidocs/openapi/schemas/roles.yml | 36 +- pkg/roles/provisionmanage.go | 1 - pkg/sdk/clients.go | 44 +-- pkg/sdk/domains.go | 44 +-- pkg/sdk/groups.go | 44 +-- pkg/sdk/mocks/sdk.go | 600 +++++++++++++++--------------- pkg/sdk/roles.go | 66 ++-- pkg/sdk/sdk.go | 156 ++++---- pkg/sdk/setup_test.go | 2 +- 12 files changed, 607 insertions(+), 600 deletions(-) diff --git a/apidocs/openapi/clients.yml b/apidocs/openapi/clients.yml index 579c9eb3dd..ffb666bda3 100644 --- a/apidocs/openapi/clients.yml +++ b/apidocs/openapi/clients.yml @@ -454,7 +454,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + /{domainID}/clients/{clientID}/roles: post: operationId: createClientRole @@ -485,7 +485,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listClientRoles tags: @@ -520,7 +520,7 @@ paths: "500": $ref: "#/components/responses/ServiceError" - /{domainID}/clients/{clientID}/roles/{roleName}: + /{domainID}/clients/{clientID}/roles/{roleID}: get: operationId: getClientRole tags: @@ -531,7 +531,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -550,7 +550,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + put: operationId: updateClientRole summary: Updates client role. @@ -561,7 +561,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/UpdateRoleReq" security: @@ -582,7 +582,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + delete: operationId: deleteClientRole summary: Deletes client role. @@ -593,7 +593,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -612,8 +612,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/clients/{clientID}/roles/{roleName}/actions: + + /{domainID}/clients/{clientID}/roles/{roleID}/actions: post: operationId: addClientRoleAction summary: Adds a role action for a client role. @@ -624,7 +624,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleActionsReq" security: @@ -645,18 +645,18 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listClientRoleActions tags: - Roles summary: Lists client role actions. description: | - Retrieves a list of client role actions. + Retrieves a list of client role actions. parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -675,8 +675,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/clients/{clientID}/roles/{roleName}/actions/delete: + + /{domainID}/clients/{clientID}/roles/{roleID}/actions/delete: post: operationId: deleteClientRoleAction summary: Deletes role actions for a client role. @@ -687,7 +687,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleActionsReq" security: @@ -708,8 +708,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/clients/{clientID}/roles/{roleName}/actions/delete-all: + + /{domainID}/clients/{clientID}/roles/{roleID}/actions/delete-all: post: operationId: deleteAllClientRoleActions summary: Deletes all role actions for a client role. @@ -720,7 +720,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -739,8 +739,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/clients/{clientID}/roles/{roleName}/members: + + /{domainID}/clients/{clientID}/roles/{roleID}/members: post: operationId: addClientRoleMember summary: Adds a member to a client role. @@ -751,7 +751,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleMembersReq" security: @@ -772,18 +772,18 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listClientRoleMembers tags: - Roles summary: Lists client role members. description: | - Retrieves a list of client role members. + Retrieves a list of client role members. parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -802,8 +802,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/clients/{clientID}/roles/{roleName}/members/delete: + + /{domainID}/clients/{clientID}/roles/{roleID}/members/delete: post: operationId: deleteClientRoleMembers summary: Deletes members from a client role. @@ -814,7 +814,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleMembersReq" security: @@ -835,8 +835,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/clients/{clientID}/roles/{roleName}/members/delete-all: + + /{domainID}/clients/{clientID}/roles/{roleID}/members/delete-all: post: operationId: deleteAllClientRoleMembers summary: Deletes all members from a client role. @@ -847,7 +847,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/clientID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -874,7 +874,7 @@ paths: - Roles summary: Retrieves available actions. description: | - Retrieves a list of available actions. + Retrieves a list of available actions. parameters: - $ref: "auth.yml#/components/parameters/DomainID" security: diff --git a/apidocs/openapi/domains.yml b/apidocs/openapi/domains.yml index 24e29eb06b..a683e9b824 100644 --- a/apidocs/openapi/domains.yml +++ b/apidocs/openapi/domains.yml @@ -225,7 +225,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + /domains/{domainID}/roles: post: operationId: createDomainRole @@ -255,7 +255,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listDomainRoles tags: @@ -289,7 +289,7 @@ paths: "500": $ref: "#/components/responses/ServiceError" - /domains/{domainID}/roles/{roleName}: + /domains/{domainID}/roles/{roleID}: get: operationId: getDomainRole tags: @@ -299,7 +299,7 @@ paths: Retrieves a specific domain role that is identified by the role name. parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -318,7 +318,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + put: operationId: updateDomainRole summary: Updates domain role. @@ -328,7 +328,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/UpdateRoleReq" security: @@ -349,7 +349,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + delete: operationId: deleteDomainRole summary: Deletes domain role. @@ -359,7 +359,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -378,8 +378,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /domains/{domainID}/roles/{roleName}/actions: + + /domains/{domainID}/roles/{roleID}/actions: post: operationId: addDomainRoleAction summary: Adds a role action for a domain role. @@ -389,7 +389,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleActionsReq" security: @@ -410,17 +410,17 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listDomainRoleActions tags: - Roles summary: Lists domain role actions. description: | - Retrieves a list of domain role actions. + Retrieves a list of domain role actions. parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -439,8 +439,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /domains/{domainID}/roles/{roleName}/actions/delete: + + /domains/{domainID}/roles/{roleID}/actions/delete: post: operationId: deleteDomainRoleAction summary: Deletes role actions for a domain role. @@ -450,7 +450,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleActionsReq" security: @@ -471,8 +471,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /domains/{domainID}/roles/{roleName}/actions/delete-all: + + /domains/{domainID}/roles/{roleID}/actions/delete-all: post: operationId: deleteAllDomainRoleActions summary: Deletes all role actions for a domain role. @@ -482,7 +482,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -501,8 +501,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /domains/{domainID}/roles/{roleName}/members: + + /domains/{domainID}/roles/{roleID}/members: post: operationId: addDomainRoleMember summary: Adds a member to a domain role. @@ -512,7 +512,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleMembersReq" security: @@ -533,17 +533,17 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listDomainRoleMembers tags: - Roles summary: Lists domain role members. description: | - Retrieves a list of domain role members. + Retrieves a list of domain role members. parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -562,8 +562,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /domains/{domainID}/roles/{roleName}/members/delete: + + /domains/{domainID}/roles/{roleID}/members/delete: post: operationId: deleteDomainRoleMembers summary: Deletes members from a domain role. @@ -573,7 +573,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleMembersReq" security: @@ -594,8 +594,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /domains/{domainID}/roles/{roleName}/members/delete-all: + + /domains/{domainID}/roles/{roleID}/members/delete-all: post: operationId: deleteAllDomainRoleMembers summary: Deletes all members from a domain role. @@ -605,7 +605,7 @@ paths: - Roles parameters: - $ref: "#/components/parameters/DomainID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -624,7 +624,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + /domains/roles/available-actions: get: operationId: listAvailableActions @@ -632,7 +632,7 @@ paths: - Roles summary: Retrieves available actions. description: | - Retrieves a list of available actions. + Retrieves a list of available actions. parameters: - $ref: "auth.yml#/components/parameters/DomainID" security: diff --git a/apidocs/openapi/groups.yml b/apidocs/openapi/groups.yml index f0e7195315..b460047d5b 100644 --- a/apidocs/openapi/groups.yml +++ b/apidocs/openapi/groups.yml @@ -262,7 +262,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + /{domainID}/groups/{groupID}/hierarchy: get: operationId: listGroupHierarchy @@ -297,7 +297,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + /{domainID}/groups/{groupID}/parent: post: operationId: setGroupParentGroup @@ -465,7 +465,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + /{domainID}/groups/{groupID}/children/all: delete: operationId: removeAllChildrenGroups @@ -529,7 +529,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listGroupRoles tags: @@ -564,7 +564,7 @@ paths: "500": $ref: "#/components/responses/ServiceError" - /{domainID}/groups/{groupID}/roles/{roleName}: + /{domainID}/groups/{groupID}/roles/{roleID}: get: operationId: getGroupRole tags: @@ -575,7 +575,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -594,7 +594,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + put: operationId: updateGroupRole summary: Updates group role. @@ -605,7 +605,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/UpdateRoleReq" security: @@ -626,7 +626,7 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + delete: operationId: deleteGroupRole summary: Deletes group role. @@ -637,7 +637,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -656,8 +656,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/groups/{groupID}/roles/{roleName}/actions: + + /{domainID}/groups/{groupID}/roles/{roleID}/actions: post: operationId: addGroupRoleAction summary: Adds a role action for a group role. @@ -668,7 +668,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleActionsReq" security: @@ -689,18 +689,18 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listGroupRoleActions tags: - Roles summary: Lists group role actions. description: | - Retrieves a list of group role actions. + Retrieves a list of group role actions. parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -719,8 +719,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/groups/{groupID}/roles/{roleName}/actions/delete: + + /{domainID}/groups/{groupID}/roles/{roleID}/actions/delete: post: operationId: deleteGroupRoleAction summary: Deletes role actions for a group role. @@ -731,7 +731,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleActionsReq" security: @@ -752,8 +752,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/groups/{groupID}/roles/{roleName}/actions/delete-all: + + /{domainID}/groups/{groupID}/roles/{roleID}/actions/delete-all: post: operationId: deleteAllGroupRoleActions summary: Deletes all role actions for a group role. @@ -764,7 +764,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -783,8 +783,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/groups/{groupID}/roles/{roleName}/members: + + /{domainID}/groups/{groupID}/roles/{roleID}/members: post: operationId: addGroupRoleMember summary: Adds a member to a group role. @@ -795,7 +795,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleMembersReq" security: @@ -816,18 +816,18 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - + get: operationId: listGroupRoleMembers tags: - Roles summary: Lists group role members. description: | - Retrieves a list of group role members. + Retrieves a list of group role members. parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -846,8 +846,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/groups/{groupID}/roles/{roleName}/members/delete: + + /{domainID}/groups/{groupID}/roles/{roleID}/members/delete: post: operationId: deleteGroupRoleMembers summary: Deletes members from a group role. @@ -858,7 +858,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" requestBody: $ref: "./schemas/roles.yml#/components/requestBodies/AddRoleMembersReq" security: @@ -879,8 +879,8 @@ paths: description: Database can't process request. "500": $ref: "#/components/responses/ServiceError" - - /{domainID}/groups/{groupID}/roles/{roleName}/members/delete-all: + + /{domainID}/groups/{groupID}/roles/{roleID}/members/delete-all: post: operationId: deleteAllGroupRoleMembers summary: Deletes all members from a group role. @@ -891,7 +891,7 @@ paths: parameters: - $ref: "auth.yml#/components/parameters/DomainID" - $ref: "#/components/parameters/GroupID" - - $ref: "./schemas/roles.yml#/components/parameters/RoleName" + - $ref: "./schemas/roles.yml#/components/parameters/RoleID" security: - bearerAuth: [] responses: @@ -918,7 +918,7 @@ paths: - Roles summary: Retrieves available actions. description: | - Retrieves a list of available actions. + Retrieves a list of available actions. parameters: - $ref: "auth.yml#/components/parameters/DomainID" security: @@ -1125,7 +1125,7 @@ components: - groups - total - offset - + GroupsHierarchyPage: type: object properties: @@ -1199,7 +1199,7 @@ components: description: Parent group unique identifier. required: - group_id - + ChildrenGroupReqObj: type: object properties: @@ -1368,7 +1368,7 @@ components: minimum: 1 maximum: 5 required: false - + StartLevel: name: start_level description: Level of hierarchy from which to start retrieving groups from given group id. @@ -1376,7 +1376,7 @@ components: schema: type: integer required: false - + EndLevel: name: end_level description: Level of hierarchy up to which to retrieve groups from given group id. @@ -1458,7 +1458,7 @@ components: application/json: schema: $ref: "#/components/schemas/ParentGroupReqObj" - + GroupChildrenReq: description: JSON-formated document describing the children groups to be added to a group. required: true diff --git a/apidocs/openapi/schemas/roles.yml b/apidocs/openapi/schemas/roles.yml index e62389f746..5b90992928 100644 --- a/apidocs/openapi/schemas/roles.yml +++ b/apidocs/openapi/schemas/roles.yml @@ -78,7 +78,7 @@ components: format: date-time example: "2019-11-26 13:31:52" description: Time when the channel was created. - + CreateRoleObj: type: object properties: @@ -94,7 +94,7 @@ components: example: [ "read", - "update", + "update", ] optional_members: type: array @@ -107,7 +107,7 @@ components: "5dc1ce4b-7cc9-4f12-98a6-9d74cc4980bb", "c01ed106-e52d-4aa4-bed3-39f360177cfa", ] - + UpdateRoleObj: type: object properties: @@ -146,9 +146,9 @@ components: example: [ "read", - "update", + "update", ] - + RoleMembersObj: type: object properties: @@ -162,7 +162,7 @@ components: "5dc1ce4b-7cc9-4f12-98a6-9d74cc4980bb", "c01ed106-e52d-4aa4-bed3-39f360177cfa", ] - + AvailableActionsObj: type: object properties: @@ -176,7 +176,7 @@ components: "read", "update", ] - + parameters: RoleName: name: roleName @@ -186,6 +186,14 @@ components: type: string required: true example: "roleName" + RoleID: + name: roleID + description: Role ID. + in: path + schema: + type: string + required: true + example: "roleID" requestBodies: CreateRoleReq: @@ -193,17 +201,17 @@ components: required: true content: application/json: - schema: + schema: $ref: '#/components/schemas/CreateRoleObj' - + UpdateRoleReq: description: JSON- formatted object decsribing a role to be updated. required: true content: application/json: - schema: + schema: $ref: '#/components/schemas/UpdateRoleObj' - + AddRoleActionsReq: description: JSON- formatted object decsribing an action to be added to a role. required: true @@ -241,7 +249,7 @@ components: application/json: schema: $ref: '#/components/schemas/Role' - + AddRoleActionsRes: description: Action added to role successfully. content: @@ -255,14 +263,14 @@ components: application/json: schema: $ref: '#/components/schemas/RoleActionsObj' - + AddRoleMembersRes: description: Member added to role successfully. content: application/json: schema: $ref: '#/components/schemas/RoleMembersObj' - + ListRoleMembersRes: description: Role members retrieved successfully. content: diff --git a/pkg/roles/provisionmanage.go b/pkg/roles/provisionmanage.go index 8c41c47eb7..9c00c66490 100644 --- a/pkg/roles/provisionmanage.go +++ b/pkg/roles/provisionmanage.go @@ -148,7 +148,6 @@ func (r ProvisionManageService) AddNewEntitiesRoles(ctx context.Context, domainI return []RoleProvision{}, fmt.Errorf("default role %s not found in in-built roles", defaultRole) } - // There an option to have id as entityID_roleName where in roleName all space are removed with _ and starts with letter and supports only alphanumeric, space and hyphen sid, err := r.sidProvider.ID() if err != nil { return []RoleProvision{}, errors.Wrap(svcerr.ErrCreateEntity, err) diff --git a/pkg/sdk/clients.go b/pkg/sdk/clients.go index a88bb9ac25..c52e6ecc09 100644 --- a/pkg/sdk/clients.go +++ b/pkg/sdk/clients.go @@ -277,48 +277,48 @@ func (sdk mgSDK) ClientRoles(id, domainID string, pm PageMetadata, token string) return sdk.listRoles(sdk.clientsURL, clientsEndpoint, id, domainID, pm, token) } -func (sdk mgSDK) ClientRole(id, roleName, domainID, token string) (Role, errors.SDKError) { - return sdk.viewRole(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) ClientRole(id, roleID, domainID, token string) (Role, errors.SDKError) { + return sdk.viewRole(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) UpdateClientRole(id, roleName, newName, domainID string, token string) (Role, errors.SDKError) { - return sdk.updateRole(sdk.clientsURL, clientsEndpoint, id, roleName, newName, domainID, token) +func (sdk mgSDK) UpdateClientRole(id, roleID, newName, domainID string, token string) (Role, errors.SDKError) { + return sdk.updateRole(sdk.clientsURL, clientsEndpoint, id, roleID, newName, domainID, token) } -func (sdk mgSDK) DeleteClientRole(id, roleName, domainID, token string) errors.SDKError { - return sdk.deleteRole(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) DeleteClientRole(id, roleID, domainID, token string) errors.SDKError { + return sdk.deleteRole(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) AddClientRoleActions(id, roleName, domainID string, actions []string, token string) ([]string, errors.SDKError) { - return sdk.addRoleActions(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, actions, token) +func (sdk mgSDK) AddClientRoleActions(id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError) { + return sdk.addRoleActions(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, actions, token) } -func (sdk mgSDK) ClientRoleActions(id, roleName, domainID string, token string) ([]string, errors.SDKError) { - return sdk.listRoleActions(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) ClientRoleActions(id, roleID, domainID string, token string) ([]string, errors.SDKError) { + return sdk.listRoleActions(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) RemoveClientRoleActions(id, roleName, domainID string, actions []string, token string) errors.SDKError { - return sdk.removeRoleActions(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, actions, token) +func (sdk mgSDK) RemoveClientRoleActions(id, roleID, domainID string, actions []string, token string) errors.SDKError { + return sdk.removeRoleActions(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, actions, token) } -func (sdk mgSDK) RemoveAllClientRoleActions(id, roleName, domainID, token string) errors.SDKError { - return sdk.removeAllRoleActions(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) RemoveAllClientRoleActions(id, roleID, domainID, token string) errors.SDKError { + return sdk.removeAllRoleActions(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) AddClientRoleMembers(id, roleName, domainID string, members []string, token string) ([]string, errors.SDKError) { - return sdk.addRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, members, token) +func (sdk mgSDK) AddClientRoleMembers(id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError) { + return sdk.addRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, members, token) } -func (sdk mgSDK) ClientRoleMembers(id, roleName, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { - return sdk.listRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, pm, token) +func (sdk mgSDK) ClientRoleMembers(id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { + return sdk.listRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, pm, token) } -func (sdk mgSDK) RemoveClientRoleMembers(id, roleName, domainID string, members []string, token string) errors.SDKError { - return sdk.removeRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, members, token) +func (sdk mgSDK) RemoveClientRoleMembers(id, roleID, domainID string, members []string, token string) errors.SDKError { + return sdk.removeRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, members, token) } -func (sdk mgSDK) RemoveAllClientRoleMembers(id, roleName, domainID, token string) errors.SDKError { - return sdk.removeAllRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) RemoveAllClientRoleMembers(id, roleID, domainID, token string) errors.SDKError { + return sdk.removeAllRoleMembers(sdk.clientsURL, clientsEndpoint, id, roleID, domainID, token) } func (sdk mgSDK) AvailableClientRoleActions(domainID, token string) ([]string, errors.SDKError) { diff --git a/pkg/sdk/domains.go b/pkg/sdk/domains.go index 5e6d37bd7b..0e1e965a0e 100644 --- a/pkg/sdk/domains.go +++ b/pkg/sdk/domains.go @@ -141,48 +141,48 @@ func (sdk mgSDK) DomainRoles(id string, pm PageMetadata, token string) (RolesPag return sdk.listRoles(sdk.domainsURL, domainsEndpoint, id, "", pm, token) } -func (sdk mgSDK) DomainRole(id, roleName, token string) (Role, errors.SDKError) { - return sdk.viewRole(sdk.domainsURL, domainsEndpoint, id, roleName, "", token) +func (sdk mgSDK) DomainRole(id, roleID, token string) (Role, errors.SDKError) { + return sdk.viewRole(sdk.domainsURL, domainsEndpoint, id, roleID, "", token) } -func (sdk mgSDK) UpdateDomainRole(id, roleName, newName string, token string) (Role, errors.SDKError) { - return sdk.updateRole(sdk.domainsURL, domainsEndpoint, id, roleName, newName, "", token) +func (sdk mgSDK) UpdateDomainRole(id, roleID, newName string, token string) (Role, errors.SDKError) { + return sdk.updateRole(sdk.domainsURL, domainsEndpoint, id, roleID, newName, "", token) } -func (sdk mgSDK) DeleteDomainRole(id, roleName, token string) errors.SDKError { - return sdk.deleteRole(sdk.domainsURL, domainsEndpoint, id, roleName, "", token) +func (sdk mgSDK) DeleteDomainRole(id, roleID, token string) errors.SDKError { + return sdk.deleteRole(sdk.domainsURL, domainsEndpoint, id, roleID, "", token) } -func (sdk mgSDK) AddDomainRoleActions(id, roleName string, actions []string, token string) ([]string, errors.SDKError) { - return sdk.addRoleActions(sdk.domainsURL, domainsEndpoint, id, roleName, "", actions, token) +func (sdk mgSDK) AddDomainRoleActions(id, roleID string, actions []string, token string) ([]string, errors.SDKError) { + return sdk.addRoleActions(sdk.domainsURL, domainsEndpoint, id, roleID, "", actions, token) } -func (sdk mgSDK) DomainRoleActions(id, roleName string, token string) ([]string, errors.SDKError) { - return sdk.listRoleActions(sdk.domainsURL, domainsEndpoint, id, roleName, "", token) +func (sdk mgSDK) DomainRoleActions(id, roleID string, token string) ([]string, errors.SDKError) { + return sdk.listRoleActions(sdk.domainsURL, domainsEndpoint, id, roleID, "", token) } -func (sdk mgSDK) RemoveDomainRoleActions(id, roleName string, actions []string, token string) errors.SDKError { - return sdk.removeRoleActions(sdk.domainsURL, domainsEndpoint, id, roleName, "", actions, token) +func (sdk mgSDK) RemoveDomainRoleActions(id, roleID string, actions []string, token string) errors.SDKError { + return sdk.removeRoleActions(sdk.domainsURL, domainsEndpoint, id, roleID, "", actions, token) } -func (sdk mgSDK) RemoveAllDomainRoleActions(id, roleName, token string) errors.SDKError { - return sdk.removeAllRoleActions(sdk.domainsURL, domainsEndpoint, id, roleName, "", token) +func (sdk mgSDK) RemoveAllDomainRoleActions(id, roleID, token string) errors.SDKError { + return sdk.removeAllRoleActions(sdk.domainsURL, domainsEndpoint, id, roleID, "", token) } -func (sdk mgSDK) AddDomainRoleMembers(id, roleName string, members []string, token string) ([]string, errors.SDKError) { - return sdk.addRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleName, "", members, token) +func (sdk mgSDK) AddDomainRoleMembers(id, roleID string, members []string, token string) ([]string, errors.SDKError) { + return sdk.addRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleID, "", members, token) } -func (sdk mgSDK) DomainRoleMembers(id, roleName string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { - return sdk.listRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleName, "", pm, token) +func (sdk mgSDK) DomainRoleMembers(id, roleID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { + return sdk.listRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleID, "", pm, token) } -func (sdk mgSDK) RemoveDomainRoleMembers(id, roleName string, members []string, token string) errors.SDKError { - return sdk.removeRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleName, "", members, token) +func (sdk mgSDK) RemoveDomainRoleMembers(id, roleID string, members []string, token string) errors.SDKError { + return sdk.removeRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleID, "", members, token) } -func (sdk mgSDK) RemoveAllDomainRoleMembers(id, roleName, token string) errors.SDKError { - return sdk.removeAllRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleName, "", token) +func (sdk mgSDK) RemoveAllDomainRoleMembers(id, roleID, token string) errors.SDKError { + return sdk.removeAllRoleMembers(sdk.domainsURL, domainsEndpoint, id, roleID, "", token) } func (sdk mgSDK) AvailableDomainRoleActions(token string) ([]string, errors.SDKError) { diff --git a/pkg/sdk/groups.go b/pkg/sdk/groups.go index 631378c725..7dc9d30269 100644 --- a/pkg/sdk/groups.go +++ b/pkg/sdk/groups.go @@ -271,48 +271,48 @@ func (sdk mgSDK) GroupRoles(id, domainID string, pm PageMetadata, token string) return sdk.listRoles(sdk.groupsURL, groupsEndpoint, id, domainID, pm, token) } -func (sdk mgSDK) GroupRole(id, roleName, domainID, token string) (Role, errors.SDKError) { - return sdk.viewRole(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) GroupRole(id, roleID, domainID, token string) (Role, errors.SDKError) { + return sdk.viewRole(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) UpdateGroupRole(id, roleName, newName, domainID string, token string) (Role, errors.SDKError) { - return sdk.updateRole(sdk.groupsURL, groupsEndpoint, id, roleName, newName, domainID, token) +func (sdk mgSDK) UpdateGroupRole(id, roleID, newName, domainID string, token string) (Role, errors.SDKError) { + return sdk.updateRole(sdk.groupsURL, groupsEndpoint, id, roleID, newName, domainID, token) } -func (sdk mgSDK) DeleteGroupRole(id, roleName, domainID, token string) errors.SDKError { - return sdk.deleteRole(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) DeleteGroupRole(id, roleID, domainID, token string) errors.SDKError { + return sdk.deleteRole(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) AddGroupRoleActions(id, roleName, domainID string, actions []string, token string) ([]string, errors.SDKError) { - return sdk.addRoleActions(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, actions, token) +func (sdk mgSDK) AddGroupRoleActions(id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError) { + return sdk.addRoleActions(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, actions, token) } -func (sdk mgSDK) GroupRoleActions(id, roleName, domainID string, token string) ([]string, errors.SDKError) { - return sdk.listRoleActions(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) GroupRoleActions(id, roleID, domainID string, token string) ([]string, errors.SDKError) { + return sdk.listRoleActions(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) RemoveGroupRoleActions(id, roleName, domainID string, actions []string, token string) errors.SDKError { - return sdk.removeRoleActions(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, actions, token) +func (sdk mgSDK) RemoveGroupRoleActions(id, roleID, domainID string, actions []string, token string) errors.SDKError { + return sdk.removeRoleActions(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, actions, token) } -func (sdk mgSDK) RemoveAllGroupRoleActions(id, roleName, domainID, token string) errors.SDKError { - return sdk.removeAllRoleActions(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) RemoveAllGroupRoleActions(id, roleID, domainID, token string) errors.SDKError { + return sdk.removeAllRoleActions(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, token) } -func (sdk mgSDK) AddGroupRoleMembers(id, roleName, domainID string, members []string, token string) ([]string, errors.SDKError) { - return sdk.addRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, members, token) +func (sdk mgSDK) AddGroupRoleMembers(id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError) { + return sdk.addRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, members, token) } -func (sdk mgSDK) GroupRoleMembers(id, roleName, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { - return sdk.listRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, pm, token) +func (sdk mgSDK) GroupRoleMembers(id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { + return sdk.listRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, pm, token) } -func (sdk mgSDK) RemoveGroupRoleMembers(id, roleName, domainID string, members []string, token string) errors.SDKError { - return sdk.removeRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, members, token) +func (sdk mgSDK) RemoveGroupRoleMembers(id, roleID, domainID string, members []string, token string) errors.SDKError { + return sdk.removeRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, members, token) } -func (sdk mgSDK) RemoveAllGroupRoleMembers(id, roleName, domainID, token string) errors.SDKError { - return sdk.removeAllRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleName, domainID, token) +func (sdk mgSDK) RemoveAllGroupRoleMembers(id, roleID, domainID, token string) errors.SDKError { + return sdk.removeAllRoleMembers(sdk.groupsURL, groupsEndpoint, id, roleID, domainID, token) } func (sdk mgSDK) AvailableGroupRoleActions(domainID, token string) ([]string, errors.SDKError) { diff --git a/pkg/sdk/mocks/sdk.go b/pkg/sdk/mocks/sdk.go index dea38f05de..962f44bd55 100644 --- a/pkg/sdk/mocks/sdk.go +++ b/pkg/sdk/mocks/sdk.go @@ -186,9 +186,9 @@ func (_c *SDK_AddChildren_Call) RunAndReturn(run func(string, string, []string, return _c } -// AddClientRoleActions provides a mock function with given fields: id, roleName, domainID, actions, token -func (_m *SDK) AddClientRoleActions(id string, roleName string, domainID string, actions []string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, actions, token) +// AddClientRoleActions provides a mock function with given fields: id, roleID, domainID, actions, token +func (_m *SDK) AddClientRoleActions(id string, roleID string, domainID string, actions []string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, actions, token) if len(ret) == 0 { panic("no return value specified for AddClientRoleActions") @@ -197,10 +197,10 @@ func (_m *SDK) AddClientRoleActions(id string, roleName string, domainID string, var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, domainID, actions, token) + return rf(id, roleID, domainID, actions, token) } if rf, ok := ret.Get(0).(func(string, string, string, []string, string) []string); ok { - r0 = rf(id, roleName, domainID, actions, token) + r0 = rf(id, roleID, domainID, actions, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -208,7 +208,7 @@ func (_m *SDK) AddClientRoleActions(id string, roleName string, domainID string, } if rf, ok := ret.Get(1).(func(string, string, string, []string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, actions, token) + r1 = rf(id, roleID, domainID, actions, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -225,15 +225,15 @@ type SDK_AddClientRoleActions_Call struct { // AddClientRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - actions []string // - token string -func (_e *SDK_Expecter) AddClientRoleActions(id interface{}, roleName interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_AddClientRoleActions_Call { - return &SDK_AddClientRoleActions_Call{Call: _e.mock.On("AddClientRoleActions", id, roleName, domainID, actions, token)} +func (_e *SDK_Expecter) AddClientRoleActions(id interface{}, roleID interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_AddClientRoleActions_Call { + return &SDK_AddClientRoleActions_Call{Call: _e.mock.On("AddClientRoleActions", id, roleID, domainID, actions, token)} } -func (_c *SDK_AddClientRoleActions_Call) Run(run func(id string, roleName string, domainID string, actions []string, token string)) *SDK_AddClientRoleActions_Call { +func (_c *SDK_AddClientRoleActions_Call) Run(run func(id string, roleID string, domainID string, actions []string, token string)) *SDK_AddClientRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -250,9 +250,9 @@ func (_c *SDK_AddClientRoleActions_Call) RunAndReturn(run func(string, string, s return _c } -// AddClientRoleMembers provides a mock function with given fields: id, roleName, domainID, members, token -func (_m *SDK) AddClientRoleMembers(id string, roleName string, domainID string, members []string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, members, token) +// AddClientRoleMembers provides a mock function with given fields: id, roleID, domainID, members, token +func (_m *SDK) AddClientRoleMembers(id string, roleID string, domainID string, members []string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, members, token) if len(ret) == 0 { panic("no return value specified for AddClientRoleMembers") @@ -261,10 +261,10 @@ func (_m *SDK) AddClientRoleMembers(id string, roleName string, domainID string, var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, domainID, members, token) + return rf(id, roleID, domainID, members, token) } if rf, ok := ret.Get(0).(func(string, string, string, []string, string) []string); ok { - r0 = rf(id, roleName, domainID, members, token) + r0 = rf(id, roleID, domainID, members, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -272,7 +272,7 @@ func (_m *SDK) AddClientRoleMembers(id string, roleName string, domainID string, } if rf, ok := ret.Get(1).(func(string, string, string, []string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, members, token) + r1 = rf(id, roleID, domainID, members, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -289,15 +289,15 @@ type SDK_AddClientRoleMembers_Call struct { // AddClientRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - members []string // - token string -func (_e *SDK_Expecter) AddClientRoleMembers(id interface{}, roleName interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_AddClientRoleMembers_Call { - return &SDK_AddClientRoleMembers_Call{Call: _e.mock.On("AddClientRoleMembers", id, roleName, domainID, members, token)} +func (_e *SDK_Expecter) AddClientRoleMembers(id interface{}, roleID interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_AddClientRoleMembers_Call { + return &SDK_AddClientRoleMembers_Call{Call: _e.mock.On("AddClientRoleMembers", id, roleID, domainID, members, token)} } -func (_c *SDK_AddClientRoleMembers_Call) Run(run func(id string, roleName string, domainID string, members []string, token string)) *SDK_AddClientRoleMembers_Call { +func (_c *SDK_AddClientRoleMembers_Call) Run(run func(id string, roleID string, domainID string, members []string, token string)) *SDK_AddClientRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -314,9 +314,9 @@ func (_c *SDK_AddClientRoleMembers_Call) RunAndReturn(run func(string, string, s return _c } -// AddDomainRoleActions provides a mock function with given fields: id, roleName, actions, token -func (_m *SDK) AddDomainRoleActions(id string, roleName string, actions []string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, actions, token) +// AddDomainRoleActions provides a mock function with given fields: id, roleID, actions, token +func (_m *SDK) AddDomainRoleActions(id string, roleID string, actions []string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, actions, token) if len(ret) == 0 { panic("no return value specified for AddDomainRoleActions") @@ -325,10 +325,10 @@ func (_m *SDK) AddDomainRoleActions(id string, roleName string, actions []string var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, []string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, actions, token) + return rf(id, roleID, actions, token) } if rf, ok := ret.Get(0).(func(string, string, []string, string) []string); ok { - r0 = rf(id, roleName, actions, token) + r0 = rf(id, roleID, actions, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -336,7 +336,7 @@ func (_m *SDK) AddDomainRoleActions(id string, roleName string, actions []string } if rf, ok := ret.Get(1).(func(string, string, []string, string) errors.SDKError); ok { - r1 = rf(id, roleName, actions, token) + r1 = rf(id, roleID, actions, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -353,14 +353,14 @@ type SDK_AddDomainRoleActions_Call struct { // AddDomainRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - actions []string // - token string -func (_e *SDK_Expecter) AddDomainRoleActions(id interface{}, roleName interface{}, actions interface{}, token interface{}) *SDK_AddDomainRoleActions_Call { - return &SDK_AddDomainRoleActions_Call{Call: _e.mock.On("AddDomainRoleActions", id, roleName, actions, token)} +func (_e *SDK_Expecter) AddDomainRoleActions(id interface{}, roleID interface{}, actions interface{}, token interface{}) *SDK_AddDomainRoleActions_Call { + return &SDK_AddDomainRoleActions_Call{Call: _e.mock.On("AddDomainRoleActions", id, roleID, actions, token)} } -func (_c *SDK_AddDomainRoleActions_Call) Run(run func(id string, roleName string, actions []string, token string)) *SDK_AddDomainRoleActions_Call { +func (_c *SDK_AddDomainRoleActions_Call) Run(run func(id string, roleID string, actions []string, token string)) *SDK_AddDomainRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].([]string), args[3].(string)) }) @@ -377,9 +377,9 @@ func (_c *SDK_AddDomainRoleActions_Call) RunAndReturn(run func(string, string, [ return _c } -// AddDomainRoleMembers provides a mock function with given fields: id, roleName, members, token -func (_m *SDK) AddDomainRoleMembers(id string, roleName string, members []string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, members, token) +// AddDomainRoleMembers provides a mock function with given fields: id, roleID, members, token +func (_m *SDK) AddDomainRoleMembers(id string, roleID string, members []string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, members, token) if len(ret) == 0 { panic("no return value specified for AddDomainRoleMembers") @@ -388,10 +388,10 @@ func (_m *SDK) AddDomainRoleMembers(id string, roleName string, members []string var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, []string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, members, token) + return rf(id, roleID, members, token) } if rf, ok := ret.Get(0).(func(string, string, []string, string) []string); ok { - r0 = rf(id, roleName, members, token) + r0 = rf(id, roleID, members, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -399,7 +399,7 @@ func (_m *SDK) AddDomainRoleMembers(id string, roleName string, members []string } if rf, ok := ret.Get(1).(func(string, string, []string, string) errors.SDKError); ok { - r1 = rf(id, roleName, members, token) + r1 = rf(id, roleID, members, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -416,14 +416,14 @@ type SDK_AddDomainRoleMembers_Call struct { // AddDomainRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - members []string // - token string -func (_e *SDK_Expecter) AddDomainRoleMembers(id interface{}, roleName interface{}, members interface{}, token interface{}) *SDK_AddDomainRoleMembers_Call { - return &SDK_AddDomainRoleMembers_Call{Call: _e.mock.On("AddDomainRoleMembers", id, roleName, members, token)} +func (_e *SDK_Expecter) AddDomainRoleMembers(id interface{}, roleID interface{}, members interface{}, token interface{}) *SDK_AddDomainRoleMembers_Call { + return &SDK_AddDomainRoleMembers_Call{Call: _e.mock.On("AddDomainRoleMembers", id, roleID, members, token)} } -func (_c *SDK_AddDomainRoleMembers_Call) Run(run func(id string, roleName string, members []string, token string)) *SDK_AddDomainRoleMembers_Call { +func (_c *SDK_AddDomainRoleMembers_Call) Run(run func(id string, roleID string, members []string, token string)) *SDK_AddDomainRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].([]string), args[3].(string)) }) @@ -440,9 +440,9 @@ func (_c *SDK_AddDomainRoleMembers_Call) RunAndReturn(run func(string, string, [ return _c } -// AddGroupRoleActions provides a mock function with given fields: id, roleName, domainID, actions, token -func (_m *SDK) AddGroupRoleActions(id string, roleName string, domainID string, actions []string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, actions, token) +// AddGroupRoleActions provides a mock function with given fields: id, roleID, domainID, actions, token +func (_m *SDK) AddGroupRoleActions(id string, roleID string, domainID string, actions []string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, actions, token) if len(ret) == 0 { panic("no return value specified for AddGroupRoleActions") @@ -451,10 +451,10 @@ func (_m *SDK) AddGroupRoleActions(id string, roleName string, domainID string, var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, domainID, actions, token) + return rf(id, roleID, domainID, actions, token) } if rf, ok := ret.Get(0).(func(string, string, string, []string, string) []string); ok { - r0 = rf(id, roleName, domainID, actions, token) + r0 = rf(id, roleID, domainID, actions, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -462,7 +462,7 @@ func (_m *SDK) AddGroupRoleActions(id string, roleName string, domainID string, } if rf, ok := ret.Get(1).(func(string, string, string, []string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, actions, token) + r1 = rf(id, roleID, domainID, actions, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -479,15 +479,15 @@ type SDK_AddGroupRoleActions_Call struct { // AddGroupRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - actions []string // - token string -func (_e *SDK_Expecter) AddGroupRoleActions(id interface{}, roleName interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_AddGroupRoleActions_Call { - return &SDK_AddGroupRoleActions_Call{Call: _e.mock.On("AddGroupRoleActions", id, roleName, domainID, actions, token)} +func (_e *SDK_Expecter) AddGroupRoleActions(id interface{}, roleID interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_AddGroupRoleActions_Call { + return &SDK_AddGroupRoleActions_Call{Call: _e.mock.On("AddGroupRoleActions", id, roleID, domainID, actions, token)} } -func (_c *SDK_AddGroupRoleActions_Call) Run(run func(id string, roleName string, domainID string, actions []string, token string)) *SDK_AddGroupRoleActions_Call { +func (_c *SDK_AddGroupRoleActions_Call) Run(run func(id string, roleID string, domainID string, actions []string, token string)) *SDK_AddGroupRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -504,9 +504,9 @@ func (_c *SDK_AddGroupRoleActions_Call) RunAndReturn(run func(string, string, st return _c } -// AddGroupRoleMembers provides a mock function with given fields: id, roleName, domainID, members, token -func (_m *SDK) AddGroupRoleMembers(id string, roleName string, domainID string, members []string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, members, token) +// AddGroupRoleMembers provides a mock function with given fields: id, roleID, domainID, members, token +func (_m *SDK) AddGroupRoleMembers(id string, roleID string, domainID string, members []string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, members, token) if len(ret) == 0 { panic("no return value specified for AddGroupRoleMembers") @@ -515,10 +515,10 @@ func (_m *SDK) AddGroupRoleMembers(id string, roleName string, domainID string, var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, domainID, members, token) + return rf(id, roleID, domainID, members, token) } if rf, ok := ret.Get(0).(func(string, string, string, []string, string) []string); ok { - r0 = rf(id, roleName, domainID, members, token) + r0 = rf(id, roleID, domainID, members, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -526,7 +526,7 @@ func (_m *SDK) AddGroupRoleMembers(id string, roleName string, domainID string, } if rf, ok := ret.Get(1).(func(string, string, string, []string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, members, token) + r1 = rf(id, roleID, domainID, members, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -543,15 +543,15 @@ type SDK_AddGroupRoleMembers_Call struct { // AddGroupRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - members []string // - token string -func (_e *SDK_Expecter) AddGroupRoleMembers(id interface{}, roleName interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_AddGroupRoleMembers_Call { - return &SDK_AddGroupRoleMembers_Call{Call: _e.mock.On("AddGroupRoleMembers", id, roleName, domainID, members, token)} +func (_e *SDK_Expecter) AddGroupRoleMembers(id interface{}, roleID interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_AddGroupRoleMembers_Call { + return &SDK_AddGroupRoleMembers_Call{Call: _e.mock.On("AddGroupRoleMembers", id, roleID, domainID, members, token)} } -func (_c *SDK_AddGroupRoleMembers_Call) Run(run func(id string, roleName string, domainID string, members []string, token string)) *SDK_AddGroupRoleMembers_Call { +func (_c *SDK_AddGroupRoleMembers_Call) Run(run func(id string, roleID string, domainID string, members []string, token string)) *SDK_AddGroupRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -1170,9 +1170,9 @@ func (_c *SDK_Client_Call) RunAndReturn(run func(string, string, string) (sdk.Cl return _c } -// ClientRole provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) ClientRole(id string, roleName string, domainID string, token string) (sdk.Role, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, token) +// ClientRole provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) ClientRole(id string, roleID string, domainID string, token string) (sdk.Role, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for ClientRole") @@ -1181,16 +1181,16 @@ func (_m *SDK) ClientRole(id string, roleName string, domainID string, token str var r0 sdk.Role var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) (sdk.Role, errors.SDKError)); ok { - return rf(id, roleName, domainID, token) + return rf(id, roleID, domainID, token) } if rf, ok := ret.Get(0).(func(string, string, string, string) sdk.Role); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { r0 = ret.Get(0).(sdk.Role) } if rf, ok := ret.Get(1).(func(string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, token) + r1 = rf(id, roleID, domainID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -1207,14 +1207,14 @@ type SDK_ClientRole_Call struct { // ClientRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) ClientRole(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_ClientRole_Call { - return &SDK_ClientRole_Call{Call: _e.mock.On("ClientRole", id, roleName, domainID, token)} +func (_e *SDK_Expecter) ClientRole(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_ClientRole_Call { + return &SDK_ClientRole_Call{Call: _e.mock.On("ClientRole", id, roleID, domainID, token)} } -func (_c *SDK_ClientRole_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_ClientRole_Call { +func (_c *SDK_ClientRole_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_ClientRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -1231,9 +1231,9 @@ func (_c *SDK_ClientRole_Call) RunAndReturn(run func(string, string, string, str return _c } -// ClientRoleActions provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) ClientRoleActions(id string, roleName string, domainID string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, token) +// ClientRoleActions provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) ClientRoleActions(id string, roleID string, domainID string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for ClientRoleActions") @@ -1242,10 +1242,10 @@ func (_m *SDK) ClientRoleActions(id string, roleName string, domainID string, to var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, domainID, token) + return rf(id, roleID, domainID, token) } if rf, ok := ret.Get(0).(func(string, string, string, string) []string); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -1253,7 +1253,7 @@ func (_m *SDK) ClientRoleActions(id string, roleName string, domainID string, to } if rf, ok := ret.Get(1).(func(string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, token) + r1 = rf(id, roleID, domainID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -1270,14 +1270,14 @@ type SDK_ClientRoleActions_Call struct { // ClientRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) ClientRoleActions(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_ClientRoleActions_Call { - return &SDK_ClientRoleActions_Call{Call: _e.mock.On("ClientRoleActions", id, roleName, domainID, token)} +func (_e *SDK_Expecter) ClientRoleActions(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_ClientRoleActions_Call { + return &SDK_ClientRoleActions_Call{Call: _e.mock.On("ClientRoleActions", id, roleID, domainID, token)} } -func (_c *SDK_ClientRoleActions_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_ClientRoleActions_Call { +func (_c *SDK_ClientRoleActions_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_ClientRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -1294,9 +1294,9 @@ func (_c *SDK_ClientRoleActions_Call) RunAndReturn(run func(string, string, stri return _c } -// ClientRoleMembers provides a mock function with given fields: id, roleName, domainID, pm, token -func (_m *SDK) ClientRoleMembers(id string, roleName string, domainID string, pm sdk.PageMetadata, token string) (sdk.RoleMembersPage, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, pm, token) +// ClientRoleMembers provides a mock function with given fields: id, roleID, domainID, pm, token +func (_m *SDK) ClientRoleMembers(id string, roleID string, domainID string, pm sdk.PageMetadata, token string) (sdk.RoleMembersPage, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, pm, token) if len(ret) == 0 { panic("no return value specified for ClientRoleMembers") @@ -1305,16 +1305,16 @@ func (_m *SDK) ClientRoleMembers(id string, roleName string, domainID string, pm var r0 sdk.RoleMembersPage var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, sdk.PageMetadata, string) (sdk.RoleMembersPage, errors.SDKError)); ok { - return rf(id, roleName, domainID, pm, token) + return rf(id, roleID, domainID, pm, token) } if rf, ok := ret.Get(0).(func(string, string, string, sdk.PageMetadata, string) sdk.RoleMembersPage); ok { - r0 = rf(id, roleName, domainID, pm, token) + r0 = rf(id, roleID, domainID, pm, token) } else { r0 = ret.Get(0).(sdk.RoleMembersPage) } if rf, ok := ret.Get(1).(func(string, string, string, sdk.PageMetadata, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, pm, token) + r1 = rf(id, roleID, domainID, pm, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -1331,15 +1331,15 @@ type SDK_ClientRoleMembers_Call struct { // ClientRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - pm sdk.PageMetadata // - token string -func (_e *SDK_Expecter) ClientRoleMembers(id interface{}, roleName interface{}, domainID interface{}, pm interface{}, token interface{}) *SDK_ClientRoleMembers_Call { - return &SDK_ClientRoleMembers_Call{Call: _e.mock.On("ClientRoleMembers", id, roleName, domainID, pm, token)} +func (_e *SDK_Expecter) ClientRoleMembers(id interface{}, roleID interface{}, domainID interface{}, pm interface{}, token interface{}) *SDK_ClientRoleMembers_Call { + return &SDK_ClientRoleMembers_Call{Call: _e.mock.On("ClientRoleMembers", id, roleID, domainID, pm, token)} } -func (_c *SDK_ClientRoleMembers_Call) Run(run func(id string, roleName string, domainID string, pm sdk.PageMetadata, token string)) *SDK_ClientRoleMembers_Call { +func (_c *SDK_ClientRoleMembers_Call) Run(run func(id string, roleID string, domainID string, pm sdk.PageMetadata, token string)) *SDK_ClientRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(sdk.PageMetadata), args[4].(string)) }) @@ -2401,9 +2401,9 @@ func (_c *SDK_DeleteClient_Call) RunAndReturn(run func(string, string, string) e return _c } -// DeleteClientRole provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) DeleteClientRole(id string, roleName string, domainID string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, token) +// DeleteClientRole provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) DeleteClientRole(id string, roleID string, domainID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for DeleteClientRole") @@ -2411,7 +2411,7 @@ func (_m *SDK) DeleteClientRole(id string, roleName string, domainID string, tok var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -2428,14 +2428,14 @@ type SDK_DeleteClientRole_Call struct { // DeleteClientRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) DeleteClientRole(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_DeleteClientRole_Call { - return &SDK_DeleteClientRole_Call{Call: _e.mock.On("DeleteClientRole", id, roleName, domainID, token)} +func (_e *SDK_Expecter) DeleteClientRole(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_DeleteClientRole_Call { + return &SDK_DeleteClientRole_Call{Call: _e.mock.On("DeleteClientRole", id, roleID, domainID, token)} } -func (_c *SDK_DeleteClientRole_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_DeleteClientRole_Call { +func (_c *SDK_DeleteClientRole_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_DeleteClientRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -2452,9 +2452,9 @@ func (_c *SDK_DeleteClientRole_Call) RunAndReturn(run func(string, string, strin return _c } -// DeleteDomainRole provides a mock function with given fields: id, roleName, token -func (_m *SDK) DeleteDomainRole(id string, roleName string, token string) errors.SDKError { - ret := _m.Called(id, roleName, token) +// DeleteDomainRole provides a mock function with given fields: id, roleID, token +func (_m *SDK) DeleteDomainRole(id string, roleID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, token) if len(ret) == 0 { panic("no return value specified for DeleteDomainRole") @@ -2462,7 +2462,7 @@ func (_m *SDK) DeleteDomainRole(id string, roleName string, token string) errors var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, token) + r0 = rf(id, roleID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -2479,13 +2479,13 @@ type SDK_DeleteDomainRole_Call struct { // DeleteDomainRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - token string -func (_e *SDK_Expecter) DeleteDomainRole(id interface{}, roleName interface{}, token interface{}) *SDK_DeleteDomainRole_Call { - return &SDK_DeleteDomainRole_Call{Call: _e.mock.On("DeleteDomainRole", id, roleName, token)} +func (_e *SDK_Expecter) DeleteDomainRole(id interface{}, roleID interface{}, token interface{}) *SDK_DeleteDomainRole_Call { + return &SDK_DeleteDomainRole_Call{Call: _e.mock.On("DeleteDomainRole", id, roleID, token)} } -func (_c *SDK_DeleteDomainRole_Call) Run(run func(id string, roleName string, token string)) *SDK_DeleteDomainRole_Call { +func (_c *SDK_DeleteDomainRole_Call) Run(run func(id string, roleID string, token string)) *SDK_DeleteDomainRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string)) }) @@ -2552,9 +2552,9 @@ func (_c *SDK_DeleteGroup_Call) RunAndReturn(run func(string, string, string) er return _c } -// DeleteGroupRole provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) DeleteGroupRole(id string, roleName string, domainID string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, token) +// DeleteGroupRole provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) DeleteGroupRole(id string, roleID string, domainID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for DeleteGroupRole") @@ -2562,7 +2562,7 @@ func (_m *SDK) DeleteGroupRole(id string, roleName string, domainID string, toke var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -2579,14 +2579,14 @@ type SDK_DeleteGroupRole_Call struct { // DeleteGroupRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) DeleteGroupRole(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_DeleteGroupRole_Call { - return &SDK_DeleteGroupRole_Call{Call: _e.mock.On("DeleteGroupRole", id, roleName, domainID, token)} +func (_e *SDK_Expecter) DeleteGroupRole(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_DeleteGroupRole_Call { + return &SDK_DeleteGroupRole_Call{Call: _e.mock.On("DeleteGroupRole", id, roleID, domainID, token)} } -func (_c *SDK_DeleteGroupRole_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_DeleteGroupRole_Call { +func (_c *SDK_DeleteGroupRole_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_DeleteGroupRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -3198,9 +3198,9 @@ func (_c *SDK_Domain_Call) RunAndReturn(run func(string, string) (sdk.Domain, er return _c } -// DomainRole provides a mock function with given fields: id, roleName, token -func (_m *SDK) DomainRole(id string, roleName string, token string) (sdk.Role, errors.SDKError) { - ret := _m.Called(id, roleName, token) +// DomainRole provides a mock function with given fields: id, roleID, token +func (_m *SDK) DomainRole(id string, roleID string, token string) (sdk.Role, errors.SDKError) { + ret := _m.Called(id, roleID, token) if len(ret) == 0 { panic("no return value specified for DomainRole") @@ -3209,16 +3209,16 @@ func (_m *SDK) DomainRole(id string, roleName string, token string) (sdk.Role, e var r0 sdk.Role var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string) (sdk.Role, errors.SDKError)); ok { - return rf(id, roleName, token) + return rf(id, roleID, token) } if rf, ok := ret.Get(0).(func(string, string, string) sdk.Role); ok { - r0 = rf(id, roleName, token) + r0 = rf(id, roleID, token) } else { r0 = ret.Get(0).(sdk.Role) } if rf, ok := ret.Get(1).(func(string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, token) + r1 = rf(id, roleID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -3235,13 +3235,13 @@ type SDK_DomainRole_Call struct { // DomainRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - token string -func (_e *SDK_Expecter) DomainRole(id interface{}, roleName interface{}, token interface{}) *SDK_DomainRole_Call { - return &SDK_DomainRole_Call{Call: _e.mock.On("DomainRole", id, roleName, token)} +func (_e *SDK_Expecter) DomainRole(id interface{}, roleID interface{}, token interface{}) *SDK_DomainRole_Call { + return &SDK_DomainRole_Call{Call: _e.mock.On("DomainRole", id, roleID, token)} } -func (_c *SDK_DomainRole_Call) Run(run func(id string, roleName string, token string)) *SDK_DomainRole_Call { +func (_c *SDK_DomainRole_Call) Run(run func(id string, roleID string, token string)) *SDK_DomainRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string)) }) @@ -3258,9 +3258,9 @@ func (_c *SDK_DomainRole_Call) RunAndReturn(run func(string, string, string) (sd return _c } -// DomainRoleActions provides a mock function with given fields: id, roleName, token -func (_m *SDK) DomainRoleActions(id string, roleName string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, token) +// DomainRoleActions provides a mock function with given fields: id, roleID, token +func (_m *SDK) DomainRoleActions(id string, roleID string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, token) if len(ret) == 0 { panic("no return value specified for DomainRoleActions") @@ -3269,10 +3269,10 @@ func (_m *SDK) DomainRoleActions(id string, roleName string, token string) ([]st var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, token) + return rf(id, roleID, token) } if rf, ok := ret.Get(0).(func(string, string, string) []string); ok { - r0 = rf(id, roleName, token) + r0 = rf(id, roleID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -3280,7 +3280,7 @@ func (_m *SDK) DomainRoleActions(id string, roleName string, token string) ([]st } if rf, ok := ret.Get(1).(func(string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, token) + r1 = rf(id, roleID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -3297,13 +3297,13 @@ type SDK_DomainRoleActions_Call struct { // DomainRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - token string -func (_e *SDK_Expecter) DomainRoleActions(id interface{}, roleName interface{}, token interface{}) *SDK_DomainRoleActions_Call { - return &SDK_DomainRoleActions_Call{Call: _e.mock.On("DomainRoleActions", id, roleName, token)} +func (_e *SDK_Expecter) DomainRoleActions(id interface{}, roleID interface{}, token interface{}) *SDK_DomainRoleActions_Call { + return &SDK_DomainRoleActions_Call{Call: _e.mock.On("DomainRoleActions", id, roleID, token)} } -func (_c *SDK_DomainRoleActions_Call) Run(run func(id string, roleName string, token string)) *SDK_DomainRoleActions_Call { +func (_c *SDK_DomainRoleActions_Call) Run(run func(id string, roleID string, token string)) *SDK_DomainRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string)) }) @@ -3320,9 +3320,9 @@ func (_c *SDK_DomainRoleActions_Call) RunAndReturn(run func(string, string, stri return _c } -// DomainRoleMembers provides a mock function with given fields: id, roleName, pm, token -func (_m *SDK) DomainRoleMembers(id string, roleName string, pm sdk.PageMetadata, token string) (sdk.RoleMembersPage, errors.SDKError) { - ret := _m.Called(id, roleName, pm, token) +// DomainRoleMembers provides a mock function with given fields: id, roleID, pm, token +func (_m *SDK) DomainRoleMembers(id string, roleID string, pm sdk.PageMetadata, token string) (sdk.RoleMembersPage, errors.SDKError) { + ret := _m.Called(id, roleID, pm, token) if len(ret) == 0 { panic("no return value specified for DomainRoleMembers") @@ -3331,16 +3331,16 @@ func (_m *SDK) DomainRoleMembers(id string, roleName string, pm sdk.PageMetadata var r0 sdk.RoleMembersPage var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, sdk.PageMetadata, string) (sdk.RoleMembersPage, errors.SDKError)); ok { - return rf(id, roleName, pm, token) + return rf(id, roleID, pm, token) } if rf, ok := ret.Get(0).(func(string, string, sdk.PageMetadata, string) sdk.RoleMembersPage); ok { - r0 = rf(id, roleName, pm, token) + r0 = rf(id, roleID, pm, token) } else { r0 = ret.Get(0).(sdk.RoleMembersPage) } if rf, ok := ret.Get(1).(func(string, string, sdk.PageMetadata, string) errors.SDKError); ok { - r1 = rf(id, roleName, pm, token) + r1 = rf(id, roleID, pm, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -3357,14 +3357,14 @@ type SDK_DomainRoleMembers_Call struct { // DomainRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - pm sdk.PageMetadata // - token string -func (_e *SDK_Expecter) DomainRoleMembers(id interface{}, roleName interface{}, pm interface{}, token interface{}) *SDK_DomainRoleMembers_Call { - return &SDK_DomainRoleMembers_Call{Call: _e.mock.On("DomainRoleMembers", id, roleName, pm, token)} +func (_e *SDK_Expecter) DomainRoleMembers(id interface{}, roleID interface{}, pm interface{}, token interface{}) *SDK_DomainRoleMembers_Call { + return &SDK_DomainRoleMembers_Call{Call: _e.mock.On("DomainRoleMembers", id, roleID, pm, token)} } -func (_c *SDK_DomainRoleMembers_Call) Run(run func(id string, roleName string, pm sdk.PageMetadata, token string)) *SDK_DomainRoleMembers_Call { +func (_c *SDK_DomainRoleMembers_Call) Run(run func(id string, roleID string, pm sdk.PageMetadata, token string)) *SDK_DomainRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(sdk.PageMetadata), args[3].(string)) }) @@ -3897,9 +3897,9 @@ func (_c *SDK_Group_Call) RunAndReturn(run func(string, string, string) (sdk.Gro return _c } -// GroupRole provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) GroupRole(id string, roleName string, domainID string, token string) (sdk.Role, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, token) +// GroupRole provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) GroupRole(id string, roleID string, domainID string, token string) (sdk.Role, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for GroupRole") @@ -3908,16 +3908,16 @@ func (_m *SDK) GroupRole(id string, roleName string, domainID string, token stri var r0 sdk.Role var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) (sdk.Role, errors.SDKError)); ok { - return rf(id, roleName, domainID, token) + return rf(id, roleID, domainID, token) } if rf, ok := ret.Get(0).(func(string, string, string, string) sdk.Role); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { r0 = ret.Get(0).(sdk.Role) } if rf, ok := ret.Get(1).(func(string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, token) + r1 = rf(id, roleID, domainID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -3934,14 +3934,14 @@ type SDK_GroupRole_Call struct { // GroupRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) GroupRole(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_GroupRole_Call { - return &SDK_GroupRole_Call{Call: _e.mock.On("GroupRole", id, roleName, domainID, token)} +func (_e *SDK_Expecter) GroupRole(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_GroupRole_Call { + return &SDK_GroupRole_Call{Call: _e.mock.On("GroupRole", id, roleID, domainID, token)} } -func (_c *SDK_GroupRole_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_GroupRole_Call { +func (_c *SDK_GroupRole_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_GroupRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -3958,9 +3958,9 @@ func (_c *SDK_GroupRole_Call) RunAndReturn(run func(string, string, string, stri return _c } -// GroupRoleActions provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) GroupRoleActions(id string, roleName string, domainID string, token string) ([]string, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, token) +// GroupRoleActions provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) GroupRoleActions(id string, roleID string, domainID string, token string) ([]string, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for GroupRoleActions") @@ -3969,10 +3969,10 @@ func (_m *SDK) GroupRoleActions(id string, roleName string, domainID string, tok var r0 []string var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) ([]string, errors.SDKError)); ok { - return rf(id, roleName, domainID, token) + return rf(id, roleID, domainID, token) } if rf, ok := ret.Get(0).(func(string, string, string, string) []string); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) @@ -3980,7 +3980,7 @@ func (_m *SDK) GroupRoleActions(id string, roleName string, domainID string, tok } if rf, ok := ret.Get(1).(func(string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, token) + r1 = rf(id, roleID, domainID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -3997,14 +3997,14 @@ type SDK_GroupRoleActions_Call struct { // GroupRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) GroupRoleActions(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_GroupRoleActions_Call { - return &SDK_GroupRoleActions_Call{Call: _e.mock.On("GroupRoleActions", id, roleName, domainID, token)} +func (_e *SDK_Expecter) GroupRoleActions(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_GroupRoleActions_Call { + return &SDK_GroupRoleActions_Call{Call: _e.mock.On("GroupRoleActions", id, roleID, domainID, token)} } -func (_c *SDK_GroupRoleActions_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_GroupRoleActions_Call { +func (_c *SDK_GroupRoleActions_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_GroupRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -4021,9 +4021,9 @@ func (_c *SDK_GroupRoleActions_Call) RunAndReturn(run func(string, string, strin return _c } -// GroupRoleMembers provides a mock function with given fields: id, roleName, domainID, pm, token -func (_m *SDK) GroupRoleMembers(id string, roleName string, domainID string, pm sdk.PageMetadata, token string) (sdk.RoleMembersPage, errors.SDKError) { - ret := _m.Called(id, roleName, domainID, pm, token) +// GroupRoleMembers provides a mock function with given fields: id, roleID, domainID, pm, token +func (_m *SDK) GroupRoleMembers(id string, roleID string, domainID string, pm sdk.PageMetadata, token string) (sdk.RoleMembersPage, errors.SDKError) { + ret := _m.Called(id, roleID, domainID, pm, token) if len(ret) == 0 { panic("no return value specified for GroupRoleMembers") @@ -4032,16 +4032,16 @@ func (_m *SDK) GroupRoleMembers(id string, roleName string, domainID string, pm var r0 sdk.RoleMembersPage var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, sdk.PageMetadata, string) (sdk.RoleMembersPage, errors.SDKError)); ok { - return rf(id, roleName, domainID, pm, token) + return rf(id, roleID, domainID, pm, token) } if rf, ok := ret.Get(0).(func(string, string, string, sdk.PageMetadata, string) sdk.RoleMembersPage); ok { - r0 = rf(id, roleName, domainID, pm, token) + r0 = rf(id, roleID, domainID, pm, token) } else { r0 = ret.Get(0).(sdk.RoleMembersPage) } if rf, ok := ret.Get(1).(func(string, string, string, sdk.PageMetadata, string) errors.SDKError); ok { - r1 = rf(id, roleName, domainID, pm, token) + r1 = rf(id, roleID, domainID, pm, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -4058,15 +4058,15 @@ type SDK_GroupRoleMembers_Call struct { // GroupRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - pm sdk.PageMetadata // - token string -func (_e *SDK_Expecter) GroupRoleMembers(id interface{}, roleName interface{}, domainID interface{}, pm interface{}, token interface{}) *SDK_GroupRoleMembers_Call { - return &SDK_GroupRoleMembers_Call{Call: _e.mock.On("GroupRoleMembers", id, roleName, domainID, pm, token)} +func (_e *SDK_Expecter) GroupRoleMembers(id interface{}, roleID interface{}, domainID interface{}, pm interface{}, token interface{}) *SDK_GroupRoleMembers_Call { + return &SDK_GroupRoleMembers_Call{Call: _e.mock.On("GroupRoleMembers", id, roleID, domainID, pm, token)} } -func (_c *SDK_GroupRoleMembers_Call) Run(run func(id string, roleName string, domainID string, pm sdk.PageMetadata, token string)) *SDK_GroupRoleMembers_Call { +func (_c *SDK_GroupRoleMembers_Call) Run(run func(id string, roleID string, domainID string, pm sdk.PageMetadata, token string)) *SDK_GroupRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(sdk.PageMetadata), args[4].(string)) }) @@ -5138,9 +5138,9 @@ func (_c *SDK_RemoveAllChildren_Call) RunAndReturn(run func(string, string, stri return _c } -// RemoveAllClientRoleActions provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) RemoveAllClientRoleActions(id string, roleName string, domainID string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, token) +// RemoveAllClientRoleActions provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) RemoveAllClientRoleActions(id string, roleID string, domainID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for RemoveAllClientRoleActions") @@ -5148,7 +5148,7 @@ func (_m *SDK) RemoveAllClientRoleActions(id string, roleName string, domainID s var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5165,14 +5165,14 @@ type SDK_RemoveAllClientRoleActions_Call struct { // RemoveAllClientRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) RemoveAllClientRoleActions(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllClientRoleActions_Call { - return &SDK_RemoveAllClientRoleActions_Call{Call: _e.mock.On("RemoveAllClientRoleActions", id, roleName, domainID, token)} +func (_e *SDK_Expecter) RemoveAllClientRoleActions(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllClientRoleActions_Call { + return &SDK_RemoveAllClientRoleActions_Call{Call: _e.mock.On("RemoveAllClientRoleActions", id, roleID, domainID, token)} } -func (_c *SDK_RemoveAllClientRoleActions_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_RemoveAllClientRoleActions_Call { +func (_c *SDK_RemoveAllClientRoleActions_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_RemoveAllClientRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -5189,9 +5189,9 @@ func (_c *SDK_RemoveAllClientRoleActions_Call) RunAndReturn(run func(string, str return _c } -// RemoveAllClientRoleMembers provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) RemoveAllClientRoleMembers(id string, roleName string, domainID string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, token) +// RemoveAllClientRoleMembers provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) RemoveAllClientRoleMembers(id string, roleID string, domainID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for RemoveAllClientRoleMembers") @@ -5199,7 +5199,7 @@ func (_m *SDK) RemoveAllClientRoleMembers(id string, roleName string, domainID s var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5216,14 +5216,14 @@ type SDK_RemoveAllClientRoleMembers_Call struct { // RemoveAllClientRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) RemoveAllClientRoleMembers(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllClientRoleMembers_Call { - return &SDK_RemoveAllClientRoleMembers_Call{Call: _e.mock.On("RemoveAllClientRoleMembers", id, roleName, domainID, token)} +func (_e *SDK_Expecter) RemoveAllClientRoleMembers(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllClientRoleMembers_Call { + return &SDK_RemoveAllClientRoleMembers_Call{Call: _e.mock.On("RemoveAllClientRoleMembers", id, roleID, domainID, token)} } -func (_c *SDK_RemoveAllClientRoleMembers_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_RemoveAllClientRoleMembers_Call { +func (_c *SDK_RemoveAllClientRoleMembers_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_RemoveAllClientRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -5240,9 +5240,9 @@ func (_c *SDK_RemoveAllClientRoleMembers_Call) RunAndReturn(run func(string, str return _c } -// RemoveAllDomainRoleActions provides a mock function with given fields: id, roleName, token -func (_m *SDK) RemoveAllDomainRoleActions(id string, roleName string, token string) errors.SDKError { - ret := _m.Called(id, roleName, token) +// RemoveAllDomainRoleActions provides a mock function with given fields: id, roleID, token +func (_m *SDK) RemoveAllDomainRoleActions(id string, roleID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, token) if len(ret) == 0 { panic("no return value specified for RemoveAllDomainRoleActions") @@ -5250,7 +5250,7 @@ func (_m *SDK) RemoveAllDomainRoleActions(id string, roleName string, token stri var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, token) + r0 = rf(id, roleID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5267,13 +5267,13 @@ type SDK_RemoveAllDomainRoleActions_Call struct { // RemoveAllDomainRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - token string -func (_e *SDK_Expecter) RemoveAllDomainRoleActions(id interface{}, roleName interface{}, token interface{}) *SDK_RemoveAllDomainRoleActions_Call { - return &SDK_RemoveAllDomainRoleActions_Call{Call: _e.mock.On("RemoveAllDomainRoleActions", id, roleName, token)} +func (_e *SDK_Expecter) RemoveAllDomainRoleActions(id interface{}, roleID interface{}, token interface{}) *SDK_RemoveAllDomainRoleActions_Call { + return &SDK_RemoveAllDomainRoleActions_Call{Call: _e.mock.On("RemoveAllDomainRoleActions", id, roleID, token)} } -func (_c *SDK_RemoveAllDomainRoleActions_Call) Run(run func(id string, roleName string, token string)) *SDK_RemoveAllDomainRoleActions_Call { +func (_c *SDK_RemoveAllDomainRoleActions_Call) Run(run func(id string, roleID string, token string)) *SDK_RemoveAllDomainRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string)) }) @@ -5290,9 +5290,9 @@ func (_c *SDK_RemoveAllDomainRoleActions_Call) RunAndReturn(run func(string, str return _c } -// RemoveAllDomainRoleMembers provides a mock function with given fields: id, roleName, token -func (_m *SDK) RemoveAllDomainRoleMembers(id string, roleName string, token string) errors.SDKError { - ret := _m.Called(id, roleName, token) +// RemoveAllDomainRoleMembers provides a mock function with given fields: id, roleID, token +func (_m *SDK) RemoveAllDomainRoleMembers(id string, roleID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, token) if len(ret) == 0 { panic("no return value specified for RemoveAllDomainRoleMembers") @@ -5300,7 +5300,7 @@ func (_m *SDK) RemoveAllDomainRoleMembers(id string, roleName string, token stri var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, token) + r0 = rf(id, roleID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5317,13 +5317,13 @@ type SDK_RemoveAllDomainRoleMembers_Call struct { // RemoveAllDomainRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - token string -func (_e *SDK_Expecter) RemoveAllDomainRoleMembers(id interface{}, roleName interface{}, token interface{}) *SDK_RemoveAllDomainRoleMembers_Call { - return &SDK_RemoveAllDomainRoleMembers_Call{Call: _e.mock.On("RemoveAllDomainRoleMembers", id, roleName, token)} +func (_e *SDK_Expecter) RemoveAllDomainRoleMembers(id interface{}, roleID interface{}, token interface{}) *SDK_RemoveAllDomainRoleMembers_Call { + return &SDK_RemoveAllDomainRoleMembers_Call{Call: _e.mock.On("RemoveAllDomainRoleMembers", id, roleID, token)} } -func (_c *SDK_RemoveAllDomainRoleMembers_Call) Run(run func(id string, roleName string, token string)) *SDK_RemoveAllDomainRoleMembers_Call { +func (_c *SDK_RemoveAllDomainRoleMembers_Call) Run(run func(id string, roleID string, token string)) *SDK_RemoveAllDomainRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string)) }) @@ -5340,9 +5340,9 @@ func (_c *SDK_RemoveAllDomainRoleMembers_Call) RunAndReturn(run func(string, str return _c } -// RemoveAllGroupRoleActions provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) RemoveAllGroupRoleActions(id string, roleName string, domainID string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, token) +// RemoveAllGroupRoleActions provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) RemoveAllGroupRoleActions(id string, roleID string, domainID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for RemoveAllGroupRoleActions") @@ -5350,7 +5350,7 @@ func (_m *SDK) RemoveAllGroupRoleActions(id string, roleName string, domainID st var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5367,14 +5367,14 @@ type SDK_RemoveAllGroupRoleActions_Call struct { // RemoveAllGroupRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) RemoveAllGroupRoleActions(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllGroupRoleActions_Call { - return &SDK_RemoveAllGroupRoleActions_Call{Call: _e.mock.On("RemoveAllGroupRoleActions", id, roleName, domainID, token)} +func (_e *SDK_Expecter) RemoveAllGroupRoleActions(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllGroupRoleActions_Call { + return &SDK_RemoveAllGroupRoleActions_Call{Call: _e.mock.On("RemoveAllGroupRoleActions", id, roleID, domainID, token)} } -func (_c *SDK_RemoveAllGroupRoleActions_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_RemoveAllGroupRoleActions_Call { +func (_c *SDK_RemoveAllGroupRoleActions_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_RemoveAllGroupRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -5391,9 +5391,9 @@ func (_c *SDK_RemoveAllGroupRoleActions_Call) RunAndReturn(run func(string, stri return _c } -// RemoveAllGroupRoleMembers provides a mock function with given fields: id, roleName, domainID, token -func (_m *SDK) RemoveAllGroupRoleMembers(id string, roleName string, domainID string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, token) +// RemoveAllGroupRoleMembers provides a mock function with given fields: id, roleID, domainID, token +func (_m *SDK) RemoveAllGroupRoleMembers(id string, roleID string, domainID string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, token) if len(ret) == 0 { panic("no return value specified for RemoveAllGroupRoleMembers") @@ -5401,7 +5401,7 @@ func (_m *SDK) RemoveAllGroupRoleMembers(id string, roleName string, domainID st var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, token) + r0 = rf(id, roleID, domainID, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5418,14 +5418,14 @@ type SDK_RemoveAllGroupRoleMembers_Call struct { // RemoveAllGroupRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - token string -func (_e *SDK_Expecter) RemoveAllGroupRoleMembers(id interface{}, roleName interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllGroupRoleMembers_Call { - return &SDK_RemoveAllGroupRoleMembers_Call{Call: _e.mock.On("RemoveAllGroupRoleMembers", id, roleName, domainID, token)} +func (_e *SDK_Expecter) RemoveAllGroupRoleMembers(id interface{}, roleID interface{}, domainID interface{}, token interface{}) *SDK_RemoveAllGroupRoleMembers_Call { + return &SDK_RemoveAllGroupRoleMembers_Call{Call: _e.mock.On("RemoveAllGroupRoleMembers", id, roleID, domainID, token)} } -func (_c *SDK_RemoveAllGroupRoleMembers_Call) Run(run func(id string, roleName string, domainID string, token string)) *SDK_RemoveAllGroupRoleMembers_Call { +func (_c *SDK_RemoveAllGroupRoleMembers_Call) Run(run func(id string, roleID string, domainID string, token string)) *SDK_RemoveAllGroupRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -5645,9 +5645,9 @@ func (_c *SDK_RemoveClientParent_Call) RunAndReturn(run func(string, string, str return _c } -// RemoveClientRoleActions provides a mock function with given fields: id, roleName, domainID, actions, token -func (_m *SDK) RemoveClientRoleActions(id string, roleName string, domainID string, actions []string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, actions, token) +// RemoveClientRoleActions provides a mock function with given fields: id, roleID, domainID, actions, token +func (_m *SDK) RemoveClientRoleActions(id string, roleID string, domainID string, actions []string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, actions, token) if len(ret) == 0 { panic("no return value specified for RemoveClientRoleActions") @@ -5655,7 +5655,7 @@ func (_m *SDK) RemoveClientRoleActions(id string, roleName string, domainID stri var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, actions, token) + r0 = rf(id, roleID, domainID, actions, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5672,15 +5672,15 @@ type SDK_RemoveClientRoleActions_Call struct { // RemoveClientRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - actions []string // - token string -func (_e *SDK_Expecter) RemoveClientRoleActions(id interface{}, roleName interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_RemoveClientRoleActions_Call { - return &SDK_RemoveClientRoleActions_Call{Call: _e.mock.On("RemoveClientRoleActions", id, roleName, domainID, actions, token)} +func (_e *SDK_Expecter) RemoveClientRoleActions(id interface{}, roleID interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_RemoveClientRoleActions_Call { + return &SDK_RemoveClientRoleActions_Call{Call: _e.mock.On("RemoveClientRoleActions", id, roleID, domainID, actions, token)} } -func (_c *SDK_RemoveClientRoleActions_Call) Run(run func(id string, roleName string, domainID string, actions []string, token string)) *SDK_RemoveClientRoleActions_Call { +func (_c *SDK_RemoveClientRoleActions_Call) Run(run func(id string, roleID string, domainID string, actions []string, token string)) *SDK_RemoveClientRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -5697,9 +5697,9 @@ func (_c *SDK_RemoveClientRoleActions_Call) RunAndReturn(run func(string, string return _c } -// RemoveClientRoleMembers provides a mock function with given fields: id, roleName, domainID, members, token -func (_m *SDK) RemoveClientRoleMembers(id string, roleName string, domainID string, members []string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, members, token) +// RemoveClientRoleMembers provides a mock function with given fields: id, roleID, domainID, members, token +func (_m *SDK) RemoveClientRoleMembers(id string, roleID string, domainID string, members []string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, members, token) if len(ret) == 0 { panic("no return value specified for RemoveClientRoleMembers") @@ -5707,7 +5707,7 @@ func (_m *SDK) RemoveClientRoleMembers(id string, roleName string, domainID stri var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, members, token) + r0 = rf(id, roleID, domainID, members, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5724,15 +5724,15 @@ type SDK_RemoveClientRoleMembers_Call struct { // RemoveClientRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - members []string // - token string -func (_e *SDK_Expecter) RemoveClientRoleMembers(id interface{}, roleName interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_RemoveClientRoleMembers_Call { - return &SDK_RemoveClientRoleMembers_Call{Call: _e.mock.On("RemoveClientRoleMembers", id, roleName, domainID, members, token)} +func (_e *SDK_Expecter) RemoveClientRoleMembers(id interface{}, roleID interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_RemoveClientRoleMembers_Call { + return &SDK_RemoveClientRoleMembers_Call{Call: _e.mock.On("RemoveClientRoleMembers", id, roleID, domainID, members, token)} } -func (_c *SDK_RemoveClientRoleMembers_Call) Run(run func(id string, roleName string, domainID string, members []string, token string)) *SDK_RemoveClientRoleMembers_Call { +func (_c *SDK_RemoveClientRoleMembers_Call) Run(run func(id string, roleID string, domainID string, members []string, token string)) *SDK_RemoveClientRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -5749,9 +5749,9 @@ func (_c *SDK_RemoveClientRoleMembers_Call) RunAndReturn(run func(string, string return _c } -// RemoveDomainRoleActions provides a mock function with given fields: id, roleName, actions, token -func (_m *SDK) RemoveDomainRoleActions(id string, roleName string, actions []string, token string) errors.SDKError { - ret := _m.Called(id, roleName, actions, token) +// RemoveDomainRoleActions provides a mock function with given fields: id, roleID, actions, token +func (_m *SDK) RemoveDomainRoleActions(id string, roleID string, actions []string, token string) errors.SDKError { + ret := _m.Called(id, roleID, actions, token) if len(ret) == 0 { panic("no return value specified for RemoveDomainRoleActions") @@ -5759,7 +5759,7 @@ func (_m *SDK) RemoveDomainRoleActions(id string, roleName string, actions []str var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, []string, string) errors.SDKError); ok { - r0 = rf(id, roleName, actions, token) + r0 = rf(id, roleID, actions, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5776,14 +5776,14 @@ type SDK_RemoveDomainRoleActions_Call struct { // RemoveDomainRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - actions []string // - token string -func (_e *SDK_Expecter) RemoveDomainRoleActions(id interface{}, roleName interface{}, actions interface{}, token interface{}) *SDK_RemoveDomainRoleActions_Call { - return &SDK_RemoveDomainRoleActions_Call{Call: _e.mock.On("RemoveDomainRoleActions", id, roleName, actions, token)} +func (_e *SDK_Expecter) RemoveDomainRoleActions(id interface{}, roleID interface{}, actions interface{}, token interface{}) *SDK_RemoveDomainRoleActions_Call { + return &SDK_RemoveDomainRoleActions_Call{Call: _e.mock.On("RemoveDomainRoleActions", id, roleID, actions, token)} } -func (_c *SDK_RemoveDomainRoleActions_Call) Run(run func(id string, roleName string, actions []string, token string)) *SDK_RemoveDomainRoleActions_Call { +func (_c *SDK_RemoveDomainRoleActions_Call) Run(run func(id string, roleID string, actions []string, token string)) *SDK_RemoveDomainRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].([]string), args[3].(string)) }) @@ -5800,9 +5800,9 @@ func (_c *SDK_RemoveDomainRoleActions_Call) RunAndReturn(run func(string, string return _c } -// RemoveDomainRoleMembers provides a mock function with given fields: id, roleName, members, token -func (_m *SDK) RemoveDomainRoleMembers(id string, roleName string, members []string, token string) errors.SDKError { - ret := _m.Called(id, roleName, members, token) +// RemoveDomainRoleMembers provides a mock function with given fields: id, roleID, members, token +func (_m *SDK) RemoveDomainRoleMembers(id string, roleID string, members []string, token string) errors.SDKError { + ret := _m.Called(id, roleID, members, token) if len(ret) == 0 { panic("no return value specified for RemoveDomainRoleMembers") @@ -5810,7 +5810,7 @@ func (_m *SDK) RemoveDomainRoleMembers(id string, roleName string, members []str var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, []string, string) errors.SDKError); ok { - r0 = rf(id, roleName, members, token) + r0 = rf(id, roleID, members, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5827,14 +5827,14 @@ type SDK_RemoveDomainRoleMembers_Call struct { // RemoveDomainRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - members []string // - token string -func (_e *SDK_Expecter) RemoveDomainRoleMembers(id interface{}, roleName interface{}, members interface{}, token interface{}) *SDK_RemoveDomainRoleMembers_Call { - return &SDK_RemoveDomainRoleMembers_Call{Call: _e.mock.On("RemoveDomainRoleMembers", id, roleName, members, token)} +func (_e *SDK_Expecter) RemoveDomainRoleMembers(id interface{}, roleID interface{}, members interface{}, token interface{}) *SDK_RemoveDomainRoleMembers_Call { + return &SDK_RemoveDomainRoleMembers_Call{Call: _e.mock.On("RemoveDomainRoleMembers", id, roleID, members, token)} } -func (_c *SDK_RemoveDomainRoleMembers_Call) Run(run func(id string, roleName string, members []string, token string)) *SDK_RemoveDomainRoleMembers_Call { +func (_c *SDK_RemoveDomainRoleMembers_Call) Run(run func(id string, roleID string, members []string, token string)) *SDK_RemoveDomainRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].([]string), args[3].(string)) }) @@ -5902,9 +5902,9 @@ func (_c *SDK_RemoveGroupParent_Call) RunAndReturn(run func(string, string, stri return _c } -// RemoveGroupRoleActions provides a mock function with given fields: id, roleName, domainID, actions, token -func (_m *SDK) RemoveGroupRoleActions(id string, roleName string, domainID string, actions []string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, actions, token) +// RemoveGroupRoleActions provides a mock function with given fields: id, roleID, domainID, actions, token +func (_m *SDK) RemoveGroupRoleActions(id string, roleID string, domainID string, actions []string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, actions, token) if len(ret) == 0 { panic("no return value specified for RemoveGroupRoleActions") @@ -5912,7 +5912,7 @@ func (_m *SDK) RemoveGroupRoleActions(id string, roleName string, domainID strin var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, actions, token) + r0 = rf(id, roleID, domainID, actions, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5929,15 +5929,15 @@ type SDK_RemoveGroupRoleActions_Call struct { // RemoveGroupRoleActions is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - actions []string // - token string -func (_e *SDK_Expecter) RemoveGroupRoleActions(id interface{}, roleName interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_RemoveGroupRoleActions_Call { - return &SDK_RemoveGroupRoleActions_Call{Call: _e.mock.On("RemoveGroupRoleActions", id, roleName, domainID, actions, token)} +func (_e *SDK_Expecter) RemoveGroupRoleActions(id interface{}, roleID interface{}, domainID interface{}, actions interface{}, token interface{}) *SDK_RemoveGroupRoleActions_Call { + return &SDK_RemoveGroupRoleActions_Call{Call: _e.mock.On("RemoveGroupRoleActions", id, roleID, domainID, actions, token)} } -func (_c *SDK_RemoveGroupRoleActions_Call) Run(run func(id string, roleName string, domainID string, actions []string, token string)) *SDK_RemoveGroupRoleActions_Call { +func (_c *SDK_RemoveGroupRoleActions_Call) Run(run func(id string, roleID string, domainID string, actions []string, token string)) *SDK_RemoveGroupRoleActions_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -5954,9 +5954,9 @@ func (_c *SDK_RemoveGroupRoleActions_Call) RunAndReturn(run func(string, string, return _c } -// RemoveGroupRoleMembers provides a mock function with given fields: id, roleName, domainID, members, token -func (_m *SDK) RemoveGroupRoleMembers(id string, roleName string, domainID string, members []string, token string) errors.SDKError { - ret := _m.Called(id, roleName, domainID, members, token) +// RemoveGroupRoleMembers provides a mock function with given fields: id, roleID, domainID, members, token +func (_m *SDK) RemoveGroupRoleMembers(id string, roleID string, domainID string, members []string, token string) errors.SDKError { + ret := _m.Called(id, roleID, domainID, members, token) if len(ret) == 0 { panic("no return value specified for RemoveGroupRoleMembers") @@ -5964,7 +5964,7 @@ func (_m *SDK) RemoveGroupRoleMembers(id string, roleName string, domainID strin var r0 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, []string, string) errors.SDKError); ok { - r0 = rf(id, roleName, domainID, members, token) + r0 = rf(id, roleID, domainID, members, token) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(errors.SDKError) @@ -5981,15 +5981,15 @@ type SDK_RemoveGroupRoleMembers_Call struct { // RemoveGroupRoleMembers is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - domainID string // - members []string // - token string -func (_e *SDK_Expecter) RemoveGroupRoleMembers(id interface{}, roleName interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_RemoveGroupRoleMembers_Call { - return &SDK_RemoveGroupRoleMembers_Call{Call: _e.mock.On("RemoveGroupRoleMembers", id, roleName, domainID, members, token)} +func (_e *SDK_Expecter) RemoveGroupRoleMembers(id interface{}, roleID interface{}, domainID interface{}, members interface{}, token interface{}) *SDK_RemoveGroupRoleMembers_Call { + return &SDK_RemoveGroupRoleMembers_Call{Call: _e.mock.On("RemoveGroupRoleMembers", id, roleID, domainID, members, token)} } -func (_c *SDK_RemoveGroupRoleMembers_Call) Run(run func(id string, roleName string, domainID string, members []string, token string)) *SDK_RemoveGroupRoleMembers_Call { +func (_c *SDK_RemoveGroupRoleMembers_Call) Run(run func(id string, roleID string, domainID string, members []string, token string)) *SDK_RemoveGroupRoleMembers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].([]string), args[4].(string)) }) @@ -6865,9 +6865,9 @@ func (_c *SDK_UpdateClient_Call) RunAndReturn(run func(sdk.Client, string, strin return _c } -// UpdateClientRole provides a mock function with given fields: id, roleName, newName, domainID, token -func (_m *SDK) UpdateClientRole(id string, roleName string, newName string, domainID string, token string) (sdk.Role, errors.SDKError) { - ret := _m.Called(id, roleName, newName, domainID, token) +// UpdateClientRole provides a mock function with given fields: id, roleID, newName, domainID, token +func (_m *SDK) UpdateClientRole(id string, roleID string, newName string, domainID string, token string) (sdk.Role, errors.SDKError) { + ret := _m.Called(id, roleID, newName, domainID, token) if len(ret) == 0 { panic("no return value specified for UpdateClientRole") @@ -6876,16 +6876,16 @@ func (_m *SDK) UpdateClientRole(id string, roleName string, newName string, doma var r0 sdk.Role var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string, string) (sdk.Role, errors.SDKError)); ok { - return rf(id, roleName, newName, domainID, token) + return rf(id, roleID, newName, domainID, token) } if rf, ok := ret.Get(0).(func(string, string, string, string, string) sdk.Role); ok { - r0 = rf(id, roleName, newName, domainID, token) + r0 = rf(id, roleID, newName, domainID, token) } else { r0 = ret.Get(0).(sdk.Role) } if rf, ok := ret.Get(1).(func(string, string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, newName, domainID, token) + r1 = rf(id, roleID, newName, domainID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -6902,15 +6902,15 @@ type SDK_UpdateClientRole_Call struct { // UpdateClientRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - newName string // - domainID string // - token string -func (_e *SDK_Expecter) UpdateClientRole(id interface{}, roleName interface{}, newName interface{}, domainID interface{}, token interface{}) *SDK_UpdateClientRole_Call { - return &SDK_UpdateClientRole_Call{Call: _e.mock.On("UpdateClientRole", id, roleName, newName, domainID, token)} +func (_e *SDK_Expecter) UpdateClientRole(id interface{}, roleID interface{}, newName interface{}, domainID interface{}, token interface{}) *SDK_UpdateClientRole_Call { + return &SDK_UpdateClientRole_Call{Call: _e.mock.On("UpdateClientRole", id, roleID, newName, domainID, token)} } -func (_c *SDK_UpdateClientRole_Call) Run(run func(id string, roleName string, newName string, domainID string, token string)) *SDK_UpdateClientRole_Call { +func (_c *SDK_UpdateClientRole_Call) Run(run func(id string, roleID string, newName string, domainID string, token string)) *SDK_UpdateClientRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string)) }) @@ -7107,9 +7107,9 @@ func (_c *SDK_UpdateDomain_Call) RunAndReturn(run func(sdk.Domain, string) (sdk. return _c } -// UpdateDomainRole provides a mock function with given fields: id, roleName, newName, token -func (_m *SDK) UpdateDomainRole(id string, roleName string, newName string, token string) (sdk.Role, errors.SDKError) { - ret := _m.Called(id, roleName, newName, token) +// UpdateDomainRole provides a mock function with given fields: id, roleID, newName, token +func (_m *SDK) UpdateDomainRole(id string, roleID string, newName string, token string) (sdk.Role, errors.SDKError) { + ret := _m.Called(id, roleID, newName, token) if len(ret) == 0 { panic("no return value specified for UpdateDomainRole") @@ -7118,16 +7118,16 @@ func (_m *SDK) UpdateDomainRole(id string, roleName string, newName string, toke var r0 sdk.Role var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string) (sdk.Role, errors.SDKError)); ok { - return rf(id, roleName, newName, token) + return rf(id, roleID, newName, token) } if rf, ok := ret.Get(0).(func(string, string, string, string) sdk.Role); ok { - r0 = rf(id, roleName, newName, token) + r0 = rf(id, roleID, newName, token) } else { r0 = ret.Get(0).(sdk.Role) } if rf, ok := ret.Get(1).(func(string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, newName, token) + r1 = rf(id, roleID, newName, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -7144,14 +7144,14 @@ type SDK_UpdateDomainRole_Call struct { // UpdateDomainRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - newName string // - token string -func (_e *SDK_Expecter) UpdateDomainRole(id interface{}, roleName interface{}, newName interface{}, token interface{}) *SDK_UpdateDomainRole_Call { - return &SDK_UpdateDomainRole_Call{Call: _e.mock.On("UpdateDomainRole", id, roleName, newName, token)} +func (_e *SDK_Expecter) UpdateDomainRole(id interface{}, roleID interface{}, newName interface{}, token interface{}) *SDK_UpdateDomainRole_Call { + return &SDK_UpdateDomainRole_Call{Call: _e.mock.On("UpdateDomainRole", id, roleID, newName, token)} } -func (_c *SDK_UpdateDomainRole_Call) Run(run func(id string, roleName string, newName string, token string)) *SDK_UpdateDomainRole_Call { +func (_c *SDK_UpdateDomainRole_Call) Run(run func(id string, roleID string, newName string, token string)) *SDK_UpdateDomainRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string)) }) @@ -7228,9 +7228,9 @@ func (_c *SDK_UpdateGroup_Call) RunAndReturn(run func(sdk.Group, string, string) return _c } -// UpdateGroupRole provides a mock function with given fields: id, roleName, newName, domainID, token -func (_m *SDK) UpdateGroupRole(id string, roleName string, newName string, domainID string, token string) (sdk.Role, errors.SDKError) { - ret := _m.Called(id, roleName, newName, domainID, token) +// UpdateGroupRole provides a mock function with given fields: id, roleID, newName, domainID, token +func (_m *SDK) UpdateGroupRole(id string, roleID string, newName string, domainID string, token string) (sdk.Role, errors.SDKError) { + ret := _m.Called(id, roleID, newName, domainID, token) if len(ret) == 0 { panic("no return value specified for UpdateGroupRole") @@ -7239,16 +7239,16 @@ func (_m *SDK) UpdateGroupRole(id string, roleName string, newName string, domai var r0 sdk.Role var r1 errors.SDKError if rf, ok := ret.Get(0).(func(string, string, string, string, string) (sdk.Role, errors.SDKError)); ok { - return rf(id, roleName, newName, domainID, token) + return rf(id, roleID, newName, domainID, token) } if rf, ok := ret.Get(0).(func(string, string, string, string, string) sdk.Role); ok { - r0 = rf(id, roleName, newName, domainID, token) + r0 = rf(id, roleID, newName, domainID, token) } else { r0 = ret.Get(0).(sdk.Role) } if rf, ok := ret.Get(1).(func(string, string, string, string, string) errors.SDKError); ok { - r1 = rf(id, roleName, newName, domainID, token) + r1 = rf(id, roleID, newName, domainID, token) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.SDKError) @@ -7265,15 +7265,15 @@ type SDK_UpdateGroupRole_Call struct { // UpdateGroupRole is a helper method to define mock.On call // - id string -// - roleName string +// - roleID string // - newName string // - domainID string // - token string -func (_e *SDK_Expecter) UpdateGroupRole(id interface{}, roleName interface{}, newName interface{}, domainID interface{}, token interface{}) *SDK_UpdateGroupRole_Call { - return &SDK_UpdateGroupRole_Call{Call: _e.mock.On("UpdateGroupRole", id, roleName, newName, domainID, token)} +func (_e *SDK_Expecter) UpdateGroupRole(id interface{}, roleID interface{}, newName interface{}, domainID interface{}, token interface{}) *SDK_UpdateGroupRole_Call { + return &SDK_UpdateGroupRole_Call{Call: _e.mock.On("UpdateGroupRole", id, roleID, newName, domainID, token)} } -func (_c *SDK_UpdateGroupRole_Call) Run(run func(id string, roleName string, newName string, domainID string, token string)) *SDK_UpdateGroupRole_Call { +func (_c *SDK_UpdateGroupRole_Call) Run(run func(id string, roleID string, newName string, domainID string, token string)) *SDK_UpdateGroupRole_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string)) }) diff --git a/pkg/sdk/roles.go b/pkg/sdk/roles.go index e441fed26e..fd87d9178b 100644 --- a/pkg/sdk/roles.go +++ b/pkg/sdk/roles.go @@ -57,10 +57,10 @@ func (sdk mgSDK) listRoles(entityURL, entityEndpoint, id, domainID string, pm Pa return rp, nil } -func (sdk mgSDK) viewRole(entityURL, entityEndpoint, id, roleName, domainID, token string) (Role, errors.SDKError) { - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName) +func (sdk mgSDK) viewRole(entityURL, entityEndpoint, id, roleID, domainID, token string) (Role, errors.SDKError) { + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID) if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName) + url = fmt.Sprintf("%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID) } _, body, sdkerr := sdk.processRequest(http.MethodGet, url, token, nil, nil, http.StatusOK) if sdkerr != nil { @@ -75,16 +75,16 @@ func (sdk mgSDK) viewRole(entityURL, entityEndpoint, id, roleName, domainID, tok return role, nil } -func (sdk mgSDK) updateRole(entityURL, entityEndpoint, id, roleName, newName, domainID string, token string) (Role, errors.SDKError) { +func (sdk mgSDK) updateRole(entityURL, entityEndpoint, id, roleID, newName, domainID string, token string) (Role, errors.SDKError) { ucr := updateRoleNameReq{Name: newName} data, err := json.Marshal(ucr) if err != nil { return Role{}, errors.NewSDKError(err) } - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName) + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID) if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName) + url = fmt.Sprintf("%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID) } _, body, sdkerr := sdk.processRequest(http.MethodPut, url, token, data, nil, http.StatusOK) if sdkerr != nil { @@ -99,26 +99,26 @@ func (sdk mgSDK) updateRole(entityURL, entityEndpoint, id, roleName, newName, do return role, nil } -func (sdk mgSDK) deleteRole(entityURL, entityEndpoint, id, roleName, domainID, token string) errors.SDKError { - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName) +func (sdk mgSDK) deleteRole(entityURL, entityEndpoint, id, roleID, domainID, token string) errors.SDKError { + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID) if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName) + url = fmt.Sprintf("%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID) } _, _, sdkerr := sdk.processRequest(http.MethodDelete, url, token, nil, nil, http.StatusNoContent) return sdkerr } -func (sdk mgSDK) addRoleActions(entityURL, entityEndpoint, id, roleName, domainID string, actions []string, token string) ([]string, errors.SDKError) { +func (sdk mgSDK) addRoleActions(entityURL, entityEndpoint, id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError) { acra := roleActionsReq{Actions: actions} data, err := json.Marshal(acra) if err != nil { return []string{}, errors.NewSDKError(err) } - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint) + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint) if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint) + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint) } _, body, sdkerr := sdk.processRequest(http.MethodPost, url, token, data, nil, http.StatusOK) if sdkerr != nil { @@ -133,10 +133,10 @@ func (sdk mgSDK) addRoleActions(entityURL, entityEndpoint, id, roleName, domainI return res.Actions, nil } -func (sdk mgSDK) listRoleActions(entityURL, entityEndpoint, id, roleName, domainID string, token string) ([]string, errors.SDKError) { - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint) +func (sdk mgSDK) listRoleActions(entityURL, entityEndpoint, id, roleID, domainID string, token string) ([]string, errors.SDKError) { + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint) if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint) + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint) } _, body, sdkerr := sdk.processRequest(http.MethodGet, url, token, nil, nil, http.StatusOK) if sdkerr != nil { @@ -151,42 +151,42 @@ func (sdk mgSDK) listRoleActions(entityURL, entityEndpoint, id, roleName, domain return res.Actions, nil } -func (sdk mgSDK) removeRoleActions(entityURL, entityEndpoint, id, roleName, domainID string, actions []string, token string) errors.SDKError { +func (sdk mgSDK) removeRoleActions(entityURL, entityEndpoint, id, roleID, domainID string, actions []string, token string) errors.SDKError { rcra := roleActionsReq{Actions: actions} data, err := json.Marshal(rcra) if err != nil { return errors.NewSDKError(err) } - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint, "delete") + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint, "delete") if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint, "delete") + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint, "delete") } _, _, sdkerr := sdk.processRequest(http.MethodPost, url, token, data, nil, http.StatusNoContent) return sdkerr } -func (sdk mgSDK) removeAllRoleActions(entityURL, entityEndpoint, id, roleName, domainID, token string) errors.SDKError { - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint, "delete-all") +func (sdk mgSDK) removeAllRoleActions(entityURL, entityEndpoint, id, roleID, domainID, token string) errors.SDKError { + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint, "delete-all") if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, actionsEndpoint, "delete-all") + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, actionsEndpoint, "delete-all") } _, _, sdkerr := sdk.processRequest(http.MethodPost, url, token, nil, nil, http.StatusNoContent) return sdkerr } -func (sdk mgSDK) addRoleMembers(entityURL, entityEndpoint, id, roleName, domainID string, members []string, token string) ([]string, errors.SDKError) { +func (sdk mgSDK) addRoleMembers(entityURL, entityEndpoint, id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError) { acrm := roleMembersReq{Members: members} data, err := json.Marshal(acrm) if err != nil { return []string{}, errors.NewSDKError(err) } - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint) + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint) if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint) + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint) } _, body, sdkerr := sdk.processRequest(http.MethodPost, url, token, data, nil, http.StatusOK) if sdkerr != nil { @@ -201,10 +201,10 @@ func (sdk mgSDK) addRoleMembers(entityURL, entityEndpoint, id, roleName, domainI return res.Members, nil } -func (sdk mgSDK) listRoleMembers(entityURL, entityEndpoint, id, roleName, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { - endpoint := fmt.Sprintf("%s/%s/%s/%s/%s/%s", domainID, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint) +func (sdk mgSDK) listRoleMembers(entityURL, entityEndpoint, id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) { + endpoint := fmt.Sprintf("%s/%s/%s/%s/%s/%s", domainID, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint) if entityEndpoint == domainsEndpoint { - endpoint = fmt.Sprintf("%s/%s/%s/%s/%s", entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint) + endpoint = fmt.Sprintf("%s/%s/%s/%s/%s", entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint) } url, err := sdk.withQueryParams(entityURL, endpoint, pm) if err != nil { @@ -223,26 +223,26 @@ func (sdk mgSDK) listRoleMembers(entityURL, entityEndpoint, id, roleName, domain return res, nil } -func (sdk mgSDK) removeRoleMembers(entityURL, entityEndpoint, id, roleName, domainID string, members []string, token string) errors.SDKError { +func (sdk mgSDK) removeRoleMembers(entityURL, entityEndpoint, id, roleID, domainID string, members []string, token string) errors.SDKError { rcrm := roleMembersReq{Members: members} data, err := json.Marshal(rcrm) if err != nil { return errors.NewSDKError(err) } - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint, "delete") + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint, "delete") if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint, "delete") + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint, "delete") } _, _, sdkerr := sdk.processRequest(http.MethodPost, url, token, data, nil, http.StatusNoContent) return sdkerr } -func (sdk mgSDK) removeAllRoleMembers(entityURL, entityEndpoint, id, roleName, domainID, token string) errors.SDKError { - url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint, "delete-all") +func (sdk mgSDK) removeAllRoleMembers(entityURL, entityEndpoint, id, roleID, domainID, token string) errors.SDKError { + url := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s/%s", entityURL, domainID, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint, "delete-all") if entityEndpoint == domainsEndpoint { - url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleName, membersEndpoint, "delete-all") + url = fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", entityURL, entityEndpoint, id, rolesEndpoint, roleID, membersEndpoint, "delete-all") } _, _, sdkerr := sdk.processRequest(http.MethodPost, url, token, nil, nil, http.StatusNoContent) diff --git a/pkg/sdk/sdk.go b/pkg/sdk/sdk.go index 3f1a569b60..c846fdf954 100644 --- a/pkg/sdk/sdk.go +++ b/pkg/sdk/sdk.go @@ -547,90 +547,90 @@ type SDK interface { // fmt.Println(roles) ClientRoles(id, domainID string, pm PageMetadata, token string) (RolesPage, errors.SDKError) - // ClientRole returns client role object by roleName. + // ClientRole returns client role object by roleID. // // example: - // role, _ := sdk.ClientRole("clientID", "roleName", "domainID", "token") + // role, _ := sdk.ClientRole("clientID", "roleID", "domainID", "token") // fmt.Println(role) - ClientRole(id, roleName, domainID, token string) (Role, errors.SDKError) + ClientRole(id, roleID, domainID, token string) (Role, errors.SDKError) // UpdateClientRole updates existing client role name. // // example: - // role, _ := sdk.UpdateClientRole{"clientID", "roleName", "newName", "domainID", "token"} + // role, _ := sdk.UpdateClientRole{"clientID", "roleID", "newName", "domainID", "token"} // fmr.Println(role) - UpdateClientRole(id, roleName, newName, domainID string, token string) (Role, errors.SDKError) + UpdateClientRole(id, roleID, newName, domainID string, token string) (Role, errors.SDKError) - // DeleteClientRole deletes a client role with the given clientID and roleName. + // DeleteClientRole deletes a client role with the given clientID and roleID. // // example: - // err := sdk.DeleteClientRole("clientID", "roleName", "domainID", "token") + // err := sdk.DeleteClientRole("clientID", "roleID", "domainID", "token") // fmt.Println(err) - DeleteClientRole(id, roleName, domainID, token string) errors.SDKError + DeleteClientRole(id, roleID, domainID, token string) errors.SDKError // AddClientRoleActions adds actions to a client role. // // example: // actions := []string{"read", "update"} - // actions, _ := sdk.AddClientRoleActions("clientID", "roleName", "domainID", actions, "token") + // actions, _ := sdk.AddClientRoleActions("clientID", "roleID", "domainID", actions, "token") // fmt.Println(actions) - AddClientRoleActions(id, roleName, domainID string, actions []string, token string) ([]string, errors.SDKError) + AddClientRoleActions(id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError) - // ClientRoleActions returns client role actions by roleName. + // ClientRoleActions returns client role actions by roleID. // // example: - // actions, _ := sdk.ClientRoleActions("clientID", "roleName", "domainID", "token") + // actions, _ := sdk.ClientRoleActions("clientID", "roleID", "domainID", "token") // fmt.Println(actions) - ClientRoleActions(id, roleName, domainID string, token string) ([]string, errors.SDKError) + ClientRoleActions(id, roleID, domainID string, token string) ([]string, errors.SDKError) // RemoveClientRoleActions removes actions from a client role. // // example: // actions := []string{"read", "update"} - // err := sdk.RemoveClientRoleActions("clientID", "roleName", "domainID", actions, "token") + // err := sdk.RemoveClientRoleActions("clientID", "roleID", "domainID", actions, "token") // fmt.Println(err) - RemoveClientRoleActions(id, roleName, domainID string, actions []string, token string) errors.SDKError + RemoveClientRoleActions(id, roleID, domainID string, actions []string, token string) errors.SDKError // RemoveAllClientRoleActions removes all actions from a client role. // // example: - // err := sdk.RemoveAllClientRoleActions("clientID", "roleName", "domainID", "token") + // err := sdk.RemoveAllClientRoleActions("clientID", "roleID", "domainID", "token") // fmt.Println(err) - RemoveAllClientRoleActions(id, roleName, domainID, token string) errors.SDKError + RemoveAllClientRoleActions(id, roleID, domainID, token string) errors.SDKError // AddClientRoleMembers adds members to a client role. // // example: // members := []string{"member_id_1", "member_id_2"} - // members, _ := sdk.AddClientRoleMembers("clientID", "roleName", "domainID", members, "token") + // members, _ := sdk.AddClientRoleMembers("clientID", "roleID", "domainID", members, "token") // fmt.Println(members) - AddClientRoleMembers(id, roleName, domainID string, members []string, token string) ([]string, errors.SDKError) + AddClientRoleMembers(id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError) - // ClientRoleMembers returns client role members by roleName. + // ClientRoleMembers returns client role members by roleID. // // example: // pm := sdk.PageMetadata{ // Offset: 0, // Limit: 10, // } - // members, _ := sdk.ClientRoleMembers("clientID", "roleName", "domainID", pm,"token") + // members, _ := sdk.ClientRoleMembers("clientID", "roleID", "domainID", pm,"token") // fmt.Println(members) - ClientRoleMembers(id, roleName, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) + ClientRoleMembers(id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) // RemoveClientRoleMembers removes members from a client role. // // example: // members := []string{"member_id_1", "member_id_2"} - // err := sdk.RemoveClientRoleMembers("clientID", "roleName", "domainID", members, "token") + // err := sdk.RemoveClientRoleMembers("clientID", "roleID", "domainID", members, "token") // fmt.Println(err) - RemoveClientRoleMembers(id, roleName, domainID string, members []string, token string) errors.SDKError + RemoveClientRoleMembers(id, roleID, domainID string, members []string, token string) errors.SDKError // RemoveAllClientRoleMembers removes all members from a client role. // // example: - // err := sdk.RemoveAllClientRoleMembers("clientID", "roleName", "domainID", "token") + // err := sdk.RemoveAllClientRoleMembers("clientID", "roleID", "domainID", "token") // fmt.Println(err) - RemoveAllClientRoleMembers(id, roleName, domainID, token string) errors.SDKError + RemoveAllClientRoleMembers(id, roleID, domainID, token string) errors.SDKError // AvailableClientRoleActions returns available actions for a client role. // @@ -789,90 +789,90 @@ type SDK interface { // fmt.Println(roles) GroupRoles(id, domainID string, pm PageMetadata, token string) (RolesPage, errors.SDKError) - // GroupRole returns group role object by roleName. + // GroupRole returns group role object by roleID. // // example: - // role, _ := sdk.GroupRole("groupID", "roleName", "domainID", "token") + // role, _ := sdk.GroupRole("groupID", "roleID", "domainID", "token") // fmt.Println(role) - GroupRole(id, roleName, domainID, token string) (Role, errors.SDKError) + GroupRole(id, roleID, domainID, token string) (Role, errors.SDKError) // UpdateGroupRole updates existing group role name. // // example: - // role, _ := sdk.UpdateGroupRole{"groupID", "roleName", "newName", "domainID", "token"} + // role, _ := sdk.UpdateGroupRole{"groupID", "roleID", "newName", "domainID", "token"} // fmr.Println(role) - UpdateGroupRole(id, roleName, newName, domainID string, token string) (Role, errors.SDKError) + UpdateGroupRole(id, roleID, newName, domainID string, token string) (Role, errors.SDKError) - // DeleteGroupRole deletes a group role with the given groupID and roleName. + // DeleteGroupRole deletes a group role with the given groupID and roleID. // // example: - // err := sdk.DeleteGroupRole("groupID", "roleName", "domainID", "token") + // err := sdk.DeleteGroupRole("groupID", "roleID", "domainID", "token") // fmt.Println(err) - DeleteGroupRole(id, roleName, domainID, token string) errors.SDKError + DeleteGroupRole(id, roleID, domainID, token string) errors.SDKError // AddGroupRoleActions adds actions to a group role. // // example: // actions := []string{"read", "update"} - // actions, _ := sdk.AddGroupRoleActions("groupID", "roleName", "domainID", actions, "token") + // actions, _ := sdk.AddGroupRoleActions("groupID", "roleID", "domainID", actions, "token") // fmt.Println(actions) - AddGroupRoleActions(id, roleName, domainID string, actions []string, token string) ([]string, errors.SDKError) + AddGroupRoleActions(id, roleID, domainID string, actions []string, token string) ([]string, errors.SDKError) - // GroupRoleActions returns group role actions by roleName. + // GroupRoleActions returns group role actions by roleID. // // example: - // actions, _ := sdk.GroupRoleActions("groupID", "roleName", "domainID", "token") + // actions, _ := sdk.GroupRoleActions("groupID", "roleID", "domainID", "token") // fmt.Println(actions) - GroupRoleActions(id, roleName, domainID string, token string) ([]string, errors.SDKError) + GroupRoleActions(id, roleID, domainID string, token string) ([]string, errors.SDKError) // RemoveGroupRoleActions removes actions from a group role. // // example: // actions := []string{"read", "update"} - // err := sdk.RemoveGroupRoleActions("groupID", "roleName", "domainID", actions, "token") + // err := sdk.RemoveGroupRoleActions("groupID", "roleID", "domainID", actions, "token") // fmt.Println(err) - RemoveGroupRoleActions(id, roleName, domainID string, actions []string, token string) errors.SDKError + RemoveGroupRoleActions(id, roleID, domainID string, actions []string, token string) errors.SDKError // RemoveAllGroupRoleActions removes all actions from a group role. // // example: - // err := sdk.RemoveAllGroupRoleActions("groupID", "roleName", "domainID", "token") + // err := sdk.RemoveAllGroupRoleActions("groupID", "roleID", "domainID", "token") // fmt.Println(err) - RemoveAllGroupRoleActions(id, roleName, domainID, token string) errors.SDKError + RemoveAllGroupRoleActions(id, roleID, domainID, token string) errors.SDKError // AddGroupRoleMembers adds members to a group role. // // example: // members := []string{"member_id_1", "member_id_2"} - // members, _ := sdk.AddGroupRoleMembers("groupID", "roleName", "domainID", members, "token") + // members, _ := sdk.AddGroupRoleMembers("groupID", "roleID", "domainID", members, "token") // fmt.Println(members) - AddGroupRoleMembers(id, roleName, domainID string, members []string, token string) ([]string, errors.SDKError) + AddGroupRoleMembers(id, roleID, domainID string, members []string, token string) ([]string, errors.SDKError) - // GroupRoleMembers returns group role members by roleName. + // GroupRoleMembers returns group role members by roleID. // // example: // pm := sdk.PageMetadata{ // Offset: 0, // Limit: 10, // } - // members, _ := sdk.GroupRoleMembers("groupID", "roleName", "domainID", "token") + // members, _ := sdk.GroupRoleMembers("groupID", "roleID", "domainID", "token") // fmt.Println(members) - GroupRoleMembers(id, roleName, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) + GroupRoleMembers(id, roleID, domainID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) // RemoveGroupRoleMembers removes members from a group role. // // example: // members := []string{"member_id_1", "member_id_2"} - // err := sdk.RemoveGroupRoleMembers("groupID", "roleName", "domainID", members, "token") + // err := sdk.RemoveGroupRoleMembers("groupID", "roleID", "domainID", members, "token") // fmt.Println(err) - RemoveGroupRoleMembers(id, roleName, domainID string, members []string, token string) errors.SDKError + RemoveGroupRoleMembers(id, roleID, domainID string, members []string, token string) errors.SDKError // RemoveAllGroupRoleMembers removes all members from a group role. // // example: - // err := sdk.RemoveAllGroupRoleMembers("groupID", "roleName", "domainID", "token") + // err := sdk.RemoveAllGroupRoleMembers("groupID", "roleID", "domainID", "token") // fmt.Println(err) - RemoveAllGroupRoleMembers(id, roleName, domainID, token string) errors.SDKError + RemoveAllGroupRoleMembers(id, roleID, domainID, token string) errors.SDKError // AvailableGroupRoleActions returns available actions for a group role. // @@ -1306,90 +1306,90 @@ type SDK interface { // fmt.Println(roles) DomainRoles(id string, pm PageMetadata, token string) (RolesPage, errors.SDKError) - // DomainRole returns domain role object by roleName. + // DomainRole returns domain role object by roleID. // // example: - // role, _ := sdk.DomainRole("domainID", "roleName", "token") + // role, _ := sdk.DomainRole("domainID", "roleID", "token") // fmt.Println(role) - DomainRole(id, roleName, token string) (Role, errors.SDKError) + DomainRole(id, roleID, token string) (Role, errors.SDKError) // UpdateDomainRole updates existing domain role name. // // example: - // role, _ := sdk.UpdateDomainRole("domainID", "roleName", "newName", "token") + // role, _ := sdk.UpdateDomainRole("domainID", "roleID", "newName", "token") // fmt.Println(role) - UpdateDomainRole(id, roleName, newName string, token string) (Role, errors.SDKError) + UpdateDomainRole(id, roleID, newName string, token string) (Role, errors.SDKError) - // DeleteDomainRole deletes a domain role with the given domainID and roleName. + // DeleteDomainRole deletes a domain role with the given domainID and roleID. // // example: - // err := sdk.DeleteDomainRole("domainID", "roleName", "token") + // err := sdk.DeleteDomainRole("domainID", "roleID", "token") // fmt.Println(err) - DeleteDomainRole(id, roleName, token string) errors.SDKError + DeleteDomainRole(id, roleID, token string) errors.SDKError // AddDomainRoleActions adds actions to a domain role. // // example: // actions := []string{"read", "update"} - // actions, _ := sdk.AddDomainRoleActions("domainID", "roleName", actions, "token") + // actions, _ := sdk.AddDomainRoleActions("domainID", "roleID", actions, "token") // fmt.Println(actions) - AddDomainRoleActions(id, roleName string, actions []string, token string) ([]string, errors.SDKError) + AddDomainRoleActions(id, roleID string, actions []string, token string) ([]string, errors.SDKError) - // DomainRoleActions returns domain role actions by roleName. + // DomainRoleActions returns domain role actions by roleID. // // example: - // actions, _ := sdk.DomainRoleActions("domainID", "roleName", "token") + // actions, _ := sdk.DomainRoleActions("domainID", "roleID", "token") // fmt.Println(actions) - DomainRoleActions(id, roleName string, token string) ([]string, errors.SDKError) + DomainRoleActions(id, roleID string, token string) ([]string, errors.SDKError) // RemoveDomainRoleActions removes actions from a domain role. // // example: // actions := []string{"read", "update"} - // err := sdk.RemoveDomainRoleActions("domainID", "roleName", actions, "token") + // err := sdk.RemoveDomainRoleActions("domainID", "roleID", actions, "token") // fmt.Println(err) - RemoveDomainRoleActions(id, roleName string, actions []string, token string) errors.SDKError + RemoveDomainRoleActions(id, roleID string, actions []string, token string) errors.SDKError // RemoveAllDomainRoleActions removes all actions from a domain role. // // example: - // err := sdk.RemoveAllDomainRoleActions("domainID", "roleName", "token") + // err := sdk.RemoveAllDomainRoleActions("domainID", "roleID", "token") // fmt.Println(err) - RemoveAllDomainRoleActions(id, roleName, token string) errors.SDKError + RemoveAllDomainRoleActions(id, roleID, token string) errors.SDKError // AddDomainRoleMembers adds members to a domain role. // // example: // members := []string{"member_id_1", "member_id_2"} - // members, _ := sdk.AddDomainRoleMembers("domainID", "roleName", members, "token") + // members, _ := sdk.AddDomainRoleMembers("domainID", "roleID", members, "token") // fmt.Println(members) - AddDomainRoleMembers(id, roleName string, members []string, token string) ([]string, errors.SDKError) + AddDomainRoleMembers(id, roleID string, members []string, token string) ([]string, errors.SDKError) - // DomainRoleMembers returns domain role members by roleName. + // DomainRoleMembers returns domain role members by roleID. // // example: // pm := sdk.PageMetadata{ // Offset: 0, // Limit: 10, // } - // members, _ := sdk.DomainRoleMembers("domainID", "roleName", "token") + // members, _ := sdk.DomainRoleMembers("domainID", "roleID", "token") // fmt.Println(members) - DomainRoleMembers(id, roleName string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) + DomainRoleMembers(id, roleID string, pm PageMetadata, token string) (RoleMembersPage, errors.SDKError) // RemoveDomainRoleMembers removes members from a domain role. // // example: // members := []string{"member_id_1", "member_id_2"} - // err := sdk.RemoveDomainRoleMembers("domainID", "roleName", members, "token") + // err := sdk.RemoveDomainRoleMembers("domainID", "roleID", members, "token") // fmt.Println(err) - RemoveDomainRoleMembers(id, roleName string, members []string, token string) errors.SDKError + RemoveDomainRoleMembers(id, roleID string, members []string, token string) errors.SDKError // RemoveAllDomainRoleMembers removes all members from a domain role. // // example: - // err := sdk.RemoveAllDomainRoleMembers("domainID", "roleName", "token") + // err := sdk.RemoveAllDomainRoleMembers("domainID", "roleID", "token") // fmt.Println(err) - RemoveAllDomainRoleMembers(id, roleName, token string) errors.SDKError + RemoveAllDomainRoleMembers(id, roleID, token string) errors.SDKError // AvailableDomainRoleActions returns available actions for a domain role. // diff --git a/pkg/sdk/setup_test.go b/pkg/sdk/setup_test.go index 33f858706b..b5bfef294d 100644 --- a/pkg/sdk/setup_test.go +++ b/pkg/sdk/setup_test.go @@ -34,7 +34,7 @@ const ( invalid = "invalid" wrongID = "wrongID" defPermission = "read_permission" - roleName = "roleName" + roleID = "roleID" ) var ( From c2cbd2dfaa788c3a633b5163f2f6d6563387996f Mon Sep 17 00:00:00 2001 From: Arvindh Date: Tue, 24 Dec 2024 22:10:34 +0530 Subject: [PATCH 5/5] change: role name to role id : fix test Signed-off-by: Arvindh --- api/http/common.go | 1 + pkg/sdk/clients_test.go | 302 +++++++++++++++++++-------------------- pkg/sdk/domains_test.go | 304 ++++++++++++++++++++------------------- pkg/sdk/groups_test.go | 307 ++++++++++++++++++++-------------------- pkg/sdk/setup_test.go | 2 +- 5 files changed, 457 insertions(+), 459 deletions(-) diff --git a/api/http/common.go b/api/http/common.go index dd3e0ce586..36210d4b5e 100644 --- a/api/http/common.go +++ b/api/http/common.go @@ -198,6 +198,7 @@ func EncodeError(_ context.Context, err error, w http.ResponseWriter) { errors.Contains(err, apiutil.ErrMissingParentGroupID), errors.Contains(err, apiutil.ErrMissingConnectionType), errors.Contains(err, apiutil.ErrMissingRoleName), + errors.Contains(err, apiutil.ErrMissingRoleID), errors.Contains(err, apiutil.ErrMissingPolicyEntityType), errors.Contains(err, apiutil.ErrMissingRoleMembers): err = unwrap(err) diff --git a/pkg/sdk/clients_test.go b/pkg/sdk/clients_test.go index 27d575bec5..2271489c70 100644 --- a/pkg/sdk/clients_test.go +++ b/pkg/sdk/clients_test.go @@ -2116,7 +2116,7 @@ func TestViewClientRole(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string svcRes roles.Role svcErr error authenticateErr error @@ -2128,7 +2128,7 @@ func TestViewClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: role.Name, + roleID: role.ID, svcRes: role, svcErr: nil, response: convertRole(role), @@ -2139,7 +2139,7 @@ func TestViewClientRole(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, authenticateErr: svcerr.ErrAuthentication, response: sdk.Role{}, @@ -2150,7 +2150,7 @@ func TestViewClientRole(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, response: sdk.Role{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -2160,7 +2160,7 @@ func TestViewClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, response: sdk.Role{}, @@ -2171,18 +2171,18 @@ func TestViewClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, svcErr: nil, response: sdk.Role{}, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "view client role with invalid role name", + desc: "view client role with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, response: sdk.Role{}, @@ -2196,12 +2196,12 @@ func TestViewClientRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RetrieveRole", mock.Anything, tc.session, tc.clientID, tc.roleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.ClientRole(tc.clientID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RetrieveRole", mock.Anything, tc.session, tc.clientID, tc.roleID).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.ClientRole(tc.clientID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RetrieveRole", mock.Anything, tc.session, tc.clientID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RetrieveRole", mock.Anything, tc.session, tc.clientID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2219,7 +2219,7 @@ func TestUpdateClientRole(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) newRoleName := valid userID := testsutil.GenerateUUID(t) createdAt := time.Now().UTC().Add(-time.Hour) @@ -2239,7 +2239,7 @@ func TestUpdateClientRole(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string newRoleName string svcRes roles.Role svcErr error @@ -2252,7 +2252,7 @@ func TestUpdateClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: role, svcErr: nil, @@ -2264,7 +2264,7 @@ func TestUpdateClientRole(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, authenticateErr: svcerr.ErrAuthentication, @@ -2276,7 +2276,7 @@ func TestUpdateClientRole(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, response: sdk.Role{}, @@ -2287,7 +2287,7 @@ func TestUpdateClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, @@ -2299,7 +2299,7 @@ func TestUpdateClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, svcErr: nil, @@ -2314,12 +2314,12 @@ func TestUpdateClientRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("UpdateRoleName", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.newRoleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.UpdateClientRole(tc.clientID, tc.roleName, tc.newRoleName, tc.domainID, tc.token) + svcCall := csvc.On("UpdateRoleName", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.newRoleName).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.UpdateClientRole(tc.clientID, tc.roleID, tc.newRoleName, tc.domainID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "UpdateRoleName", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.newRoleName) + ok := svcCall.Parent.AssertCalled(t, "UpdateRoleName", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.newRoleName) assert.True(t, ok) } svcCall.Unset() @@ -2337,7 +2337,7 @@ func TestDeleteClientRole(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) cases := []struct { desc string @@ -2345,7 +2345,7 @@ func TestDeleteClientRole(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -2355,7 +2355,7 @@ func TestDeleteClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -2364,7 +2364,7 @@ func TestDeleteClientRole(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2373,7 +2373,7 @@ func TestDeleteClientRole(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -2381,7 +2381,7 @@ func TestDeleteClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2390,15 +2390,15 @@ func TestDeleteClientRole(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "delete client role with invalid role name", + desc: "delete client role with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2410,11 +2410,11 @@ func TestDeleteClientRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RemoveRole", mock.Anything, tc.session, tc.clientID, tc.roleName).Return(tc.svcErr) - err := mgsdk.DeleteClientRole(tc.clientID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RemoveRole", mock.Anything, tc.session, tc.clientID, tc.roleID).Return(tc.svcErr) + err := mgsdk.DeleteClientRole(tc.clientID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RemoveRole", mock.Anything, tc.session, tc.clientID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RemoveRole", mock.Anything, tc.session, tc.clientID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2432,7 +2432,7 @@ func TestAddClientRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} cases := []struct { @@ -2441,7 +2441,7 @@ func TestAddClientRoleActions(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string actions []string svcRes []string svcErr error @@ -2454,7 +2454,7 @@ func TestAddClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: actions, svcRes: actions, svcErr: nil, @@ -2466,7 +2466,7 @@ func TestAddClientRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: actions, authenticateErr: svcerr.ErrAuthentication, response: []string{}, @@ -2477,7 +2477,7 @@ func TestAddClientRoleActions(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: actions, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -2487,7 +2487,7 @@ func TestAddClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, actions: actions, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -2498,17 +2498,17 @@ func TestAddClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, actions: actions, response: []string{}, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "add client role actions with invalid role name", + desc: "add client role actions with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, actions: actions, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -2519,7 +2519,7 @@ func TestAddClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: []string{}, svcErr: nil, response: []string{}, @@ -2533,12 +2533,12 @@ func TestAddClientRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleAddActions", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.actions).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.AddClientRoleActions(tc.clientID, tc.roleName, tc.domainID, tc.actions, tc.token) + svcCall := csvc.On("RoleAddActions", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.actions).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.AddClientRoleActions(tc.clientID, tc.roleID, tc.domainID, tc.actions, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleAddActions", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.actions) + ok := svcCall.Parent.AssertCalled(t, "RoleAddActions", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.actions) assert.True(t, ok) } svcCall.Unset() @@ -2556,7 +2556,7 @@ func TestListClientRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} cases := []struct { @@ -2565,7 +2565,7 @@ func TestListClientRoleActions(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string svcRes []string svcErr error authenticateErr error @@ -2577,7 +2577,7 @@ func TestListClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, svcRes: actions, svcErr: nil, response: actions, @@ -2588,7 +2588,7 @@ func TestListClientRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2597,7 +2597,7 @@ func TestListClientRoleActions(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -2605,7 +2605,7 @@ func TestListClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2614,26 +2614,26 @@ func TestListClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "list client role actions with invalid role name", + desc: "list client role actions with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "list client role actions with empty role name", + desc: "list client role actions with empty role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -2643,12 +2643,12 @@ func TestListClientRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleListActions", mock.Anything, tc.session, tc.clientID, tc.roleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.ClientRoleActions(tc.clientID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RoleListActions", mock.Anything, tc.session, tc.clientID, tc.roleID).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.ClientRoleActions(tc.clientID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleListActions", mock.Anything, tc.session, tc.clientID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleListActions", mock.Anything, tc.session, tc.clientID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2666,7 +2666,7 @@ func TestRemoveClientRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} cases := []struct { @@ -2675,7 +2675,7 @@ func TestRemoveClientRoleActions(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string actions []string svcErr error authenticateErr error @@ -2686,7 +2686,7 @@ func TestRemoveClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: actions, svcErr: nil, err: nil, @@ -2696,7 +2696,7 @@ func TestRemoveClientRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: actions, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), @@ -2706,7 +2706,7 @@ func TestRemoveClientRoleActions(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: actions, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, @@ -2715,7 +2715,7 @@ func TestRemoveClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, actions: actions, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -2725,16 +2725,16 @@ func TestRemoveClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, actions: actions, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove client role actions with invalid role name", + desc: "remove client role actions with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, actions: actions, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -2744,7 +2744,7 @@ func TestRemoveClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, actions: []string{}, svcErr: nil, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingPolicyEntityType), http.StatusBadRequest), @@ -2757,11 +2757,11 @@ func TestRemoveClientRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveActions", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.actions).Return(tc.svcErr) - err := mgsdk.RemoveClientRoleActions(tc.clientID, tc.roleName, tc.domainID, tc.actions, tc.token) + svcCall := csvc.On("RoleRemoveActions", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.actions).Return(tc.svcErr) + err := mgsdk.RemoveClientRoleActions(tc.clientID, tc.roleID, tc.domainID, tc.actions, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveActions", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.actions) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveActions", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.actions) assert.True(t, ok) } svcCall.Unset() @@ -2779,7 +2779,7 @@ func TestRemoveAllClientRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) cases := []struct { desc string @@ -2787,7 +2787,7 @@ func TestRemoveAllClientRoleActions(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -2797,7 +2797,7 @@ func TestRemoveAllClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -2806,7 +2806,7 @@ func TestRemoveAllClientRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2815,7 +2815,7 @@ func TestRemoveAllClientRoleActions(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -2823,7 +2823,7 @@ func TestRemoveAllClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2832,26 +2832,26 @@ func TestRemoveAllClientRoleActions(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove all client role actions with invalid role name", + desc: "remove all client role actions with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "remove all client role actions with empty role name", + desc: "remove all client role actions with empty role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -2861,11 +2861,11 @@ func TestRemoveAllClientRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveAllActions", mock.Anything, tc.session, tc.clientID, tc.roleName).Return(tc.svcErr) - err := mgsdk.RemoveAllClientRoleActions(tc.clientID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RoleRemoveAllActions", mock.Anything, tc.session, tc.clientID, tc.roleID).Return(tc.svcErr) + err := mgsdk.RemoveAllClientRoleActions(tc.clientID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllActions", mock.Anything, tc.session, tc.clientID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllActions", mock.Anything, tc.session, tc.clientID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2883,7 +2883,7 @@ func TestAddClientRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} cases := []struct { @@ -2892,7 +2892,7 @@ func TestAddClientRoleMembers(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string members []string svcRes []string svcErr error @@ -2905,7 +2905,7 @@ func TestAddClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: members, svcRes: members, svcErr: nil, @@ -2917,7 +2917,7 @@ func TestAddClientRoleMembers(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: members, authenticateErr: svcerr.ErrAuthentication, response: []string{}, @@ -2928,7 +2928,7 @@ func TestAddClientRoleMembers(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: members, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -2938,7 +2938,7 @@ func TestAddClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, members: members, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -2949,17 +2949,17 @@ func TestAddClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, members: members, response: []string{}, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "add client role members with invalid role name", + desc: "add client role members with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, members: members, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -2970,7 +2970,7 @@ func TestAddClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: []string{}, svcErr: nil, response: []string{}, @@ -2984,12 +2984,12 @@ func TestAddClientRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleAddMembers", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.members).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.AddClientRoleMembers(tc.clientID, tc.roleName, tc.domainID, tc.members, tc.token) + svcCall := csvc.On("RoleAddMembers", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.members).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.AddClientRoleMembers(tc.clientID, tc.roleID, tc.domainID, tc.members, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleAddMembers", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.members) + ok := svcCall.Parent.AssertCalled(t, "RoleAddMembers", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.members) assert.True(t, ok) } svcCall.Unset() @@ -3007,7 +3007,7 @@ func TestListClientRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} cases := []struct { @@ -3016,7 +3016,7 @@ func TestListClientRoleMembers(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string pageMeta sdk.PageMetadata svcRes roles.MembersPage svcErr error @@ -3033,7 +3033,7 @@ func TestListClientRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, + roleID: roleID, svcRes: roles.MembersPage{ Total: 2, Offset: 0, @@ -3058,7 +3058,7 @@ func TestListClientRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -3071,8 +3071,8 @@ func TestListClientRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, - err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), + roleID: roleID, + err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "list client role members with invalid client id", @@ -3083,9 +3083,9 @@ func TestListClientRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, - svcErr: svcerr.ErrAuthorization, - err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), + roleID: roleID, + svcErr: svcerr.ErrAuthorization, + err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { desc: "list client role members with empty client id", @@ -3096,11 +3096,11 @@ func TestListClientRoleMembers(t *testing.T) { Limit: 5, }, clientID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "list client role members with invalid role name", + desc: "list client role members with invalid role id", token: validToken, domainID: domainID, clientID: clientID, @@ -3108,12 +3108,12 @@ func TestListClientRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: invalid, - svcErr: svcerr.ErrAuthorization, - err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), + roleID: invalid, + svcErr: svcerr.ErrAuthorization, + err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "list client role members with empty role name", + desc: "list client role members with empty role id", token: validToken, domainID: domainID, clientID: clientID, @@ -3121,9 +3121,9 @@ func TestListClientRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: "", - svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + roleID: "", + svcErr: nil, + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -3133,12 +3133,12 @@ func TestListClientRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleListMembers", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.pageMeta.Limit, tc.pageMeta.Offset).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.ClientRoleMembers(tc.clientID, tc.roleName, tc.domainID, tc.pageMeta, tc.token) + svcCall := csvc.On("RoleListMembers", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.pageMeta.Limit, tc.pageMeta.Offset).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.ClientRoleMembers(tc.clientID, tc.roleID, tc.domainID, tc.pageMeta, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleListMembers", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.pageMeta.Limit, tc.pageMeta.Offset) + ok := svcCall.Parent.AssertCalled(t, "RoleListMembers", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.pageMeta.Limit, tc.pageMeta.Offset) assert.True(t, ok) } svcCall.Unset() @@ -3156,7 +3156,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} cases := []struct { @@ -3165,7 +3165,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string members []string svcErr error authenticateErr error @@ -3176,7 +3176,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: members, svcErr: nil, err: nil, @@ -3186,7 +3186,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: members, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), @@ -3196,7 +3196,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: members, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, @@ -3205,7 +3205,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, members: members, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -3215,16 +3215,16 @@ func TestRemoveClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, members: members, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove client role members with invalid role name", + desc: "remove client role members with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, members: members, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -3234,7 +3234,7 @@ func TestRemoveClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, members: []string{}, svcErr: nil, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleMembers), http.StatusBadRequest), @@ -3247,11 +3247,11 @@ func TestRemoveClientRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveMembers", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.members).Return(tc.svcErr) - err := mgsdk.RemoveClientRoleMembers(tc.clientID, tc.roleName, tc.domainID, tc.members, tc.token) + svcCall := csvc.On("RoleRemoveMembers", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.members).Return(tc.svcErr) + err := mgsdk.RemoveClientRoleMembers(tc.clientID, tc.roleID, tc.domainID, tc.members, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveMembers", mock.Anything, tc.session, tc.clientID, tc.roleName, tc.members) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveMembers", mock.Anything, tc.session, tc.clientID, tc.roleID, tc.members) assert.True(t, ok) } svcCall.Unset() @@ -3269,7 +3269,7 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) cases := []struct { desc string @@ -3277,7 +3277,7 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { session smqauthn.Session domainID string clientID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -3287,7 +3287,7 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -3296,7 +3296,7 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { token: invalidToken, domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -3305,7 +3305,7 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { token: "", domainID: domainID, clientID: clientID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -3313,7 +3313,7 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -3322,26 +3322,26 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { token: validToken, domainID: domainID, clientID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove all client role members with invalid role name", + desc: "remove all client role members with invalid role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "remove all client role members with empty role name", + desc: "remove all client role members with empty role id", token: validToken, domainID: domainID, clientID: clientID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -3351,11 +3351,11 @@ func TestRemoveAllClientRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveAllMembers", mock.Anything, tc.session, tc.clientID, tc.roleName).Return(tc.svcErr) - err := mgsdk.RemoveAllClientRoleMembers(tc.clientID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RoleRemoveAllMembers", mock.Anything, tc.session, tc.clientID, tc.roleID).Return(tc.svcErr) + err := mgsdk.RemoveAllClientRoleMembers(tc.clientID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllMembers", mock.Anything, tc.session, tc.clientID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllMembers", mock.Anything, tc.session, tc.clientID, tc.roleID) assert.True(t, ok) } svcCall.Unset() diff --git a/pkg/sdk/domains_test.go b/pkg/sdk/domains_test.go index 03ce8e539e..6ce2f619af 100644 --- a/pkg/sdk/domains_test.go +++ b/pkg/sdk/domains_test.go @@ -1040,7 +1040,6 @@ func TestViewClietRole(t *testing.T) { DomainsURL: ts.URL, } mgsdk := sdk.NewSDK(conf) - role := roles.Role{ ID: testsutil.GenerateUUID(t), Name: roleName, @@ -1054,7 +1053,7 @@ func TestViewClietRole(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string svcRes roles.Role svcErr error authenticateErr error @@ -1065,7 +1064,7 @@ func TestViewClietRole(t *testing.T) { desc: "view domain role successfully", token: validToken, domainID: domainID, - roleName: role.Name, + roleID: role.ID, svcRes: role, svcErr: nil, response: convertRole(role), @@ -1075,7 +1074,7 @@ func TestViewClietRole(t *testing.T) { desc: "view domain role with invalid token", token: invalidToken, domainID: domainID, - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, authenticateErr: svcerr.ErrAuthentication, response: sdk.Role{}, @@ -1085,7 +1084,7 @@ func TestViewClietRole(t *testing.T) { desc: "view domain role with empty token", token: "", domainID: domainID, - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, response: sdk.Role{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -1094,7 +1093,7 @@ func TestViewClietRole(t *testing.T) { desc: "view domain role with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, response: sdk.Role{}, @@ -1104,17 +1103,17 @@ func TestViewClietRole(t *testing.T) { desc: "view domain role with empty domain id", token: validToken, domainID: "", - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, svcErr: nil, response: sdk.Role{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "view domain role with invalid role name", + desc: "view domain role with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, response: sdk.Role{}, @@ -1128,12 +1127,12 @@ func TestViewClietRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RetrieveRole", mock.Anything, tc.session, tc.domainID, tc.roleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.DomainRole(tc.domainID, tc.roleName, tc.token) + svcCall := csvc.On("RetrieveRole", mock.Anything, tc.session, tc.domainID, tc.roleID).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.DomainRole(tc.domainID, tc.roleID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RetrieveRole", mock.Anything, tc.session, tc.domainID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RetrieveRole", mock.Anything, tc.session, tc.domainID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -1151,7 +1150,7 @@ func TestUpdateDomainRole(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) newRoleName := "newTest" userID := testsutil.GenerateUUID(t) createdAt := time.Now().UTC().Add(-time.Hour) @@ -1170,7 +1169,7 @@ func TestUpdateDomainRole(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string newRoleName string svcRes roles.Role svcErr error @@ -1182,7 +1181,7 @@ func TestUpdateDomainRole(t *testing.T) { desc: "update domain role successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: role, svcErr: nil, @@ -1193,7 +1192,7 @@ func TestUpdateDomainRole(t *testing.T) { desc: "update domain role with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, authenticateErr: svcerr.ErrAuthentication, @@ -1204,7 +1203,7 @@ func TestUpdateDomainRole(t *testing.T) { desc: "update domain role with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, response: sdk.Role{}, @@ -1214,7 +1213,7 @@ func TestUpdateDomainRole(t *testing.T) { desc: "update domain role with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, @@ -1225,7 +1224,7 @@ func TestUpdateDomainRole(t *testing.T) { desc: "update domain role with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, svcErr: nil, @@ -1240,12 +1239,12 @@ func TestUpdateDomainRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("UpdateRoleName", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.newRoleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.UpdateDomainRole(tc.domainID, tc.roleName, tc.newRoleName, tc.token) + svcCall := csvc.On("UpdateRoleName", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.newRoleName).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.UpdateDomainRole(tc.domainID, tc.roleID, tc.newRoleName, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "UpdateRoleName", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.newRoleName) + ok := svcCall.Parent.AssertCalled(t, "UpdateRoleName", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.newRoleName) assert.True(t, ok) } svcCall.Unset() @@ -1263,14 +1262,13 @@ func TestDeleteDomainRole(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName - + roleID := testsutil.GenerateUUID(t) cases := []struct { desc string token string session smqauthn.Session domainID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -1279,7 +1277,7 @@ func TestDeleteDomainRole(t *testing.T) { desc: "delete domain role successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -1287,7 +1285,7 @@ func TestDeleteDomainRole(t *testing.T) { desc: "delete domain role with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -1295,14 +1293,14 @@ func TestDeleteDomainRole(t *testing.T) { desc: "delete domain role with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "delete domain role with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -1310,14 +1308,14 @@ func TestDeleteDomainRole(t *testing.T) { desc: "delete domain role with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "delete domain role with invalid role name", + desc: "delete domain role with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -1329,11 +1327,11 @@ func TestDeleteDomainRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RemoveRole", mock.Anything, tc.session, tc.domainID, tc.roleName).Return(tc.svcErr) - err := mgsdk.DeleteDomainRole(tc.domainID, tc.roleName, tc.token) + svcCall := csvc.On("RemoveRole", mock.Anything, tc.session, tc.domainID, tc.roleID).Return(tc.svcErr) + err := mgsdk.DeleteDomainRole(tc.domainID, tc.roleID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RemoveRole", mock.Anything, tc.session, tc.domainID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RemoveRole", mock.Anything, tc.session, tc.domainID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -1351,7 +1349,7 @@ func TestAddDomainRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} cases := []struct { @@ -1359,7 +1357,7 @@ func TestAddDomainRoleActions(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string actions []string svcRes []string svcErr error @@ -1371,7 +1369,7 @@ func TestAddDomainRoleActions(t *testing.T) { desc: "add domain role actions successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, actions: actions, svcRes: actions, svcErr: nil, @@ -1382,7 +1380,7 @@ func TestAddDomainRoleActions(t *testing.T) { desc: "add domain role actions with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, actions: actions, authenticateErr: svcerr.ErrAuthentication, response: []string{}, @@ -1392,7 +1390,7 @@ func TestAddDomainRoleActions(t *testing.T) { desc: "add domain role actions with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, actions: actions, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -1401,7 +1399,7 @@ func TestAddDomainRoleActions(t *testing.T) { desc: "add domain role actions with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, actions: actions, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -1411,16 +1409,16 @@ func TestAddDomainRoleActions(t *testing.T) { desc: "add domain role actions with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, actions: actions, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "add domain role actions with invalid role name", + desc: "add domain role actions with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, actions: actions, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -1430,7 +1428,7 @@ func TestAddDomainRoleActions(t *testing.T) { desc: "add domain role actions with empty actions", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, actions: []string{}, svcErr: nil, response: []string{}, @@ -1444,12 +1442,12 @@ func TestAddDomainRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleAddActions", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.actions).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.AddDomainRoleActions(tc.domainID, tc.roleName, tc.actions, tc.token) + svcCall := csvc.On("RoleAddActions", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.actions).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.AddDomainRoleActions(tc.domainID, tc.roleID, tc.actions, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleAddActions", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.actions) + ok := svcCall.Parent.AssertCalled(t, "RoleAddActions", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.actions) assert.True(t, ok) } svcCall.Unset() @@ -1467,7 +1465,7 @@ func TestListDomainRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} cases := []struct { @@ -1475,7 +1473,7 @@ func TestListDomainRoleActions(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string svcRes []string svcErr error authenticateErr error @@ -1486,7 +1484,7 @@ func TestListDomainRoleActions(t *testing.T) { desc: "list domain role actions successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, svcRes: actions, svcErr: nil, response: actions, @@ -1496,7 +1494,7 @@ func TestListDomainRoleActions(t *testing.T) { desc: "list domain role actions with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -1504,14 +1502,14 @@ func TestListDomainRoleActions(t *testing.T) { desc: "list domain role actions with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "list domain role actions with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -1519,24 +1517,24 @@ func TestListDomainRoleActions(t *testing.T) { desc: "list domain role actions with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "list domain role actions with invalid role name", + desc: "list domain role actions with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "list domain role actions with empty role name", + desc: "list domain role actions with empty role id", token: validToken, domainID: domainID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -1546,12 +1544,12 @@ func TestListDomainRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleListActions", mock.Anything, tc.session, tc.domainID, tc.roleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.DomainRoleActions(tc.domainID, tc.roleName, tc.token) + svcCall := csvc.On("RoleListActions", mock.Anything, tc.session, tc.domainID, tc.roleID).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.DomainRoleActions(tc.domainID, tc.roleID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleListActions", mock.Anything, tc.session, tc.domainID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleListActions", mock.Anything, tc.session, tc.domainID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -1569,7 +1567,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} cases := []struct { @@ -1577,7 +1575,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string actions []string svcErr error authenticateErr error @@ -1587,7 +1585,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { desc: "remove domain role actions successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, actions: actions, svcErr: nil, err: nil, @@ -1596,7 +1594,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { desc: "remove domain role actions with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, actions: actions, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), @@ -1605,7 +1603,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { desc: "remove domain role actions with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, actions: actions, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, @@ -1613,7 +1611,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { desc: "remove domain role actions with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, actions: actions, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -1622,15 +1620,15 @@ func TestRemoveDomainRoleActions(t *testing.T) { desc: "remove domain role actions with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, actions: actions, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "remove domain role actions with invalid role name", + desc: "remove domain role actions with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, actions: actions, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -1639,7 +1637,7 @@ func TestRemoveDomainRoleActions(t *testing.T) { desc: "remove domain role actions with empty actions", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, actions: []string{}, svcErr: nil, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingPolicyEntityType), http.StatusBadRequest), @@ -1652,11 +1650,11 @@ func TestRemoveDomainRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveActions", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.actions).Return(tc.svcErr) - err := mgsdk.RemoveDomainRoleActions(tc.domainID, tc.roleName, tc.actions, tc.token) + svcCall := csvc.On("RoleRemoveActions", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.actions).Return(tc.svcErr) + err := mgsdk.RemoveDomainRoleActions(tc.domainID, tc.roleID, tc.actions, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveActions", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.actions) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveActions", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.actions) assert.True(t, ok) } svcCall.Unset() @@ -1674,14 +1672,14 @@ func TestRemoveAllDomainRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) cases := []struct { desc string token string session smqauthn.Session domainID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -1690,7 +1688,7 @@ func TestRemoveAllDomainRoleActions(t *testing.T) { desc: "remove all domain role actions successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -1698,7 +1696,7 @@ func TestRemoveAllDomainRoleActions(t *testing.T) { desc: "remove all domain role actions with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -1706,14 +1704,14 @@ func TestRemoveAllDomainRoleActions(t *testing.T) { desc: "remove all domain role actions with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "remove all domain role actions with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -1721,24 +1719,24 @@ func TestRemoveAllDomainRoleActions(t *testing.T) { desc: "remove all domain role actions with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "remove all domain role actions with invalid role name", + desc: "remove all domain role actions with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "remove all domain role actions with empty role name", + desc: "remove all domain role actions with empty role id", token: validToken, domainID: domainID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -1748,11 +1746,11 @@ func TestRemoveAllDomainRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveAllActions", mock.Anything, tc.session, tc.domainID, tc.roleName).Return(tc.svcErr) - err := mgsdk.RemoveAllDomainRoleActions(tc.domainID, tc.roleName, tc.token) + svcCall := csvc.On("RoleRemoveAllActions", mock.Anything, tc.session, tc.domainID, tc.roleID).Return(tc.svcErr) + err := mgsdk.RemoveAllDomainRoleActions(tc.domainID, tc.roleID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllActions", mock.Anything, tc.session, tc.domainID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllActions", mock.Anything, tc.session, tc.domainID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -1770,7 +1768,7 @@ func TestAddDomainRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} cases := []struct { @@ -1778,7 +1776,7 @@ func TestAddDomainRoleMembers(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string members []string svcRes []string svcErr error @@ -1790,7 +1788,7 @@ func TestAddDomainRoleMembers(t *testing.T) { desc: "add domain role members successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, members: members, svcRes: members, svcErr: nil, @@ -1801,7 +1799,7 @@ func TestAddDomainRoleMembers(t *testing.T) { desc: "add domain role members with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, members: members, authenticateErr: svcerr.ErrAuthentication, response: []string{}, @@ -1811,7 +1809,7 @@ func TestAddDomainRoleMembers(t *testing.T) { desc: "add domain role members with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, members: members, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -1820,7 +1818,7 @@ func TestAddDomainRoleMembers(t *testing.T) { desc: "add domain role members with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, members: members, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -1830,16 +1828,16 @@ func TestAddDomainRoleMembers(t *testing.T) { desc: "add domain role members with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, members: members, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "add domain role members with invalid role name", + desc: "add domain role members with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, members: members, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -1849,7 +1847,7 @@ func TestAddDomainRoleMembers(t *testing.T) { desc: "add domain role members with empty members", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, members: []string{}, svcErr: nil, response: []string{}, @@ -1863,12 +1861,12 @@ func TestAddDomainRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleAddMembers", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.members).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.AddDomainRoleMembers(tc.domainID, tc.roleName, tc.members, tc.token) + svcCall := csvc.On("RoleAddMembers", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.members).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.AddDomainRoleMembers(tc.domainID, tc.roleID, tc.members, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleAddMembers", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.members) + ok := svcCall.Parent.AssertCalled(t, "RoleAddMembers", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.members) assert.True(t, ok) } svcCall.Unset() @@ -1886,7 +1884,7 @@ func TestListDomainRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} cases := []struct { @@ -1894,7 +1892,7 @@ func TestListDomainRoleMembers(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string pageMeta sdk.PageMetadata svcRes roles.MembersPage svcErr error @@ -1910,7 +1908,7 @@ func TestListDomainRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, + roleID: roleID, svcRes: roles.MembersPage{ Total: 2, Offset: 0, @@ -1934,7 +1932,7 @@ func TestListDomainRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -1946,8 +1944,8 @@ func TestListDomainRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, - err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), + roleID: roleID, + err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "list domain role members with invalid domain id", @@ -1957,9 +1955,9 @@ func TestListDomainRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, - svcErr: svcerr.ErrAuthorization, - err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), + roleID: roleID, + svcErr: svcerr.ErrAuthorization, + err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { desc: "list domain role members with empty domain id", @@ -1969,32 +1967,32 @@ func TestListDomainRoleMembers(t *testing.T) { Limit: 5, }, domainID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "list domain role members with invalid role name", + desc: "list domain role members with invalid role id", token: validToken, domainID: domainID, pageMeta: sdk.PageMetadata{ Offset: 0, Limit: 5, }, - roleName: invalid, - svcErr: svcerr.ErrAuthorization, - err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), + roleID: invalid, + svcErr: svcerr.ErrAuthorization, + err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "list domain role members with empty role name", + desc: "list domain role members with empty role id", token: validToken, domainID: domainID, pageMeta: sdk.PageMetadata{ Offset: 0, Limit: 5, }, - roleName: "", - svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + roleID: "", + svcErr: nil, + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -2004,12 +2002,12 @@ func TestListDomainRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleListMembers", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.pageMeta.Limit, tc.pageMeta.Offset).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.DomainRoleMembers(tc.domainID, tc.roleName, tc.pageMeta, tc.token) + svcCall := csvc.On("RoleListMembers", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.pageMeta.Limit, tc.pageMeta.Offset).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.DomainRoleMembers(tc.domainID, tc.roleID, tc.pageMeta, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleListMembers", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.pageMeta.Limit, tc.pageMeta.Offset) + ok := svcCall.Parent.AssertCalled(t, "RoleListMembers", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.pageMeta.Limit, tc.pageMeta.Offset) assert.True(t, ok) } svcCall.Unset() @@ -2027,7 +2025,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} cases := []struct { @@ -2035,7 +2033,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { token string session smqauthn.Session domainID string - roleName string + roleID string members []string svcErr error authenticateErr error @@ -2045,7 +2043,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { desc: "remove domain role members successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, members: members, svcErr: nil, err: nil, @@ -2054,7 +2052,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { desc: "remove domain role members with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, members: members, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), @@ -2063,7 +2061,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { desc: "remove domain role members with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, members: members, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, @@ -2071,7 +2069,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { desc: "remove domain role members with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, members: members, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -2080,15 +2078,15 @@ func TestRemoveDomainRoleMembers(t *testing.T) { desc: "remove domain role members with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, members: members, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "remove domain role members with invalid role name", + desc: "remove domain role members with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, members: members, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -2097,7 +2095,7 @@ func TestRemoveDomainRoleMembers(t *testing.T) { desc: "remove domain role members with empty members", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, members: []string{}, svcErr: nil, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleMembers), http.StatusBadRequest), @@ -2110,11 +2108,11 @@ func TestRemoveDomainRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveMembers", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.members).Return(tc.svcErr) - err := mgsdk.RemoveDomainRoleMembers(tc.domainID, tc.roleName, tc.members, tc.token) + svcCall := csvc.On("RoleRemoveMembers", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.members).Return(tc.svcErr) + err := mgsdk.RemoveDomainRoleMembers(tc.domainID, tc.roleID, tc.members, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveMembers", mock.Anything, tc.session, tc.domainID, tc.roleName, tc.members) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveMembers", mock.Anything, tc.session, tc.domainID, tc.roleID, tc.members) assert.True(t, ok) } svcCall.Unset() @@ -2132,14 +2130,14 @@ func TestRemoveAllDomainRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) cases := []struct { desc string token string session smqauthn.Session domainID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -2148,7 +2146,7 @@ func TestRemoveAllDomainRoleMembers(t *testing.T) { desc: "remove all domain role members successfully", token: validToken, domainID: domainID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -2156,7 +2154,7 @@ func TestRemoveAllDomainRoleMembers(t *testing.T) { desc: "remove all domain role members with invalid token", token: invalidToken, domainID: domainID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2164,14 +2162,14 @@ func TestRemoveAllDomainRoleMembers(t *testing.T) { desc: "remove all domain role members with empty token", token: "", domainID: domainID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "remove all domain role members with invalid domain id", token: validToken, domainID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2179,24 +2177,24 @@ func TestRemoveAllDomainRoleMembers(t *testing.T) { desc: "remove all domain role members with empty domain id", token: validToken, domainID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrMissingDomainID, http.StatusBadRequest), }, { - desc: "remove all domain role members with invalid role name", + desc: "remove all domain role members with invalid role id", token: validToken, domainID: domainID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "remove all domain role members with empty role name", + desc: "remove all domain role members with empty role id", token: validToken, domainID: domainID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -2206,11 +2204,11 @@ func TestRemoveAllDomainRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: tc.domainID + "_" + validID, UserID: validID, DomainID: tc.domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveAllMembers", mock.Anything, tc.session, tc.domainID, tc.roleName).Return(tc.svcErr) - err := mgsdk.RemoveAllDomainRoleMembers(tc.domainID, tc.roleName, tc.token) + svcCall := csvc.On("RoleRemoveAllMembers", mock.Anything, tc.session, tc.domainID, tc.roleID).Return(tc.svcErr) + err := mgsdk.RemoveAllDomainRoleMembers(tc.domainID, tc.roleID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllMembers", mock.Anything, tc.session, tc.domainID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllMembers", mock.Anything, tc.session, tc.domainID, tc.roleID) assert.True(t, ok) } svcCall.Unset() diff --git a/pkg/sdk/groups_test.go b/pkg/sdk/groups_test.go index b80964ecc6..05fcb84bc2 100644 --- a/pkg/sdk/groups_test.go +++ b/pkg/sdk/groups_test.go @@ -2265,7 +2265,6 @@ func TestViewGroupRole(t *testing.T) { GroupsURL: ts.URL, } mgsdk := sdk.NewSDK(conf) - groupID := testsutil.GenerateUUID(t) role := roles.Role{ ID: testsutil.GenerateUUID(t), @@ -2281,7 +2280,7 @@ func TestViewGroupRole(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string svcRes roles.Role svcErr error authenticateErr error @@ -2293,7 +2292,7 @@ func TestViewGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: role.Name, + roleID: role.ID, svcRes: role, svcErr: nil, response: convertRole(role), @@ -2304,7 +2303,7 @@ func TestViewGroupRole(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, authenticateErr: svcerr.ErrAuthentication, response: sdk.Role{}, @@ -2315,7 +2314,7 @@ func TestViewGroupRole(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, response: sdk.Role{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -2325,7 +2324,7 @@ func TestViewGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, response: sdk.Role{}, @@ -2336,18 +2335,18 @@ func TestViewGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: role.Name, + roleID: role.ID, svcRes: roles.Role{}, svcErr: nil, response: sdk.Role{}, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "view group role with invalid role name", + desc: "view group role with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, response: sdk.Role{}, @@ -2361,12 +2360,12 @@ func TestViewGroupRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RetrieveRole", mock.Anything, tc.session, tc.groupID, tc.roleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.GroupRole(tc.groupID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RetrieveRole", mock.Anything, tc.session, tc.groupID, tc.roleID).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.GroupRole(tc.groupID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RetrieveRole", mock.Anything, tc.session, tc.groupID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RetrieveRole", mock.Anything, tc.session, tc.groupID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2385,7 +2384,7 @@ func TestUpdateGroupRole(t *testing.T) { mgsdk := sdk.NewSDK(conf) groupID := testsutil.GenerateUUID(t) - roleName := roleName + roleID := testsutil.GenerateUUID(t) newRoleName := "newTest" userID := testsutil.GenerateUUID(t) createdAt := time.Now().UTC().Add(-time.Hour) @@ -2405,7 +2404,7 @@ func TestUpdateGroupRole(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string newRoleName string svcRes roles.Role svcErr error @@ -2418,7 +2417,7 @@ func TestUpdateGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: role, svcErr: nil, @@ -2430,7 +2429,7 @@ func TestUpdateGroupRole(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, authenticateErr: svcerr.ErrAuthentication, @@ -2442,7 +2441,7 @@ func TestUpdateGroupRole(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, response: sdk.Role{}, @@ -2453,7 +2452,7 @@ func TestUpdateGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, svcErr: svcerr.ErrAuthorization, @@ -2465,7 +2464,7 @@ func TestUpdateGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, newRoleName: newRoleName, svcRes: roles.Role{}, svcErr: nil, @@ -2480,12 +2479,12 @@ func TestUpdateGroupRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("UpdateRoleName", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.newRoleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.UpdateGroupRole(tc.groupID, tc.roleName, tc.newRoleName, tc.domainID, tc.token) + svcCall := csvc.On("UpdateRoleName", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.newRoleName).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.UpdateGroupRole(tc.groupID, tc.roleID, tc.newRoleName, tc.domainID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "UpdateRoleName", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.newRoleName) + ok := svcCall.Parent.AssertCalled(t, "UpdateRoleName", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.newRoleName) assert.True(t, ok) } svcCall.Unset() @@ -2503,7 +2502,7 @@ func TestDeleteGroupRole(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) groupID := testsutil.GenerateUUID(t) cases := []struct { @@ -2512,7 +2511,7 @@ func TestDeleteGroupRole(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -2522,7 +2521,7 @@ func TestDeleteGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -2531,7 +2530,7 @@ func TestDeleteGroupRole(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2540,7 +2539,7 @@ func TestDeleteGroupRole(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -2548,7 +2547,7 @@ func TestDeleteGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2557,15 +2556,15 @@ func TestDeleteGroupRole(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "delete group role with invalid role name", + desc: "delete group role with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2577,11 +2576,11 @@ func TestDeleteGroupRole(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RemoveRole", mock.Anything, tc.session, tc.groupID, tc.roleName).Return(tc.svcErr) - err := mgsdk.DeleteGroupRole(tc.groupID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RemoveRole", mock.Anything, tc.session, tc.groupID, tc.roleID).Return(tc.svcErr) + err := mgsdk.DeleteGroupRole(tc.groupID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RemoveRole", mock.Anything, tc.session, tc.groupID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RemoveRole", mock.Anything, tc.session, tc.groupID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2599,7 +2598,7 @@ func TestAddGroupRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} groupID := testsutil.GenerateUUID(t) @@ -2609,7 +2608,7 @@ func TestAddGroupRoleActions(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string actions []string svcRes []string svcErr error @@ -2622,7 +2621,7 @@ func TestAddGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: actions, svcRes: actions, svcErr: nil, @@ -2634,7 +2633,7 @@ func TestAddGroupRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: actions, authenticateErr: svcerr.ErrAuthentication, response: []string{}, @@ -2645,7 +2644,7 @@ func TestAddGroupRoleActions(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: actions, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -2655,7 +2654,7 @@ func TestAddGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, actions: actions, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -2666,17 +2665,17 @@ func TestAddGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, actions: actions, response: []string{}, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "add group role actions with invalid role name", + desc: "add group role actions with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, actions: actions, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -2687,7 +2686,7 @@ func TestAddGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: []string{}, svcErr: nil, response: []string{}, @@ -2701,12 +2700,12 @@ func TestAddGroupRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleAddActions", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.actions).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.AddGroupRoleActions(tc.groupID, tc.roleName, tc.domainID, tc.actions, tc.token) + svcCall := csvc.On("RoleAddActions", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.actions).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.AddGroupRoleActions(tc.groupID, tc.roleID, tc.domainID, tc.actions, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleAddActions", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.actions) + ok := svcCall.Parent.AssertCalled(t, "RoleAddActions", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.actions) assert.True(t, ok) } svcCall.Unset() @@ -2724,7 +2723,7 @@ func TestListGroupRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} groupID := testsutil.GenerateUUID(t) @@ -2734,7 +2733,7 @@ func TestListGroupRoleActions(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string svcRes []string svcErr error authenticateErr error @@ -2746,7 +2745,7 @@ func TestListGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, svcRes: actions, svcErr: nil, response: actions, @@ -2757,7 +2756,7 @@ func TestListGroupRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2766,7 +2765,7 @@ func TestListGroupRoleActions(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -2774,7 +2773,7 @@ func TestListGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -2783,26 +2782,26 @@ func TestListGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "list group role actions with invalid role name", + desc: "list group role actions with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "list group role actions with empty role name", + desc: "list group role actions with empty role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -2812,12 +2811,12 @@ func TestListGroupRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleListActions", mock.Anything, tc.session, tc.groupID, tc.roleName).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.GroupRoleActions(tc.groupID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RoleListActions", mock.Anything, tc.session, tc.groupID, tc.roleID).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.GroupRoleActions(tc.groupID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleListActions", mock.Anything, tc.session, tc.groupID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleListActions", mock.Anything, tc.session, tc.groupID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -2835,7 +2834,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) actions := []string{"create", "update"} groupID := testsutil.GenerateUUID(t) @@ -2845,7 +2844,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string actions []string svcErr error authenticateErr error @@ -2856,7 +2855,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: actions, svcErr: nil, err: nil, @@ -2866,7 +2865,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: actions, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), @@ -2876,7 +2875,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: actions, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, @@ -2885,7 +2884,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, actions: actions, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -2895,16 +2894,16 @@ func TestRemoveGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, actions: actions, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove group role actions with invalid role name", + desc: "remove group role actions with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, actions: actions, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -2914,7 +2913,7 @@ func TestRemoveGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, actions: []string{}, svcErr: nil, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingPolicyEntityType), http.StatusBadRequest), @@ -2927,11 +2926,11 @@ func TestRemoveGroupRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveActions", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.actions).Return(tc.svcErr) - err := mgsdk.RemoveGroupRoleActions(tc.groupID, tc.roleName, tc.domainID, tc.actions, tc.token) + svcCall := csvc.On("RoleRemoveActions", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.actions).Return(tc.svcErr) + err := mgsdk.RemoveGroupRoleActions(tc.groupID, tc.roleID, tc.domainID, tc.actions, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveActions", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.actions) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveActions", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.actions) assert.True(t, ok) } svcCall.Unset() @@ -2949,7 +2948,7 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) groupID := testsutil.GenerateUUID(t) cases := []struct { @@ -2958,7 +2957,7 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -2968,7 +2967,7 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -2977,7 +2976,7 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -2986,7 +2985,7 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -2994,7 +2993,7 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -3003,26 +3002,26 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove all group role actions with invalid role name", + desc: "remove all group role actions with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "remove all group role actions with empty role name", + desc: "remove all group role actions with empty role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -3032,11 +3031,11 @@ func TestRemoveAllGroupRoleActions(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveAllActions", mock.Anything, tc.session, tc.groupID, tc.roleName).Return(tc.svcErr) - err := mgsdk.RemoveAllGroupRoleActions(tc.groupID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RoleRemoveAllActions", mock.Anything, tc.session, tc.groupID, tc.roleID).Return(tc.svcErr) + err := mgsdk.RemoveAllGroupRoleActions(tc.groupID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllActions", mock.Anything, tc.session, tc.groupID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllActions", mock.Anything, tc.session, tc.groupID, tc.roleID) assert.True(t, ok) } svcCall.Unset() @@ -3054,7 +3053,7 @@ func TestAddGroupRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} groupID := testsutil.GenerateUUID(t) @@ -3064,7 +3063,7 @@ func TestAddGroupRoleMembers(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string members []string svcRes []string svcErr error @@ -3077,7 +3076,7 @@ func TestAddGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: members, svcRes: members, svcErr: nil, @@ -3089,7 +3088,7 @@ func TestAddGroupRoleMembers(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: members, authenticateErr: svcerr.ErrAuthentication, response: []string{}, @@ -3100,7 +3099,7 @@ func TestAddGroupRoleMembers(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: members, response: []string{}, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), @@ -3110,7 +3109,7 @@ func TestAddGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, members: members, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -3121,17 +3120,17 @@ func TestAddGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, members: members, response: []string{}, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "add group role members with invalid role name", + desc: "add group role members with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, members: members, svcErr: svcerr.ErrAuthorization, response: []string{}, @@ -3142,7 +3141,7 @@ func TestAddGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: []string{}, svcErr: nil, response: []string{}, @@ -3156,12 +3155,12 @@ func TestAddGroupRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleAddMembers", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.members).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.AddGroupRoleMembers(tc.groupID, tc.roleName, tc.domainID, tc.members, tc.token) + svcCall := csvc.On("RoleAddMembers", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.members).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.AddGroupRoleMembers(tc.groupID, tc.roleID, tc.domainID, tc.members, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleAddMembers", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.members) + ok := svcCall.Parent.AssertCalled(t, "RoleAddMembers", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.members) assert.True(t, ok) } svcCall.Unset() @@ -3179,7 +3178,7 @@ func TestListGroupRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} groupID := testsutil.GenerateUUID(t) @@ -3189,7 +3188,7 @@ func TestListGroupRoleMembers(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string pageMeta sdk.PageMetadata svcRes roles.MembersPage svcErr error @@ -3206,7 +3205,7 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, + roleID: roleID, svcRes: roles.MembersPage{ Total: 2, Offset: 0, @@ -3231,7 +3230,7 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -3244,8 +3243,8 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, - err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), + roleID: roleID, + err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { desc: "list group role members with invalid group id", @@ -3256,9 +3255,9 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: roleName, - svcErr: svcerr.ErrAuthorization, - err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), + roleID: roleID, + svcErr: svcerr.ErrAuthorization, + err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { desc: "list group role members with empty group id", @@ -3268,12 +3267,12 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - groupID: "", - roleName: roleName, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), + groupID: "", + roleID: roleID, + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "list group role members with invalid role name", + desc: "list group role members with invalid role id", token: validToken, domainID: domainID, groupID: groupID, @@ -3281,12 +3280,12 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: invalid, - svcErr: svcerr.ErrAuthorization, - err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), + roleID: invalid, + svcErr: svcerr.ErrAuthorization, + err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "list group role members with empty role name", + desc: "list group role members with empty role id", token: validToken, domainID: domainID, groupID: groupID, @@ -3294,9 +3293,9 @@ func TestListGroupRoleMembers(t *testing.T) { Offset: 0, Limit: 5, }, - roleName: "", - svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + roleID: "", + svcErr: nil, + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -3306,12 +3305,12 @@ func TestListGroupRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleListMembers", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.pageMeta.Limit, tc.pageMeta.Offset).Return(tc.svcRes, tc.svcErr) - resp, err := mgsdk.GroupRoleMembers(tc.groupID, tc.roleName, tc.domainID, tc.pageMeta, tc.token) + svcCall := csvc.On("RoleListMembers", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.pageMeta.Limit, tc.pageMeta.Offset).Return(tc.svcRes, tc.svcErr) + resp, err := mgsdk.GroupRoleMembers(tc.groupID, tc.roleID, tc.domainID, tc.pageMeta, tc.token) assert.Equal(t, tc.err, err) assert.Equal(t, tc.response, resp) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleListMembers", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.pageMeta.Limit, tc.pageMeta.Offset) + ok := svcCall.Parent.AssertCalled(t, "RoleListMembers", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.pageMeta.Limit, tc.pageMeta.Offset) assert.True(t, ok) } svcCall.Unset() @@ -3329,7 +3328,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) members := []string{"user1", "user2"} groupID := testsutil.GenerateUUID(t) @@ -3339,7 +3338,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string members []string svcErr error authenticateErr error @@ -3350,7 +3349,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: members, svcErr: nil, err: nil, @@ -3360,7 +3359,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: members, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), @@ -3370,7 +3369,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: members, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, @@ -3379,7 +3378,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, members: members, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -3389,16 +3388,16 @@ func TestRemoveGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, members: members, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove group role members with invalid role name", + desc: "remove group role members with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, members: members, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), @@ -3408,7 +3407,7 @@ func TestRemoveGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, members: []string{}, svcErr: nil, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleMembers), http.StatusBadRequest), @@ -3421,11 +3420,11 @@ func TestRemoveGroupRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveMembers", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.members).Return(tc.svcErr) - err := mgsdk.RemoveGroupRoleMembers(tc.groupID, tc.roleName, tc.domainID, tc.members, tc.token) + svcCall := csvc.On("RoleRemoveMembers", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.members).Return(tc.svcErr) + err := mgsdk.RemoveGroupRoleMembers(tc.groupID, tc.roleID, tc.domainID, tc.members, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveMembers", mock.Anything, tc.session, tc.groupID, tc.roleName, tc.members) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveMembers", mock.Anything, tc.session, tc.groupID, tc.roleID, tc.members) assert.True(t, ok) } svcCall.Unset() @@ -3443,7 +3442,7 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { } mgsdk := sdk.NewSDK(conf) - roleName := roleName + roleID := testsutil.GenerateUUID(t) groupID := testsutil.GenerateUUID(t) cases := []struct { @@ -3452,7 +3451,7 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { session smqauthn.Session domainID string groupID string - roleName string + roleID string svcErr error authenticateErr error err errors.SDKError @@ -3462,7 +3461,7 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, svcErr: nil, err: nil, }, @@ -3471,7 +3470,7 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { token: invalidToken, domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, authenticateErr: svcerr.ErrAuthentication, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthentication, http.StatusUnauthorized), }, @@ -3480,7 +3479,7 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { token: "", domainID: domainID, groupID: groupID, - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(apiutil.ErrBearerToken, http.StatusUnauthorized), }, { @@ -3488,7 +3487,7 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: testsutil.GenerateUUID(t), - roleName: roleName, + roleID: roleID, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, @@ -3497,26 +3496,26 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { token: validToken, domainID: domainID, groupID: "", - roleName: roleName, + roleID: roleID, err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingID), http.StatusBadRequest), }, { - desc: "remove all group role members with invalid role name", + desc: "remove all group role members with invalid role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: invalid, + roleID: invalid, svcErr: svcerr.ErrAuthorization, err: errors.NewSDKErrorWithStatus(svcerr.ErrAuthorization, http.StatusForbidden), }, { - desc: "remove all group role members with empty role name", + desc: "remove all group role members with empty role id", token: validToken, domainID: domainID, groupID: groupID, - roleName: "", + roleID: "", svcErr: nil, - err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleName), http.StatusBadRequest), + err: errors.NewSDKErrorWithStatus(errors.Wrap(apiutil.ErrValidation, apiutil.ErrMissingRoleID), http.StatusBadRequest), }, } @@ -3526,11 +3525,11 @@ func TestRemoveAllGroupRoleMembers(t *testing.T) { tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID} } authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr) - svcCall := csvc.On("RoleRemoveAllMembers", mock.Anything, tc.session, tc.groupID, tc.roleName).Return(tc.svcErr) - err := mgsdk.RemoveAllGroupRoleMembers(tc.groupID, tc.roleName, tc.domainID, tc.token) + svcCall := csvc.On("RoleRemoveAllMembers", mock.Anything, tc.session, tc.groupID, tc.roleID).Return(tc.svcErr) + err := mgsdk.RemoveAllGroupRoleMembers(tc.groupID, tc.roleID, tc.domainID, tc.token) assert.Equal(t, tc.err, err) if tc.err == nil { - ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllMembers", mock.Anything, tc.session, tc.groupID, tc.roleName) + ok := svcCall.Parent.AssertCalled(t, "RoleRemoveAllMembers", mock.Anything, tc.session, tc.groupID, tc.roleID) assert.True(t, ok) } svcCall.Unset() diff --git a/pkg/sdk/setup_test.go b/pkg/sdk/setup_test.go index b5bfef294d..33f858706b 100644 --- a/pkg/sdk/setup_test.go +++ b/pkg/sdk/setup_test.go @@ -34,7 +34,7 @@ const ( invalid = "invalid" wrongID = "wrongID" defPermission = "read_permission" - roleID = "roleID" + roleName = "roleName" ) var (