mirror of
https://github.com/mattermost/mattermost.git
synced 2026-10-30 22:55:29 +08:00
MM-68352 - update permission policy ff correctly checks in tests (#36142)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user