RBAC: remove access control mock from org quota tests (#61574)

* remove ac mock from org quota tests

* fix incorrect expected status code and swap tests to make setup easier

* remove empty line
This commit is contained in:
Ieva
2023-01-17 10:33:01 +00:00
committed by GitHub
parent 04b5e6ed9e
commit cd363cb037
2 changed files with 125 additions and 98 deletions

View File

@@ -1,8 +1,6 @@
package api
import (
"context"
"fmt"
"net/http"
"strings"
"testing"
@@ -14,7 +12,6 @@ import (
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/org/orgtest"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/services/user/usertest"
"github.com/grafana/grafana/pkg/setting"
@@ -622,18 +619,3 @@ func TestAPIEndpoint_GetOrg_RBAC(t *testing.T) {
})
}
}
// setupOrgsDBForAccessControlTests creates orgs up until orgID and fake user as member of org
func setupOrgsDBForAccessControlTests(t *testing.T, db *sqlstore.SQLStore, c accessControlScenarioContext, orgID int64) {
t.Helper()
setInitCtxSignedInViewer(c.initCtx)
u := *c.initCtx.SignedInUser
u.OrgID = orgID
c.userService.(*usertest.FakeUserService).ExpectedSignedInUser = &u
// Create `orgsCount` orgs
for i := 1; i <= int(orgID); i++ {
_, err := c.hs.orgService.CreateWithMember(context.Background(), &org.CreateOrgCommand{Name: fmt.Sprintf("TestOrg%v", i), UserID: 0})
require.NoError(t, err)
}
}