Skip to content

Commit 7cefb6c

Browse files
aryan-bhokaredependabot[bot]imrajdashrishavjhaSaranya-jena
authored andcommitted
Feat: Added support for multiple project owners (litmuschaos#4597)
* Modified db schema of Owner. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added new API GetProjectOwners. Signed-off-by: aryan <aryan1bhokare@gmail.com> * fix: return type error. Signed-off-by: aryan <aryan1bhokare@gmail.com> * chore(deps): Bump golang.org/x/crypto in /chaoscenter/authentication (litmuschaos#4527) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.21.0. - [Commits](golang/crypto@v0.18.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): Bump follow-redirects in /chaoscenter/web (litmuschaos#4529) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.5...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): Bump github.com/golang/protobuf (litmuschaos#4493) Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.5.3 to 1.5.4. - [Release notes](https://github.com/golang/protobuf/releases) - [Commits](golang/protobuf@v1.5.3...v1.5.4) --- updated-dependencies: - dependency-name: github.com/golang/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raj Das <mail.rajdas@gmail.com> * Modified SendInvitation API. This modification unables to send invite with the role as owner. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Modified LeaveProject API. This modification checks if the User is the last owner of the project and if not User can leave the project. Signed-off-by: aryan <aryan1bhokare@gmail.com> * RBAC modification `LeaveProject`. Allows Owner to be able to leave the project. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `UpdateMemberRole` API. This API is used for updating role of the member in the project. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Fixed some syntax errors. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Updated roles for owner. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added new API `DeleteProject`. Owner can delete project with help of this API. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added mocks. Signed-off-by: aryan <aryan1bhokare@gmail.com> * modified go.sum Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added condition `UpdateMemberRole`. User cannot change role of their own, so that it will avoid edge cases like 1. User is the last owner of the project. 2. User accidentally losing owner access to the projects. Signed-off-by: aryan <aryan1bhokare@gmail.com> * made suggested changes. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Changed DeleteProject endpoint to have url parameter. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Minor fixes. Signed-off-by: aryan <aryan1bhokare@gmail.com> * [WIP] : Multiple project owner backend. (litmuschaos#4536) * Modified db schema of Owner. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added new API GetProjectOwners. Signed-off-by: aryan <aryan1bhokare@gmail.com> * fix: return type error. Signed-off-by: aryan <aryan1bhokare@gmail.com> * chore(deps): Bump golang.org/x/crypto in /chaoscenter/authentication (litmuschaos#4527) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.21.0. - [Commits](golang/crypto@v0.18.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): Bump follow-redirects in /chaoscenter/web (litmuschaos#4529) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.5...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): Bump github.com/golang/protobuf (litmuschaos#4493) Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.5.3 to 1.5.4. - [Release notes](https://github.com/golang/protobuf/releases) - [Commits](golang/protobuf@v1.5.3...v1.5.4) --- updated-dependencies: - dependency-name: github.com/golang/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raj Das <mail.rajdas@gmail.com> * Modified SendInvitation API. This modification unables to send invite with the role as owner. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Modified LeaveProject API. This modification checks if the User is the last owner of the project and if not User can leave the project. Signed-off-by: aryan <aryan1bhokare@gmail.com> * RBAC modification `LeaveProject`. Allows Owner to be able to leave the project. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `UpdateMemberRole` API. This API is used for updating role of the member in the project. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Fixed some syntax errors. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Updated roles for owner. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added new API `DeleteProject`. Owner can delete project with help of this API. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added mocks. Signed-off-by: aryan <aryan1bhokare@gmail.com> * modified go.sum Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added condition `UpdateMemberRole`. User cannot change role of their own, so that it will avoid edge cases like 1. User is the last owner of the project. 2. User accidentally losing owner access to the projects. Signed-off-by: aryan <aryan1bhokare@gmail.com> * made suggested changes. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Changed DeleteProject endpoint to have url parameter. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Minor fixes. Signed-off-by: aryan <aryan1bhokare@gmail.com> --------- Signed-off-by: aryan <aryan1bhokare@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raj Das <mail.rajdas@gmail.com> * Added new route . Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `CreateProject` modal. Added a modal CreateProject with it's controller and views. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Some changes in `CreateProjectView`. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `ProjectDashboardCardMenu`. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `ProjectDashboardCard`. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `DeleteProject` API mutations. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `ProjectDashboard`. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added image and strings. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Modified `project entities`. Added new fields in `Project` struct. Added fields for filters, pagination, and some constants. Modified `CreateProjectInput`. Signed-off-by: aryan <aryan1bhokare@gmail.com> * [Backend] Modification in Backend for the UI. Added Filters and pagination in Backend. Modified API's and added a pipeline for the aggregation of results. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added `project_util` for validation of input request. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Indent Fixes Signed-off-by: aryan <aryan1bhokare@gmail.com> * Modification for Frontend Hook of `CreateProject` API. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Modified `ListProject` Query frontend hook. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Removed string constants and some minor changes. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added Project Filters. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added pagination and filter subheader in Dashboard. Signed-off-by: aryan <aryan1bhokare@gmail.com> * modified auth-api swagger file. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added tags section in create-project modal. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Changes due to modification of API and addition of new strings Signed-off-by: aryan <aryan1bhokare@gmail.com> * minor changes and resolved some errors. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added routing when clicked on the card. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Modifications in backend tests as per API updates. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Fix: NoProjects Element and NoFilteredProject Results element. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Added scroll for the project list. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Some changes in UI w.r.t Multiple Project Owner Feature. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Made search text type insensitive. Signed-off-by: aryan <aryan1bhokare@gmail.com> * Update chaoscenter/web/src/controllers/ProjectDashboard/ProjectFilters.tsx Co-authored-by: Hrishav <hrishav.kumar@harness.io> Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> * requested changes. Signed-off-by: aryan <aryan1bhokare@gmail.com> * removed unnecessary handle function Signed-off-by: aryan <aryan1bhokare@gmail.com> * requested backend changes and small fixes Signed-off-by: aryan <aryan1bhokare@gmail.com> * Changed folder structure. Signed-off-by: aryan <aryan1bhokare@gmail.com> * requested changes. Signed-off-by: aryan <aryan1bhokare@gmail.com> * fixed import orders Signed-off-by: aryan <aryan1bhokare@gmail.com> * fixing RoleEditor to RoleExecuter Signed-off-by: aryan <aryan1bhokare@gmail.com> * removed redundant deleteprojectinput Signed-off-by: aryan <aryan1bhokare@gmail.com> * fixed bug caused in merging Signed-off-by: aryan <aryan1bhokare@gmail.com> * fixed bug caused in merging Signed-off-by: aryan <aryan1bhokare@gmail.com> * removed duplicate struct Signed-off-by: aryan <aryan1bhokare@gmail.com> * Fix: frontend chaoshub test Signed-off-by: aryan <aryan1bhokare@gmail.com> * fix: tag rendering issue in project dashboard Signed-off-by: aryan <aryan1bhokare@gmail.com> * fix: Less user details in createProject Signed-off-by: aryan <aryan1bhokare@gmail.com> * fix: import orders Signed-off-by: aryan <aryan1bhokare@gmail.com> --------- Signed-off-by: aryan <aryan1bhokare@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raj Das <mail.rajdas@gmail.com> Co-authored-by: Hrishav <hrishav.kumar@harness.io> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
1 parent 5c1f9c0 commit 7cefb6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2442
-390
lines changed

chaoscenter/authentication/api/handlers/rest/project_handler.go

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"time"
66

77
"github.com/litmuschaos/litmus/chaoscenter/authentication/api/presenter"
8+
"github.com/litmuschaos/litmus/chaoscenter/authentication/api/types"
9+
project_utils "github.com/litmuschaos/litmus/chaoscenter/authentication/api/utils"
810
"github.com/litmuschaos/litmus/chaoscenter/authentication/pkg/entities"
911
"github.com/litmuschaos/litmus/chaoscenter/authentication/pkg/services"
1012
"github.com/litmuschaos/litmus/chaoscenter/authentication/pkg/utils"
@@ -53,16 +55,23 @@ func GetUserWithProject(service services.ApplicationService) gin.HandlerFunc {
5355
return
5456
}
5557

56-
outputUser := user.GetUserWithProject()
58+
request := project_utils.GetProjectFilters(c)
59+
request.UserID = user.ID
5760

58-
projects, err := service.GetProjectsByUserID(outputUser.ID, false)
61+
response, err := service.GetProjectsByUserID(request)
5962
if err != nil {
6063
log.Error(err)
6164
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
6265
return
6366
}
6467

65-
outputUser.Projects = projects
68+
outputUser := &entities.UserWithProject{
69+
Username: user.Username,
70+
ID: user.ID,
71+
Email: user.Email,
72+
Name: user.Name,
73+
Projects: response.Projects,
74+
}
6675

6776
c.JSON(http.StatusOK, gin.H{"data": outputUser})
6877
}
@@ -122,9 +131,10 @@ func GetProject(service services.ApplicationService) gin.HandlerFunc {
122131
// GetProjectsByUserID queries the project with a given userID from the database and returns it in the appropriate format
123132
func GetProjectsByUserID(service services.ApplicationService) gin.HandlerFunc {
124133
return func(c *gin.Context) {
125-
uID := c.MustGet("uid").(string)
126-
projects, err := service.GetProjectsByUserID(uID, false)
127-
if projects == nil {
134+
request := project_utils.GetProjectFilters(c)
135+
136+
response, err := service.GetProjectsByUserID(request)
137+
if response == nil || (response.TotalNumberOfProjects != nil && *response.TotalNumberOfProjects == 0) {
128138
c.JSON(http.StatusOK, gin.H{
129139
"message": "No projects found",
130140
})
@@ -135,7 +145,7 @@ func GetProjectsByUserID(service services.ApplicationService) gin.HandlerFunc {
135145
return
136146
}
137147

138-
c.JSON(http.StatusOK, gin.H{"data": projects})
148+
c.JSON(http.StatusOK, gin.H{"data": response})
139149
}
140150
}
141151

@@ -309,6 +319,7 @@ func CreateProject(service services.ApplicationService) gin.HandlerFunc {
309319
c.JSON(utils.ErrorStatusCodes[utils.ErrInvalidRequest], presenter.CreateErrorResponse(utils.ErrInvalidRequest))
310320
return
311321
}
322+
userRequest.UserID = c.MustGet("uid").(string)
312323

313324
// admin/user shouldn't be able to perform any task if it's default pwd is not changes(initial login is true)
314325
initialLogin, err := CheckInitialLogin(service, userRequest.UserID)
@@ -324,7 +335,17 @@ func CreateProject(service services.ApplicationService) gin.HandlerFunc {
324335
return
325336
}
326337

327-
userRequest.UserID = c.MustGet("uid").(string)
338+
if userRequest.Description == nil {
339+
// If description is not provided, set it to an empty string
340+
emptyDescription := ""
341+
userRequest.Description = &emptyDescription
342+
}
343+
344+
if userRequest.Tags == nil {
345+
// If tags are not provided, set it to an empty slice
346+
emptyTags := make([]*string, 0)
347+
userRequest.Tags = emptyTags
348+
}
328349

329350
user, err := service.GetUser(userRequest.UserID)
330351
if err != nil {
@@ -349,18 +370,22 @@ func CreateProject(service services.ApplicationService) gin.HandlerFunc {
349370
// Adding user as project owner in project's member list
350371
newMember := &entities.Member{
351372
UserID: user.ID,
373+
Username: user.Name,
374+
Email: user.Email,
352375
Role: entities.RoleOwner,
353376
Invitation: entities.AcceptedInvitation,
354377
JoinedAt: time.Now().UnixMilli(),
355378
}
356379
var members []*entities.Member
357380
members = append(members, newMember)
358-
state := "active"
381+
state := string(types.MemberStateActive)
359382
newProject := &entities.Project{
360-
ID: pID,
361-
Name: userRequest.ProjectName,
362-
Members: members,
363-
State: &state,
383+
ID: pID,
384+
Name: userRequest.ProjectName,
385+
Members: members,
386+
State: &state,
387+
Description: userRequest.Description,
388+
Tags: userRequest.Tags,
364389
Audit: entities.Audit{
365390
IsRemoved: false,
366391
CreatedAt: time.Now().UnixMilli(),
@@ -436,7 +461,7 @@ func SendInvitation(service services.ApplicationService) gin.HandlerFunc {
436461
}
437462

438463
// Validating member role
439-
if member.Role == nil || (*member.Role != entities.RoleExecutor && *member.Role != entities.RoleViewer) {
464+
if member.Role == nil || (*member.Role != entities.RoleExecutor && *member.Role != entities.RoleViewer && *member.Role != entities.RoleOwner) {
440465
c.JSON(utils.ErrorStatusCodes[utils.ErrInvalidRole], presenter.CreateErrorResponse(utils.ErrInvalidRole))
441466
return
442467
}
@@ -734,6 +759,12 @@ func RemoveInvitation(service services.ApplicationService) gin.HandlerFunc {
734759
return
735760
}
736761

762+
uid := c.MustGet("uid").(string)
763+
if uid == member.UserID {
764+
c.JSON(http.StatusBadRequest, gin.H{"message": "User cannot remove invitation of themselves use Leave Project."})
765+
return
766+
}
767+
737768
invitation, err := getInvitation(service, member)
738769
if err != nil {
739770
log.Error(err)

chaoscenter/authentication/api/handlers/rest/project_handler_test.go

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ func TestGetUserWithProject(t *testing.T) {
3434
Username: "testUser",
3535
Email: "test@example.com",
3636
}
37-
project := &entities.Project{}
37+
response := &entities.ListProjectResponse{}
38+
39+
request := &entities.ListProjectRequest{
40+
UserID: "testUID",
41+
}
3842

3943
service.On("FindUserByUsername", "testUser").Return(user, errors.New("failed"))
40-
service.On("GetProjectsByUserID", "testUID", false).Return([]*entities.Project{project}, errors.New("failed"))
44+
service.On("GetProjectsByUserID", request).Return(response, errors.New("failed"))
4145

4246
rest.GetUserWithProject(service)(c)
4347

@@ -60,10 +64,30 @@ func TestGetUserWithProject(t *testing.T) {
6064
Username: "testUser1",
6165
Email: "test@example.com",
6266
}
63-
project := &entities.Project{}
67+
68+
response := &entities.ListProjectResponse{}
69+
70+
fieldName := entities.ProjectSortingFieldTime
71+
72+
request := &entities.ListProjectRequest{
73+
UserID: "testUID",
74+
Pagination: &entities.Pagination{
75+
Page: 0,
76+
Limit: 15,
77+
},
78+
Sort: &entities.SortInput{
79+
Field: &fieldName,
80+
Ascending: nil,
81+
},
82+
Filter: &entities.ListProjectInputFilter{
83+
CreatedByMe: nil,
84+
InvitedByOthers: nil,
85+
ProjectName: nil,
86+
},
87+
}
6488

6589
service.On("FindUserByUsername", "testUser1").Return(user, nil)
66-
service.On("GetProjectsByUserID", "testUID", false).Return([]*entities.Project{project}, nil)
90+
service.On("GetProjectsByUserID", request).Return(response, nil)
6791

6892
rest.GetUserWithProject(service)(c)
6993

@@ -87,10 +111,29 @@ func TestGetUserWithProject(t *testing.T) {
87111
Email: "test@example.com",
88112
Role: entities.RoleAdmin,
89113
}
90-
project := &entities.Project{}
114+
response := &entities.ListProjectResponse{}
115+
116+
fieldName := entities.ProjectSortingFieldTime
117+
118+
request := &entities.ListProjectRequest{
119+
UserID: "testUID",
120+
Pagination: &entities.Pagination{
121+
Page: 0,
122+
Limit: 15,
123+
},
124+
Sort: &entities.SortInput{
125+
Field: &fieldName,
126+
Ascending: nil,
127+
},
128+
Filter: &entities.ListProjectInputFilter{
129+
CreatedByMe: nil,
130+
InvitedByOthers: nil,
131+
ProjectName: nil,
132+
},
133+
}
91134

92135
service.On("FindUserByUsername", "testUser").Return(user, nil)
93-
service.On("GetProjectsByUserID", "testUID", false).Return([]*entities.Project{project}, nil)
136+
service.On("GetProjectsByUserID", request).Return(response, nil)
94137

95138
rest.GetUserWithProject(service)(c)
96139

@@ -106,14 +149,30 @@ func TestGetProjectsByUserID(t *testing.T) {
106149
w := httptest.NewRecorder()
107150
ctx := GetTestGinContext(w)
108151
ctx.Set("uid", "testUserID")
109-
projects := []*entities.Project{
110-
{
111-
ID: "testProjectID",
112-
Name: "Test Project",
152+
153+
response := &entities.ListProjectResponse{}
154+
155+
fieldName := entities.ProjectSortingFieldTime
156+
157+
request := &entities.ListProjectRequest{
158+
UserID: "testUserID",
159+
Pagination: &entities.Pagination{
160+
Page: 0,
161+
Limit: 15,
162+
},
163+
Sort: &entities.SortInput{
164+
Field: &fieldName,
165+
Ascending: nil,
166+
},
167+
Filter: &entities.ListProjectInputFilter{
168+
CreatedByMe: nil,
169+
InvitedByOthers: nil,
170+
ProjectName: nil,
113171
},
114172
}
173+
115174
service := new(mocks.MockedApplicationService)
116-
service.On("GetProjectsByUserID", "testUserID", false).Return(projects, errors.New("Failed"))
175+
service.On("GetProjectsByUserID", request).Return(response, errors.New("Failed"))
117176
rest.GetProjectsByUserID(service)(ctx)
118177
assert.Equal(t, utils.ErrorStatusCodes[utils.ErrServerError], w.Code)
119178
})
@@ -129,8 +188,32 @@ func TestGetProjectsByUserID(t *testing.T) {
129188
Name: "Test Project",
130189
},
131190
}
191+
192+
response := &entities.ListProjectResponse{
193+
Projects: projects,
194+
}
195+
196+
fieldName := entities.ProjectSortingFieldTime
197+
198+
request := &entities.ListProjectRequest{
199+
UserID: "testUserID",
200+
Pagination: &entities.Pagination{
201+
Page: 0,
202+
Limit: 15,
203+
},
204+
Sort: &entities.SortInput{
205+
Field: &fieldName,
206+
Ascending: nil,
207+
},
208+
Filter: &entities.ListProjectInputFilter{
209+
CreatedByMe: nil,
210+
InvitedByOthers: nil,
211+
ProjectName: nil,
212+
},
213+
}
214+
132215
service := new(mocks.MockedApplicationService)
133-
service.On("GetProjectsByUserID", "testUserID", false).Return(projects, nil)
216+
service.On("GetProjectsByUserID", request).Return(response, nil)
134217
rest.GetProjectsByUserID(service)(ctx)
135218
assert.Equal(t, http.StatusOK, w.Code)
136219
})

chaoscenter/authentication/api/mocks/rest_mocks.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ func (m *MockedApplicationService) GetProjects(query bson.D) ([]*entities.Projec
9797
return args.Get(0).([]*entities.Project), args.Error(1)
9898
}
9999

100-
func (m *MockedApplicationService) GetProjectsByUserID(uid string, isOwner bool) ([]*entities.Project, error) {
101-
args := m.Called(uid, isOwner)
102-
return args.Get(0).([]*entities.Project), args.Error(1)
100+
func (m *MockedApplicationService) GetProjectsByUserID(request *entities.ListProjectRequest) (*entities.ListProjectResponse, error) {
101+
args := m.Called(request)
102+
return args.Get(0).(*entities.ListProjectResponse), args.Error(1)
103103
}
104104

105105
func (m *MockedApplicationService) GetProjectStats() ([]*entities.ProjectStats, error) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package types
2+
3+
type MemberState string
4+
5+
const (
6+
MemberStateActive MemberState = "active"
7+
MemberStateInactive MemberState = "inactive"
8+
)
9+
10+
const (
11+
ProjectName = "projectName"
12+
SortField = "sortField"
13+
Ascending = "sortAscending"
14+
CreatedByMe = "createdByMe"
15+
Page = "page"
16+
Limit = "limit"
17+
)

0 commit comments

Comments
 (0)