diff options
author | Chris <ccbrown112@gmail.com> | 2017-11-21 13:08:32 -0600 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-11-21 11:08:32 -0800 |
commit | 816a30397da6ceff836d8723233dc5cdbda70871 (patch) | |
tree | d9075e04c6570296cea924b97088839f49d6ce9d /app/authorization_test.go | |
parent | 01e652ed481ed0ef0a8d8c021751655c1a58dd2a (diff) | |
download | chat-816a30397da6ceff836d8723233dc5cdbda70871.tar.gz chat-816a30397da6ceff836d8723233dc5cdbda70871.tar.bz2 chat-816a30397da6ceff836d8723233dc5cdbda70871.zip |
Role refactor (#7867)
* role refactor
* add missing file
* fix web test
Diffstat (limited to 'app/authorization_test.go')
-rw-r--r-- | app/authorization_test.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/app/authorization_test.go b/app/authorization_test.go index 375b279dc..a65fe8333 100644 --- a/app/authorization_test.go +++ b/app/authorization_test.go @@ -10,23 +10,26 @@ import ( ) func TestCheckIfRolesGrantPermission(t *testing.T) { + th := Setup().InitBasic() + defer th.TearDown() + cases := []struct { roles []string permissionId string shouldGrant bool }{ - {[]string{model.ROLE_SYSTEM_ADMIN.Id}, model.ROLE_SYSTEM_ADMIN.Permissions[0], true}, - {[]string{model.ROLE_SYSTEM_ADMIN.Id}, "non-existant-permission", false}, - {[]string{model.ROLE_CHANNEL_USER.Id}, model.ROLE_CHANNEL_USER.Permissions[0], true}, - {[]string{model.ROLE_CHANNEL_USER.Id}, model.PERMISSION_MANAGE_SYSTEM.Id, false}, - {[]string{model.ROLE_SYSTEM_ADMIN.Id, model.ROLE_CHANNEL_USER.Id}, model.PERMISSION_MANAGE_SYSTEM.Id, true}, - {[]string{model.ROLE_CHANNEL_USER.Id, model.ROLE_SYSTEM_ADMIN.Id}, model.PERMISSION_MANAGE_SYSTEM.Id, true}, - {[]string{model.ROLE_TEAM_USER.Id, model.ROLE_TEAM_ADMIN.Id}, model.PERMISSION_MANAGE_SLASH_COMMANDS.Id, true}, - {[]string{model.ROLE_TEAM_ADMIN.Id, model.ROLE_TEAM_USER.Id}, model.PERMISSION_MANAGE_SLASH_COMMANDS.Id, true}, + {[]string{model.SYSTEM_ADMIN_ROLE_ID}, th.App.Role(model.SYSTEM_ADMIN_ROLE_ID).Permissions[0], true}, + {[]string{model.SYSTEM_ADMIN_ROLE_ID}, "non-existant-permission", false}, + {[]string{model.CHANNEL_USER_ROLE_ID}, th.App.Role(model.CHANNEL_USER_ROLE_ID).Permissions[0], true}, + {[]string{model.CHANNEL_USER_ROLE_ID}, model.PERMISSION_MANAGE_SYSTEM.Id, false}, + {[]string{model.SYSTEM_ADMIN_ROLE_ID, model.CHANNEL_USER_ROLE_ID}, model.PERMISSION_MANAGE_SYSTEM.Id, true}, + {[]string{model.CHANNEL_USER_ROLE_ID, model.SYSTEM_ADMIN_ROLE_ID}, model.PERMISSION_MANAGE_SYSTEM.Id, true}, + {[]string{model.TEAM_USER_ROLE_ID, model.TEAM_ADMIN_ROLE_ID}, model.PERMISSION_MANAGE_SLASH_COMMANDS.Id, true}, + {[]string{model.TEAM_ADMIN_ROLE_ID, model.TEAM_USER_ROLE_ID}, model.PERMISSION_MANAGE_SLASH_COMMANDS.Id, true}, } for testnum, testcase := range cases { - if CheckIfRolesGrantPermission(testcase.roles, testcase.permissionId) != testcase.shouldGrant { + if th.App.CheckIfRolesGrantPermission(testcase.roles, testcase.permissionId) != testcase.shouldGrant { t.Fatal("Failed test case ", testnum) } } |