RBAC: Cleaup team api rbac tests (#57265)

* RBAC: Remove the access control evaluator fake

* API: Change to use access control implementation instead of mocks with
rbac disabled in tests

* Tests: Set cfg and access control defaults after applying options

* Tests: Rewrite team legacy access control tests

* Tests: Add helper function to create user with permissions

* Tests: set fake quota service as default

* Team: Add ExpectedTeamDTO and set in query result

* RBAC: Revert change

* RBAC: Add deprecation notice to mock
This commit is contained in:
Karl Persson
2022-10-20 09:11:47 +02:00
committed by GitHub
parent 0dd721d4ce
commit 764d5b9929
4 changed files with 206 additions and 187 deletions
+1
View File
@@ -53,6 +53,7 @@ type Mock struct {
// Ensure the mock stays in line with the interface
var _ fullAccessControl = New()
// Deprecated: use fake service and real access control evaluator instead
func New() *Mock {
mock := &Mock{
Calls: Calls{},
+2
View File
@@ -8,6 +8,7 @@ import (
type FakeService struct {
ExpectedTeam models.Team
ExpectedTeamDTO *models.TeamDTO
ExpectedTeamsByUser []*models.TeamDTO
ExpectedMembers []*models.TeamMemberDTO
ExpectedError error
@@ -34,6 +35,7 @@ func (s *FakeService) SearchTeams(ctx context.Context, query *models.SearchTeams
}
func (s *FakeService) GetTeamById(ctx context.Context, query *models.GetTeamByIdQuery) error {
query.Result = s.ExpectedTeamDTO
return s.ExpectedError
}