RBAC: Fix delete team permissions on team delete (#83442)

* RBAC: Remove team permissions on delete

* Remove unecessary deletes from store function

* Nit on mock

* Add test to the database

* Nit on comment

* Add another test to check that other permissions remain
This commit is contained in:
Gabriel MABILLE
2024-02-27 12:21:26 +01:00
committed by GitHub
parent ffae7d111c
commit 8d9921a5ba
9 changed files with 178 additions and 5 deletions

View File

@@ -41,6 +41,10 @@ func (f FakeService) DeleteUserPermissions(ctx context.Context, orgID, userID in
return f.ExpectedErr
}
func (f FakeService) DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error {
return f.ExpectedErr
}
func (f FakeService) DeclareFixedRoles(registrations ...accesscontrol.RoleRegistration) error {
return f.ExpectedErr
}
@@ -94,6 +98,10 @@ func (f FakeStore) DeleteUserPermissions(ctx context.Context, orgID, userID int6
return f.ExpectedErr
}
func (f FakeStore) DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error {
return f.ExpectedErr
}
func (f FakeStore) SaveExternalServiceRole(ctx context.Context, cmd accesscontrol.SaveExternalServiceRoleCommand) error {
return f.ExpectedErr
}

View File

@@ -51,6 +51,24 @@ func (_m *MockStore) DeleteUserPermissions(ctx context.Context, orgID int64, use
return r0
}
// DeleteTeamPermissions provides a mock function with given fields: ctx, orgID, teamID
func (_m *MockStore) DeleteTeamPermissions(ctx context.Context, orgID int64, teamID int64) error {
ret := _m.Called(ctx, orgID, teamID)
if len(ret) == 0 {
panic("no return value specified for DeleteTeamPermissions")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64, int64) error); ok {
r0 = rf(ctx, orgID, teamID)
} else {
r0 = ret.Error(0)
}
return r0
}
// GetUserPermissions provides a mock function with given fields: ctx, query
func (_m *MockStore) GetUserPermissions(ctx context.Context, query accesscontrol.GetUserPermissionsQuery) ([]accesscontrol.Permission, error) {
ret := _m.Called(ctx, query)