Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
NOISSUE - Improve tests in users service (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: felix.gateru <[email protected]>
  • Loading branch information
felixgateru authored Jan 18, 2024
1 parent e7129fe commit d7cd911
Show file tree
Hide file tree
Showing 8 changed files with 6,313 additions and 847 deletions.
18 changes: 0 additions & 18 deletions api/openapi/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1458,15 +1458,6 @@ components:
required: true
example: bb7edb32-2eac-4aad-aebe-ed96fe073879

Visibility:
name: visibility
description: The visibility specifier when listing users. Either all, shared or mine.
in: path
schema:
type: string
required: true
example: all

UserName:
name: name
description: User's name.
Expand Down Expand Up @@ -1505,15 +1496,6 @@ components:
required: false
example: bb7edb32-2eac-4aad-aebe-ed96fe073879

UserVisibility:
name: visibility
description: visibility to list either users I own or users that are shared with me or both users I own and shared with me
in: query
schema:
type: string
required: false
example: shared

Status:
name: status
description: User account status.
Expand Down
28 changes: 2 additions & 26 deletions users/api/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func decodeViewProfile(_ context.Context, r *http.Request) (interface{}, error)
}

func decodeListClients(_ context.Context, r *http.Request) (interface{}, error) {
var sharedID, ownerID string
s, err := apiutil.ReadStringQuery(r, api.StatusKey, api.DefClientStatus)
if err != nil {
return nil, errors.Wrap(apiutil.ErrValidation, err)
Expand Down Expand Up @@ -222,10 +221,6 @@ func decodeListClients(_ context.Context, r *http.Request) (interface{}, error)
if err != nil {
return nil, err
}
visibility, err := apiutil.ReadStringQuery(r, api.VisibilityKey, "")
if err != nil {
return nil, errors.Wrap(apiutil.ErrValidation, err)
}
order, err := apiutil.ReadStringQuery(r, api.OrderKey, api.DefOrder)
if err != nil {
return nil, errors.Wrap(apiutil.ErrValidation, err)
Expand All @@ -234,18 +229,6 @@ func decodeListClients(_ context.Context, r *http.Request) (interface{}, error)
if err != nil {
return nil, errors.Wrap(apiutil.ErrValidation, err)
}
switch visibility {
case api.MyVisibility:
ownerID = api.MyVisibility
case api.SharedVisibility:
sharedID = api.MyVisibility
case api.AllVisibility:
sharedID = api.MyVisibility
ownerID = api.MyVisibility
}
if oid != "" {
ownerID = oid
}
st, err := mgclients.ToStatus(s)
if err != nil {
return nil, errors.Wrap(apiutil.ErrValidation, err)
Expand All @@ -259,8 +242,7 @@ func decodeListClients(_ context.Context, r *http.Request) (interface{}, error)
name: n,
identity: i,
tag: t,
sharedBy: sharedID,
owner: ownerID,
owner: oid,
order: order,
dir: dir,
}
Expand Down Expand Up @@ -473,13 +455,7 @@ func decodeListMembersByDomain(_ context.Context, r *http.Request) (interface{},
if err != nil {
return nil, err
}
// For domains default permission in membership, In "queryPageParams" default is view,
// so overwriting the permission given by queryPageParams function with default membership permission.
p, err := apiutil.ReadStringQuery(r, api.PermissionKey, auth.MembershipPermission)
if err != nil {
return mgclients.Page{}, errors.Wrap(apiutil.ErrValidation, err)
}
page.Permission = p

req := listMembersByObjectReq{
token: apiutil.ExtractBearerToken(r),
Page: page,
Expand Down
Loading

0 comments on commit d7cd911

Please sign in to comment.