diff options
author | Martin Kraft <mkraft@users.noreply.github.com> | 2018-02-13 06:08:21 -0500 |
---|---|---|
committer | Jesús Espino <jespinog@gmail.com> | 2018-02-13 12:08:21 +0100 |
commit | b7fc3d7d35ca4dd16097715a66463392a1dfaf0a (patch) | |
tree | f3ab26dcd84c3377bc34542a63facf21df6c0bc6 /utils | |
parent | 93254308599357fac665fce604f3506ee8a845fa (diff) | |
download | chat-b7fc3d7d35ca4dd16097715a66463392a1dfaf0a.tar.gz chat-b7fc3d7d35ca4dd16097715a66463392a1dfaf0a.tar.bz2 chat-b7fc3d7d35ca4dd16097715a66463392a1dfaf0a.zip |
Updates migration tests to reflect front-end mapping changes. (#8237)
Diffstat (limited to 'utils')
-rw-r--r-- | utils/authorization.go | 2 | ||||
-rw-r--r-- | utils/authorization_test.go | 10 | ||||
-rw-r--r-- | utils/config.go | 2 | ||||
-rw-r--r-- | utils/policies-roles-mapping.json | 74 |
4 files changed, 59 insertions, 29 deletions
diff --git a/utils/authorization.go b/utils/authorization.go index e8556458a..bc71404ef 100644 --- a/utils/authorization.go +++ b/utils/authorization.go @@ -260,7 +260,7 @@ func SetRolePermissionsFromConfig(roles map[string]*model.Role, cfg *model.Confi ) } - if cfg.TeamSettings.EnableTeamCreation { + if *cfg.TeamSettings.EnableTeamCreation { roles[model.SYSTEM_USER_ROLE_ID].Permissions = append( roles[model.SYSTEM_USER_ROLE_ID].Permissions, model.PERMISSION_CREATE_TEAM.Id, diff --git a/utils/authorization_test.go b/utils/authorization_test.go index 9e5b570bb..8c78dcbda 100644 --- a/utils/authorization_test.go +++ b/utils/authorization_test.go @@ -8,6 +8,7 @@ import ( "fmt" "io/ioutil" "reflect" + "strconv" "strings" "testing" @@ -112,7 +113,14 @@ func updateConfig(config *model.Config, key string, value string) { v = reflect.ValueOf(config.TeamSettings) field = v.FieldByName(key) } - field.Elem().SetString(value) + + switch value { + case "true", "false": + b, _ := strconv.ParseBool(value) + field.Elem().SetBool(b) + default: + field.Elem().SetString(value) + } } func roleHasPermission(role *model.Role, permission string) bool { diff --git a/utils/config.go b/utils/config.go index 9e962eef4..be20e0367 100644 --- a/utils/config.go +++ b/utils/config.go @@ -354,7 +354,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string) map[string]strin props["SiteURL"] = strings.TrimRight(*c.ServiceSettings.SiteURL, "/") props["SiteName"] = c.TeamSettings.SiteName - props["EnableTeamCreation"] = strconv.FormatBool(c.TeamSettings.EnableTeamCreation) + props["EnableTeamCreation"] = strconv.FormatBool(*c.TeamSettings.EnableTeamCreation) props["EnableUserCreation"] = strconv.FormatBool(c.TeamSettings.EnableUserCreation) props["EnableOpenServer"] = strconv.FormatBool(*c.TeamSettings.EnableOpenServer) props["RestrictDirectMessage"] = *c.TeamSettings.RestrictDirectMessage diff --git a/utils/policies-roles-mapping.json b/utils/policies-roles-mapping.json index f083a854a..1b2acdfcb 100644 --- a/utils/policies-roles-mapping.json +++ b/utils/policies-roles-mapping.json @@ -432,16 +432,6 @@ "shouldHave": true }, { - "roleName": "channel_admin", - "permission": "delete_post", - "shouldHave": false - }, - { - "roleName": "channel_admin", - "permission": "delete_others_posts", - "shouldHave": false - }, - { "roleName": "team_admin", "permission": "delete_post", "shouldHave": true @@ -459,16 +449,6 @@ "shouldHave": false }, { - "roleName": "channel_admin", - "permission": "delete_post", - "shouldHave": false - }, - { - "roleName": "channel_admin", - "permission": "delete_others_posts", - "shouldHave": false - }, - { "roleName": "team_admin", "permission": "delete_post", "shouldHave": true @@ -486,25 +466,67 @@ "shouldHave": false }, { - "roleName": "channel_admin", + "roleName": "team_admin", "permission": "delete_post", "shouldHave": false }, { - "roleName": "channel_admin", + "roleName": "team_admin", "permission": "delete_others_posts", "shouldHave": false + } + ] + }, + "enableTeamCreation": { + "true": [ + { + "roleName": "system_user", + "permission": "create_team", + "shouldHave": true + } + ], + "false": [ + { + "roleName": "system_user", + "permission": "create_team", + "shouldHave": false + } + ] + }, + "enableOnlyAdminIntegrations": { + "true": [ + { + "roleName": "team_user", + "permission": "manage_webhooks", + "shouldHave": false }, { - "roleName": "team_admin", - "permission": "delete_post", + "roleName": "team_user", + "permission": "manage_slash_commands", "shouldHave": false }, { - "roleName": "team_admin", - "permission": "delete_others_posts", + "roleName": "system_user", + "permission": "manage_oauth", "shouldHave": false } + ], + "false": [ + { + "roleName": "team_user", + "permission": "manage_webhooks", + "shouldHave": true + }, + { + "roleName": "team_user", + "permission": "manage_slash_commands", + "shouldHave": true + }, + { + "roleName": "system_user", + "permission": "manage_oauth", + "shouldHave": true + } ] } }
\ No newline at end of file |