diff --git a/server/.golangci.yml b/server/.golangci.yml index c60d3df089..03365f1e3e 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -151,7 +151,6 @@ issues: channels/app/post_persistent_notification_test.go|\ channels/app/post_test.go|\ channels/app/product_notices_test.go|\ - channels/app/role_test.go|\ channels/app/security_update_check.go|\ channels/app/server.go|\ channels/app/server_test.go|\ diff --git a/server/channels/app/role_test.go b/server/channels/app/role_test.go index f6fd63485e..211eb6bb5f 100644 --- a/server/channels/app/role_test.go +++ b/server/channels/app/role_test.go @@ -81,7 +81,8 @@ func testPermissionInheritance(t *testing.T, testCallback func(t *testing.T, th defer th.TearDown() th.App.Srv().SetLicense(model.NewTestLicense("")) - th.App.SetPhase2PermissionsMigrationStatus(true) + err := th.App.SetPhase2PermissionsMigrationStatus(true) + require.NoError(t, err) permissionsDefault := []string{ model.PermissionManageChannelRoles.Id, @@ -89,41 +90,53 @@ func testPermissionInheritance(t *testing.T, testCallback func(t *testing.T, th } // Defer resetting the system scheme permissions - systemSchemeRoles, err := th.App.GetRolesByNames([]string{ + systemSchemeRoles, appErr := th.App.GetRolesByNames([]string{ model.ChannelGuestRoleId, model.ChannelUserRoleId, model.ChannelAdminRoleId, }) - require.Nil(t, err) + require.Nil(t, appErr) require.Len(t, systemSchemeRoles, 3) // defer resetting the system role permissions for _, systemRole := range systemSchemeRoles { - defer th.App.PatchRole(systemRole, &model.RolePatch{ - Permissions: &systemRole.Permissions, - }) + defer func() { + _, appErr = th.App.PatchRole(systemRole, &model.RolePatch{ + Permissions: &systemRole.Permissions, + }) + require.Nil(t, appErr) + }() } // Make a channel scheme, clear its permissions - channelScheme, err := th.App.CreateScheme(&model.Scheme{ + channelScheme, appErr := th.App.CreateScheme(&model.Scheme{ Name: model.NewId(), DisplayName: model.NewId(), Scope: model.SchemeScopeChannel, }) - require.Nil(t, err) - defer th.App.DeleteScheme(channelScheme.Id) + require.Nil(t, appErr) + defer func() { + _, appErr = th.App.DeleteScheme(channelScheme.Id) + require.Nil(t, appErr) + }() team := th.CreateTeam() - defer th.App.PermanentDeleteTeamId(th.Context, team.Id) + defer func() { + appErr = th.App.PermanentDeleteTeamId(th.Context, team.Id) + require.Nil(t, appErr) + }() // Make a channel channel := th.CreateChannel(th.Context, team) - defer th.App.PermanentDeleteChannel(th.Context, channel) + defer func() { + appErr = th.App.PermanentDeleteChannel(th.Context, channel) + require.Nil(t, appErr) + }() // Set the channel scheme channel.SchemeId = &channelScheme.Id - channel, err = th.App.UpdateChannelScheme(th.Context, channel) - require.Nil(t, err) + channel, appErr = th.App.UpdateChannelScheme(th.Context, channel) + require.Nil(t, appErr) // Get the truth table from CSV file, e := os.Open("tests/channel-role-has-permission.csv") @@ -225,18 +238,21 @@ func testPermissionInheritance(t *testing.T, testCallback func(t *testing.T, th test(model.ChannelGuestRoleId, model.ChannelUserRoleId, model.ChannelAdminRoleId) // create a team scheme - teamScheme, err := th.App.CreateScheme(&model.Scheme{ + teamScheme, appErr := th.App.CreateScheme(&model.Scheme{ Name: model.NewId(), DisplayName: model.NewId(), Scope: model.SchemeScopeTeam, }) - require.Nil(t, err) - defer th.App.DeleteScheme(teamScheme.Id) + require.Nil(t, appErr) + defer func() { + _, appErr = th.App.DeleteScheme(teamScheme.Id) + require.Nil(t, appErr) + }() // assign the scheme to the team team.SchemeId = &teamScheme.Id - _, err = th.App.UpdateTeamScheme(team) - require.Nil(t, err) + _, appErr = th.App.UpdateTeamScheme(team) + require.Nil(t, appErr) // test 24 combinations where the higher-scoped scheme is a TEAM scheme test(teamScheme.DefaultChannelGuestRole, teamScheme.DefaultChannelUserRole, teamScheme.DefaultChannelAdminRole)