MSP-8974 add download flow test
This commit is contained in:
1 parent
2f29af5e76
commit
06acaba5b3
4 files changed
+289
-35
No files matched your search
+5
-30
@@ -4,19 +4,17 @@ import (
|
||||
"context"
|
||||
"isp-admin-service/domain"
|
||||
"isp-admin-service/entity"
|
||||
"slices"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/http/httpcli"
|
||||
)
|
||||
|
||||
const (
|
||||
getUserById = "admin/user/get_by_id"
|
||||
getAllLogs = "admin/log/all"
|
||||
getAllSessions = "admin/session/all"
|
||||
getAllUsers = "admin/user/get_users"
|
||||
getAllRoles = "admin/role/all"
|
||||
getPermissions = "admin/user/get_permissions"
|
||||
getAllLogs = "/admin/log/all"
|
||||
getAllSessions = "/admin/session/all"
|
||||
getAllUsers = "/admin/user/get_users"
|
||||
getAllRoles = "/admin/role/all"
|
||||
getPermissions = "/admin/user/get_permissions"
|
||||
)
|
||||
|
||||
type ReqGetById struct {
|
||||
@@ -35,29 +33,6 @@ func NewAdmin(cli *httpcli.Client) Admin {
|
||||
return Admin{cli: cli}
|
||||
}
|
||||
|
||||
func (r Admin) GetRoleNamesByIds(ctx context.Context, roleIds []int) ([]string, error) {
|
||||
if len(roleIds) == 0 {
|
||||
return []string{}, nil
|
||||
}
|
||||
resp := make([]entity.Role, 0)
|
||||
err := r.cli.Post(getAllRoles).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
DoWithoutResponse(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "http client request %s", getAllRoles)
|
||||
}
|
||||
|
||||
roleNames := make([]string, 0)
|
||||
for _, role := range resp {
|
||||
if slices.Contains(roleIds, role.Id) {
|
||||
roleNames = append(roleNames, role.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return roleNames, nil
|
||||
}
|
||||
|
||||
func (r Admin) GetAudit(ctx context.Context, req domain.AuditDownloadRequest) (*entity.AuditResponse, error) {
|
||||
var response entity.AuditResponse
|
||||
|
||||
|
||||
Reference in new issue
Block a user