From 816a30397da6ceff836d8723233dc5cdbda70871 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 21 Nov 2017 13:08:32 -0600 Subject: Role refactor (#7867) * role refactor * add missing file * fix web test --- api4/post_test.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'api4/post_test.go') diff --git a/api4/post_test.go b/api4/post_test.go index c37b61ecd..e4fb7dd8b 100644 --- a/api4/post_test.go +++ b/api4/post_test.go @@ -136,14 +136,14 @@ func testCreatePostWithOutgoingHook( defer func() { th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() + th.App.SetDefaultRolesBasedOnConfig() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections }) }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) - utils.SetDefaultRolesBasedOnConfig() + th.App.SetDefaultRolesBasedOnConfig() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1" }) @@ -323,7 +323,7 @@ func TestCreatePostPublic(t *testing.T) { post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"} - user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_USER.Id} + user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID} ruser, resp := Client.CreateUser(&user) CheckNoError(t, resp) @@ -333,7 +333,7 @@ func TestCreatePostPublic(t *testing.T) { _, resp = Client.CreatePost(post) CheckForbiddenStatus(t, resp) - th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL_PUBLIC.Id, false) + th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_POST_ALL_PUBLIC_ROLE_ID, false) th.App.InvalidateAllCaches() Client.Login(user.Email, user.Password) @@ -345,9 +345,9 @@ func TestCreatePostPublic(t *testing.T) { _, resp = Client.CreatePost(post) CheckForbiddenStatus(t, resp) - th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id, false) + th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID, false) th.App.JoinUserToTeam(th.BasicTeam, ruser, "") - th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.ROLE_TEAM_USER.Id+" "+model.ROLE_TEAM_POST_ALL_PUBLIC.Id) + th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.TEAM_USER_ROLE_ID+" "+model.TEAM_POST_ALL_PUBLIC_ROLE_ID) th.App.InvalidateAllCaches() Client.Login(user.Email, user.Password) @@ -368,7 +368,7 @@ func TestCreatePostAll(t *testing.T) { post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"} - user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_USER.Id} + user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID} directChannel, _ := th.App.CreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id) @@ -380,7 +380,7 @@ func TestCreatePostAll(t *testing.T) { _, resp = Client.CreatePost(post) CheckForbiddenStatus(t, resp) - th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL.Id, false) + th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_POST_ALL_ROLE_ID, false) th.App.InvalidateAllCaches() Client.Login(user.Email, user.Password) @@ -396,9 +396,9 @@ func TestCreatePostAll(t *testing.T) { _, resp = Client.CreatePost(post) CheckNoError(t, resp) - th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id, false) + th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID, false) th.App.JoinUserToTeam(th.BasicTeam, ruser, "") - th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.ROLE_TEAM_USER.Id+" "+model.ROLE_TEAM_POST_ALL.Id) + th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.TEAM_USER_ROLE_ID+" "+model.TEAM_POST_ALL_ROLE_ID) th.App.InvalidateAllCaches() Client.Login(user.Email, user.Password) @@ -496,14 +496,14 @@ func TestUpdatePost(t *testing.T) { utils.SetIsLicensed(isLicensed) utils.SetLicense(license) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost }) - utils.SetDefaultRolesBasedOnConfig() + th.App.SetDefaultRolesBasedOnConfig() }() utils.SetIsLicensed(true) utils.SetLicense(&model.License{Features: &model.Features{}}) utils.License().Features.SetDefaults() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS }) - utils.SetDefaultRolesBasedOnConfig() + th.App.SetDefaultRolesBasedOnConfig() post := &model.Post{ChannelId: channel.Id, Message: "zz" + model.NewId() + "a"} rpost, resp := Client.CreatePost(post) @@ -581,14 +581,14 @@ func TestPatchPost(t *testing.T) { utils.SetIsLicensed(isLicensed) utils.SetLicense(license) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost }) - utils.SetDefaultRolesBasedOnConfig() + th.App.SetDefaultRolesBasedOnConfig() }() utils.SetIsLicensed(true) utils.SetLicense(&model.License{Features: &model.Features{}}) utils.License().Features.SetDefaults() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS }) - utils.SetDefaultRolesBasedOnConfig() + th.App.SetDefaultRolesBasedOnConfig() post := &model.Post{ ChannelId: channel.Id, -- cgit v1.2.3-1-g7c22