RBAC: Update library element tests to use RBAC (#66782)

* update library element tests to use RBAC

* update bits of code to use RBAC

* update library panel tests

* linting

* more linting

* and more linting

* PR feedback
This commit is contained in:
Ieva
2023-04-20 12:24:41 +03:00
committed by GitHub
parent 4e10118c3a
commit a37bf1ac2a
8 changed files with 390 additions and 380 deletions
@@ -24,7 +24,7 @@ func TestPatchLibraryElement(t *testing.T) {
scenarioWithPanel(t, "When an admin tries to patch a library panel that exists, it should succeed",
func(t *testing.T, sc scenarioContext) {
newFolder := createFolderWithACL(t, sc.sqlStore, "NewFolder", sc.user, []folderACLItem{})
newFolder := createFolder(t, sc, "NewFolder")
cmd := model.PatchLibraryElementCommand{
FolderID: newFolder.ID,
Name: "Panel - New name",
@@ -89,7 +89,7 @@ func TestPatchLibraryElement(t *testing.T) {
scenarioWithPanel(t, "When an admin tries to patch a library panel with folder only, it should change folder successfully and return correct result",
func(t *testing.T, sc scenarioContext) {
newFolder := createFolderWithACL(t, sc.sqlStore, "NewFolder", sc.user, []folderACLItem{})
newFolder := createFolder(t, sc, "NewFolder")
cmd := model.PatchLibraryElementCommand{
FolderID: newFolder.ID,
Kind: int64(model.PanelElement),
@@ -325,7 +325,7 @@ func TestPatchLibraryElement(t *testing.T) {
scenarioWithPanel(t, "When an admin tries to patch a library panel with a folder where a library panel with the same name already exists, it should fail",
func(t *testing.T, sc scenarioContext) {
newFolder := createFolderWithACL(t, sc.sqlStore, "NewFolder", sc.user, []folderACLItem{})
newFolder := createFolder(t, sc, "NewFolder")
command := getCreatePanelCommand(newFolder.ID, "Text - Library Panel")
sc.ctx.Req.Body = mockRequestBody(command)
resp := sc.service.createHandler(sc.reqContext)