MM-68352 - update permission policy ff correctly checks in tests (#36142)

This commit is contained in:
Pablo Vélez
2026-04-16 15:34:42 +02:00
committed by GitHub
parent 49f3c74737
commit a21e25e415
3 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -996,7 +996,9 @@ func TestFilterFilesByChannelPermissions(t *testing.T) {
func TestFilterFilesByChannelPermissions_ABAC(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic(t)
th := SetupConfig(t, func(cfg *model.Config) {
cfg.FeatureFlags.PermissionPolicies = true
}).InitBasic(t)
post := th.CreatePost(t, th.BasicChannel)
+1 -1
View File
@@ -204,7 +204,7 @@ func (h *permalinkBroadcastHook) Process(msg *platform.HookedWebSocketEvent, web
(len(permalinkPreviewedPost.Post.FileIds) > 0 ||
(permalinkPreviewedPost.Post.Metadata != nil && len(permalinkPreviewedPost.Post.Metadata.Files) > 0)) {
session := webConn.GetSession()
if session != nil && webConn.Platform.Config().FeatureFlags.PermissionPolicies {
if session != nil {
rctxWithSession := rctx.WithSession(session)
if !webConn.Suite.HasPermissionToFileAction(rctxWithSession, webConn.UserId, session.Roles, permalinkPreviewedPost.Post.ChannelId, model.AccessControlPolicyActionDownloadFileAttachment) {
postCopy := permalinkPreviewedPost.Post.Clone()
@@ -634,9 +634,9 @@ func TestPermalinkBroadcastHook_AbacFileStripping(t *testing.T) {
gotJSON, _ := msg.Get("post").(string)
assert.NotContains(t, gotJSON, fileID, "file ID should be cleared")
// RedactedFileCount is 0 because Files was nil (len(nil) == 0).
// With JSON omitempty, a zero value is omitted from the output.
assert.NotContains(t, gotJSON, `"redacted_file_count"`, "zero redacted count is omitted by omitempty")
// RedactedFileCount falls back to len(FileIds) when Metadata.Files is nil,
// so the placeholder count is 1 even though Files was already cleared upstream.
assert.Contains(t, gotJSON, `"redacted_file_count":1`, "file count falls back to FileIds length")
})
t.Run("no file stripping when embed has no files", func(t *testing.T) {