Compare commits

..
4 Commits
Author SHA1 Message Date
riabovvo 63a47ee7b5 update Dockerfiles 2026-11-25 12:13:21 +03:00
Тимофей Чащин cecbda3e43 Merge branch 'MSP-9044' into 'dev'
MSP-9044 filter with app group for download flow

See merge request isp/isp-admin-service!7
2026-11-23 12:07:06 +00:00
chashintv 2cea7a516c MSP-9044 filter with app group for download flow 2026-11-23 14:57:33 +03:00
Тимофей Чащин e544074dbf Merge branch 'MSP-8974' into 'dev'
Resolve MSP-8974

See merge request isp/isp-admin-service!6
2026-11-23 10:34:38 +00:00
7 changed files with 48 additions and 8 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.26-alpine as builder FROM golang:1.27-alpine as builder
WORKDIR /build WORKDIR /build
ARG version ARG version
ENV version_env=$version ENV version_env=$version
+1 -1
View File
@@ -1,5 +1,5 @@
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.24 git RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.27 git
WORKDIR /build WORKDIR /build
ARG version ARG version
ENV version_env=$version ENV version_env=$version
+3 -3
View File
@@ -13,7 +13,7 @@ type DownloadService interface {
DownloadUsers(ctx context.Context, req domain.UsersPageRequest, w http.ResponseWriter) error DownloadUsers(ctx context.Context, req domain.UsersPageRequest, w http.ResponseWriter) error
DownloadSessions(ctx context.Context, req domain.SessionPageRequest, w http.ResponseWriter) error DownloadSessions(ctx context.Context, req domain.SessionPageRequest, w http.ResponseWriter) error
DownloadAudit(ctx context.Context, req domain.AuditPageRequest, w http.ResponseWriter) error DownloadAudit(ctx context.Context, req domain.AuditPageRequest, w http.ResponseWriter) error
DownloadRoles(ctx context.Context, w http.ResponseWriter) error DownloadRoles(ctx context.Context, req domain.RoleAllRequest, w http.ResponseWriter) error
} }
type Download struct { type Download struct {
@@ -92,8 +92,8 @@ func (c Download) Audit(ctx context.Context, req domain.AuditPageRequest, w http
// @Success 200 // @Success 200
// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```" // @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```"
// @Router /role/download [POST] // @Router /role/download [POST]
func (c Download) Roles(ctx context.Context, w http.ResponseWriter) error { func (c Download) Roles(ctx context.Context, req domain.RoleAllRequest, w http.ResponseWriter) error {
err := c.service.DownloadRoles(ctx, w) err := c.service.DownloadRoles(ctx, req, w)
if err != nil { if err != nil {
return errors.WithMessage(err, "download roles") return errors.WithMessage(err, "download roles")
} }
+5
View File
@@ -2353,6 +2353,11 @@
"limit" "limit"
], ],
"properties": { "properties": {
"applicationGroup": {
"description": "Фильтр по группе приложений",
"type": "string",
"minLength": 1
},
"limit": { "limit": {
"description": "Максимальное количество записей", "description": "Максимальное количество записей",
"type": "integer" "type": "integer"
+1
View File
@@ -33,6 +33,7 @@ type UserQuery struct {
type UsersPageRequest struct { type UsersPageRequest struct {
LimitOffsetParams LimitOffsetParams
RoleAllRequest
Order *OrderParams // Параметры сортировки Order *OrderParams // Параметры сортировки
Query *UserQuery // Параметры выборки Query *UserQuery // Параметры выборки
+3 -3
View File
@@ -178,7 +178,7 @@ func (s Download) DownloadUsers(ctx context.Context, req domain.UsersPageRequest
return errors.WithMessage(err, "get users") return errors.WithMessage(err, "get users")
} }
roles, err := s.roleService.All(ctx, domain.RoleAllRequest{}) roles, err := s.roleService.All(ctx, req.RoleAllRequest)
if err != nil { if err != nil {
return errors.WithMessage(err, "get roles") return errors.WithMessage(err, "get roles")
} }
@@ -216,8 +216,8 @@ func (s Download) DownloadUsers(ctx context.Context, req domain.UsersPageRequest
return nil return nil
} }
func (s Download) DownloadRoles(ctx context.Context, w http.ResponseWriter) error { func (s Download) DownloadRoles(ctx context.Context, req domain.RoleAllRequest, w http.ResponseWriter) error {
roles, err := s.roleService.All(ctx, domain.RoleAllRequest{}) roles, err := s.roleService.All(ctx, req)
if err != nil { if err != nil {
return errors.WithMessage(err, "get roles") return errors.WithMessage(err, "get roles")
} }
+34
View File
@@ -232,7 +232,22 @@ func (s *DownloadSuite) TestAuditHappyPath() {
} }
func (s *DownloadSuite) TestRolesHappyPath() { func (s *DownloadSuite) TestRolesHappyPath() {
InsertRole(s.db, entity.Role{
Name: "admin_1",
ApplicationGroup: "123",
Permissions: s.permissions,
})
InsertRole(s.db, entity.Role{
Name: "admin_2",
ApplicationGroup: "456",
Permissions: s.permissions,
})
applicationGroup := "123"
resp, err := s.httpCli.Post("role/download"). resp, err := s.httpCli.Post("role/download").
JsonRequestBody(domain.RoleAllRequest{
ApplicationGroup: &applicationGroup,
}).
StatusCodeToError(). StatusCodeToError().
Do(s.T().Context()) Do(s.T().Context())
s.Require().NoError(err) s.Require().NoError(err)
@@ -240,4 +255,23 @@ func (s *DownloadSuite) TestRolesHappyPath() {
records, err := csv.NewReader(resp.Raw.Body).ReadAll() records, err := csv.NewReader(resp.Raw.Body).ReadAll()
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotEmpty(records) s.Require().NotEmpty(records)
header := records[0]
col := make(map[string]int, len(header))
for i, name := range header {
col[name] = i
}
moveIdx, ok := col["Действие"]
s.Require().True(ok)
keyIdx, ok := col["Ключ в системе"]
s.Require().True(ok)
nameIdx, ok := col["admin_1"]
s.Require().True(ok)
s.Require().Len(records, 2)
row := records[1]
s.Require().EqualValues("123", row[moveIdx])
s.Require().EqualValues("data_download", row[keyIdx])
s.Require().EqualValues("+", row[nameIdx])
} }