tests: adapt test expectations

This commit is contained in:
Michael Barz
2024-09-13 14:43:13 +02:00
parent 8b8aad6591
commit 2c9dab3e7c
3 changed files with 28 additions and 11 deletions
+21 -4
View File
@@ -14,6 +14,23 @@ import (
"github.com/owncloud/ocis/v2/services/graph/pkg/unifiedrole" "github.com/owncloud/ocis/v2/services/graph/pkg/unifiedrole"
) )
var (
unifiedRolesNames = map[string]string{
unifiedrole.UnifiedRoleViewerID: "Viewer",
unifiedrole.UnifiedRoleViewerListGrantsID: "ViewerListGrants",
unifiedrole.UnifiedRoleSpaceViewerID: "SpaceViewer",
unifiedrole.UnifiedRoleEditorID: "Editor",
unifiedrole.UnifiedRoleEditorListGrantsID: "EditorListGrants",
unifiedrole.UnifiedRoleSpaceEditorID: "SpaceEditor",
unifiedrole.UnifiedRoleSpaceEditorWithoutVersionsID: "SpaceEditorWithoutVersions",
unifiedrole.UnifiedRoleFileEditorID: "FileEditor",
unifiedrole.UnifiedRoleFileEditorListGrantsID: "FileEditorListGrants",
unifiedrole.UnifiedRoleEditorLiteID: "EditorLite",
unifiedrole.UnifiedRoleManagerID: "SpaceManager",
unifiedrole.UnifiedRoleSecureViewerID: "SecureViewer",
}
)
// UnifiedRoles bundles available commands for unified roles // UnifiedRoles bundles available commands for unified roles
func UnifiedRoles(cfg *config.Config) cli.Commands { func UnifiedRoles(cfg *config.Config) cli.Commands {
cmds := cli.Commands{ cmds := cli.Commands{
@@ -41,7 +58,7 @@ func listUnifiedRoles(cfg *config.Config) *cli.Command {
tbl.SetRowLine(true) tbl.SetRowLine(true)
tbl.SetAutoMergeCellsByColumnIndex([]int{0}) // rowspan should only affect the first column tbl.SetAutoMergeCellsByColumnIndex([]int{0}) // rowspan should only affect the first column
headers := []string{"UID", "Enabled", "Description", "Condition", "Allowed resource actions"} headers := []string{"Name", "UID", "Enabled", "Description", "Condition", "Allowed resource actions"}
tbl.SetHeader(headers) tbl.SetHeader(headers)
for _, definition := range unifiedrole.GetRoles(unifiedrole.RoleFilterAll()) { for _, definition := range unifiedrole.GetRoles(unifiedrole.RoleFilterAll()) {
@@ -49,10 +66,10 @@ func listUnifiedRoles(cfg *config.Config) *cli.Command {
const disabled = "disabled" const disabled = "disabled"
rows := [][]string{ rows := [][]string{
{definition.GetId(), disabled, definition.GetDescription()}, {unifiedRolesNames[definition.GetId()], definition.GetId(), disabled, definition.GetDescription()},
} }
if slices.Contains(cfg.UnifiedRoles.AvailableRoles, definition.GetId()) { if slices.Contains(cfg.UnifiedRoles.AvailableRoles, definition.GetId()) {
rows[0][1] = enabled rows[0][2] = enabled
} }
for i, rolePermission := range definition.GetRolePermissions() { for i, rolePermission := range definition.GetRolePermissions() {
@@ -62,7 +79,7 @@ func listUnifiedRoles(cfg *config.Config) *cli.Command {
case 0: case 0:
rows[0] = append(rows[0], row...) rows[0] = append(rows[0], row...)
default: default:
rows[0][3] = rows[0][3] + "\n" + rolePermission.GetCondition() rows[0][4] = rows[0][4] + "\n" + rolePermission.GetCondition()
} }
} }
@@ -296,7 +296,7 @@ Feature: permissions role definitions
"const": 0 "const": 0
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"
@@ -283,7 +283,7 @@ Feature: List a sharing permissions
"const": 2 "const": 2
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"
@@ -416,7 +416,7 @@ Feature: List a sharing permissions
"const": 2 "const": 2
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"
@@ -1104,7 +1104,7 @@ Feature: List a sharing permissions
"const": 2 "const": 2
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"
@@ -1226,7 +1226,7 @@ Feature: List a sharing permissions
"const": 2 "const": 2
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"
@@ -1508,7 +1508,7 @@ Feature: List a sharing permissions
"const": 2 "const": 2
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"
@@ -1846,7 +1846,7 @@ Feature: List a sharing permissions
"const": 2 "const": 2
}, },
"description": { "description": {
"const": "View, download, upload, edit, add and delete." "const": "View, download, upload, edit, add, delete including the history."
}, },
"displayName": { "displayName": {
"const": "Can edit" "const": "Can edit"