mattermost/server/config/client_test.go

697 lines
17 KiB
Go
Raw Permalink Normal View History

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package config
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/mattermost/mattermost/server/public/model"
)
func TestGetClientConfig(t *testing.T) {
t.Parallel()
testCases := []struct {
description string
config *model.Config
telemetryID string
license *model.License
expectedFields map[string]string
}{
{
"unlicensed",
&model.Config{
EmailSettings: model.EmailSettings{
EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull),
},
ThemeSettings: model.ThemeSettings{
// Ignored, since not licensed.
AllowCustomThemes: model.NewPointer(false),
},
ServiceSettings: model.ServiceSettings{
WebsocketURL: model.NewPointer("ws://mattermost.example.com:8065"),
WebsocketPort: model.NewPointer(80),
WebsocketSecurePort: model.NewPointer(443),
},
},
"",
nil,
map[string]string{
"DiagnosticId": "",
"EmailNotificationContentsType": "full",
"AllowCustomThemes": "true",
"EnforceMultifactorAuthentication": "false",
"WebsocketURL": "ws://mattermost.example.com:8065",
"WebsocketPort": "80",
"WebsocketSecurePort": "443",
},
},
{
"licensed, but not for theme management",
&model.Config{
EmailSettings: model.EmailSettings{
EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull),
},
ThemeSettings: model.ThemeSettings{
// Ignored, since not licensed.
AllowCustomThemes: model.NewPointer(false),
},
},
"tag1",
&model.License{
Features: &model.Features{
ThemeManagement: model.NewPointer(false),
},
},
map[string]string{
"DiagnosticId": "tag1",
"EmailNotificationContentsType": "full",
"AllowCustomThemes": "true",
},
},
{
"licensed for theme management",
&model.Config{
EmailSettings: model.EmailSettings{
EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull),
},
ThemeSettings: model.ThemeSettings{
AllowCustomThemes: model.NewPointer(false),
},
},
"tag2",
&model.License{
Features: &model.Features{
ThemeManagement: model.NewPointer(true),
},
},
map[string]string{
"DiagnosticId": "tag2",
"EmailNotificationContentsType": "full",
"AllowCustomThemes": "false",
},
},
{
"licensed for enforcement",
&model.Config{
ServiceSettings: model.ServiceSettings{
EnforceMultifactorAuthentication: model.NewPointer(true),
},
},
"tag1",
&model.License{
Features: &model.Features{
MFA: model.NewPointer(true),
},
},
map[string]string{
"EnforceMultifactorAuthentication": "true",
},
},
{
"default marketplace",
&model.Config{
PluginSettings: model.PluginSettings{
MarketplaceURL: model.NewPointer(model.PluginSettingsDefaultMarketplaceURL),
},
},
"tag1",
nil,
map[string]string{
"IsDefaultMarketplace": "true",
},
},
{
"non-default marketplace",
&model.Config{
PluginSettings: model.PluginSettings{
MarketplaceURL: model.NewPointer("http://example.com"),
},
},
"tag1",
nil,
map[string]string{
"IsDefaultMarketplace": "false",
},
},
2020-05-27 12:23:51 -04:00
{
"enable ShowFullName prop",
&model.Config{
PrivacySettings: model.PrivacySettings{
ShowFullName: model.NewPointer(true),
2020-05-27 12:23:51 -04:00
},
},
"tag1",
nil,
map[string]string{
"ShowFullName": "true",
},
},
Anonymous URLs (#35493) * COmposing messages with redacted URLs * Handled non member channels * Some refinements * Optimizations * lint fixes * cleaned up hasObfuscatedSlug test * Fixed a test * Added system console setting * WIP * fixed channel seelection double selection bug * LInt fixes * i18n fixes * fixed test * CI * renamed setting * lint fixes * lint fixes * WIP * Combined TeamSignupDisplayNamePage and TeamUrl component into a single CreateTeamForm component * Converted CreateTeamForm to functional component * Refactored to mnake code cleaner * Handle team creation with setting enabled * Skipped team URL step if secure URL feature is enabled * Managed button text and steps in team creation flow * lint fixes * Don't register team URL path when using secure URL * Display team display name instead of name in system console top nav bar * Fixed tests * Fixed coderabbit issues * Fixed type errors * Optimization * improvements * Handled API errors during team creation when using secure URL setting * Some refinements * Added test * Updaetd tests, and trimming when reading instead of writing * Added tests for new components * Added BackstageNavbar tests * Restored package lock * lint fix * Updaetd plugin API * Updated team creation tests * Added tests for ChannelNameFormField * Added plugin API tests * Updated API terst * Review fixes * Added test for ConvertGmToChannelModal component * Added EA license check for secure urls feature * restored package lock * Fixed GM conversion test * Fixed team creation tests * remove message composition changes * remove message composition changes * remove message composition changes * restored a file * lint fix * renamed feature * used model.SafeDereference * Added E2E tests * add secure URL Playwright coverage Expand the secure URLs Playwright coverage to validate creation, routing, rename flows, system console configuration, and search/navigation behavior while adding the page objects needed to keep the tests maintainable. Made-with: Cursor * rename secure URLs copy to anonymous URLs Align the admin console and Playwright coverage with the Anonymous URLs feature name while preserving the existing UseAnonymousURLs config behavior and validating the renamed test surfaces. Made-with: Cursor * Update team creation CTA for anonymous URLs Show Create in the single-step anonymous URL flow while preserving Next and Finish in the standard team creation flow. Update unit and Playwright coverage to match the revised create-team UX. Made-with: Cursor --------- Co-authored-by: maria.nunez <maria.nunez@mattermost.com> Co-authored-by: Mattermost Build <build@mattermost.com>
2026-03-12 10:32:29 -04:00
{
"enable UseAnonymousURLs prop",
&model.Config{
PrivacySettings: model.PrivacySettings{
UseAnonymousURLs: model.NewPointer(true),
},
},
"tag1",
nil,
map[string]string{
"UseAnonymousURLs": "true",
},
},
{
"Custom groups professional license",
&model.Config{},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuProfessional,
},
map[string]string{
"EnableCustomGroups": "true",
},
},
{
"Custom groups enterprise license",
&model.Config{},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterprise,
},
map[string]string{
"EnableCustomGroups": "true",
},
},
{
"Custom groups other license",
&model.Config{},
"",
&model.License{
Features: &model.Features{},
SkuShortName: "other",
},
map[string]string{
"EnableCustomGroups": "false",
},
},
{
"Shared channels other license",
&model.Config{
ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true),
},
},
"",
&model.License{
Features: &model.Features{
SharedChannels: model.NewPointer(false),
},
SkuShortName: "other",
},
map[string]string{
"ExperimentalSharedChannels": "false",
},
},
{
"licensed for shared channels",
&model.Config{
ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true),
},
},
"",
&model.License{
Features: &model.Features{
SharedChannels: model.NewPointer(true),
},
SkuShortName: "other",
},
map[string]string{
"ExperimentalSharedChannels": "true",
},
},
{
"Shared channels professional license",
&model.Config{
ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true),
},
},
"",
&model.License{
Features: &model.Features{
SharedChannels: model.NewPointer(false),
},
SkuShortName: model.LicenseShortSkuProfessional,
},
map[string]string{
"ExperimentalSharedChannels": "true",
},
},
{
"disable EnableUserStatuses",
&model.Config{
ServiceSettings: model.ServiceSettings{
EnableUserStatuses: model.NewPointer(false),
},
},
"",
nil,
map[string]string{
"EnableUserStatuses": "false",
},
},
{
"Shared channels enterprise license",
&model.Config{
ConnectedWorkspacesSettings: model.ConnectedWorkspacesSettings{
EnableSharedChannels: model.NewPointer(true),
},
},
"",
&model.License{
Features: &model.Features{
SharedChannels: model.NewPointer(false),
},
SkuShortName: model.LicenseShortSkuEnterprise,
},
map[string]string{
"ExperimentalSharedChannels": "true",
},
},
{
"Disable App Bar",
&model.Config{
ExperimentalSettings: model.ExperimentalSettings{
DisableAppBar: model.NewPointer(true),
},
},
"",
nil,
map[string]string{
"DisableAppBar": "true",
},
},
{
"default EnableJoinLeaveMessage",
&model.Config{},
"tag1",
nil,
map[string]string{
"EnableJoinLeaveMessageByDefault": "true",
},
},
{
"disable EnableJoinLeaveMessage",
&model.Config{
TeamSettings: model.TeamSettings{
EnableJoinLeaveMessageByDefault: model.NewPointer(false),
},
},
"tag1",
nil,
map[string]string{
"EnableJoinLeaveMessageByDefault": "false",
},
},
{
"test key for GiphySdkKey",
&model.Config{
ServiceSettings: model.ServiceSettings{
GiphySdkKey: model.NewPointer(""),
},
},
"",
nil,
map[string]string{
"GiphySdkKey": model.ServiceSettingsDefaultGiphySdkKeyTest,
},
},
{
"report a problem values",
&model.Config{
SupportSettings: model.SupportSettings{
ReportAProblemType: model.NewPointer("type"),
ReportAProblemLink: model.NewPointer("http://example.com"),
ReportAProblemMail: model.NewPointer("mail"),
AllowDownloadLogs: model.NewPointer(true),
},
},
"",
nil,
map[string]string{
"ReportAProblemType": "type",
"ReportAProblemLink": "http://example.com",
"ReportAProblemMail": "mail",
"AllowDownloadLogs": "true",
},
},
{
"access control settings enabled",
&model.Config{
AccessControlSettings: model.AccessControlSettings{
EnableAttributeBasedAccessControl: model.NewPointer(true),
EnableUserManagedAttributes: model.NewPointer(true),
},
},
"",
nil,
map[string]string{
"EnableAttributeBasedAccessControl": "true",
"EnableUserManagedAttributes": "true",
},
},
{
"access control settings disabled",
&model.Config{
AccessControlSettings: model.AccessControlSettings{
EnableAttributeBasedAccessControl: model.NewPointer(false),
EnableUserManagedAttributes: model.NewPointer(false),
},
},
"",
nil,
map[string]string{
"EnableAttributeBasedAccessControl": "false",
"EnableUserManagedAttributes": "false",
},
},
{
"access control settings default",
&model.Config{},
"",
nil,
map[string]string{
"EnableAttributeBasedAccessControl": "false",
"EnableUserManagedAttributes": "false",
},
},
{
"burn on read enabled",
&model.Config{
ServiceSettings: model.ServiceSettings{
EnableBurnOnRead: model.NewPointer(true),
[MM-61758] Burn on read feature (#34703) * Add read receipt store for burn on read message types * update mocks * fix invalidation target * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * add translations * Added logic to associate files of BoR post with the post * Added test * fixes * disable pinning posts and review comments * MM-66594 - Burn on read UI integration (#34647) * MM-66244 - add BoR visual components to message editor * MM-66246 - BoR visual indicator for sender and receiver * MM-66607 - bor - add timer countdown and autodeletion * add the system console max time to live config * use the max expire at and create global scheduler to register bor messages * use seconds for BoR config values in BE * implement the read by text shown in the tooltip logic * unestack the posts from same receiver and BoR and fix styling * avoid opening reply RHS * remove unused dispatchers * persis the BoR label in the drafts * move expiration value to metadata * adjust unit tests to metadata insted of props * code clean up and some performance improvements; add period grace for deletion too * adjust migration serie number * hide bor messages when config is off * performance improvements on post component and code clean up * keep bor existing post functionality if config is disabled * Add read receipt store for burn on read message types * Add temporary posts table * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * avoid reacting to unrevealed bor messages * adjust migration number * Add read receipt store for burn on read message types * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * adjust post reveal and type with backend changes * use real config values, adjust icon usage and style * adjust the delete from from sender and receiver * improve self deleting logic by placing in badge, use burn endpoint * adjust websocket events handling for the read by sender label information * adjust styling for concealed and error state * update burn-on-read post event handling for improved recipient tracking and multi-device sync * replace burn_on_read with type in database migrations and model * remove burn_on_read metadata from PostMetadata and related structures * Added logic to associate files of BoR post with the post * Added test * adjust migration name and fix linter * Add read receipt store for burn on read message types * update mocks * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * Added logic to associate files of BoR post with the post * Added test * disable pinning posts and review comments * show attachment on bor reveal * remove unused translation * Enhance burn-on-read post handling and refine previous post ID retrieval logic * adjust the returning chunk to work with bor messages * read temp post from master db * read from master * show the copy link button to the sender * revert unnecessary check * restore correct json tag * remove unused error handling and clarify burn-on-read comment * improve type safety and use proper selectors * eliminate code duplication in deletion handler * optimize performance and add documentation * delete bor message for sender once all receivers reveal it * add burn on read to scheduled posts * add feature enable check * use master to avoid all read recipients race condition --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> * squash migrations into single file * add configuration for the scheduler * don't run messagehasbeenposted hook * remove parallel tests on burn on read * add clean up for closing opened modals from previous tests * simplify delete menu item rendering * add cleanup step to close open modals after each test to prevent pollution * streamline delete button visibility logic for Burn on Read posts * improve reliability of closing post menu and modals by using body ESC key --------- Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Pablo Vélez <pablovv2012@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
2025-12-11 01:59:50 -05:00
BurnOnReadDurationSeconds: model.NewPointer(1800), // 30 minutes in seconds
},
},
"",
nil,
map[string]string{
"EnableBurnOnRead": "true",
[MM-61758] Burn on read feature (#34703) * Add read receipt store for burn on read message types * update mocks * fix invalidation target * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * add translations * Added logic to associate files of BoR post with the post * Added test * fixes * disable pinning posts and review comments * MM-66594 - Burn on read UI integration (#34647) * MM-66244 - add BoR visual components to message editor * MM-66246 - BoR visual indicator for sender and receiver * MM-66607 - bor - add timer countdown and autodeletion * add the system console max time to live config * use the max expire at and create global scheduler to register bor messages * use seconds for BoR config values in BE * implement the read by text shown in the tooltip logic * unestack the posts from same receiver and BoR and fix styling * avoid opening reply RHS * remove unused dispatchers * persis the BoR label in the drafts * move expiration value to metadata * adjust unit tests to metadata insted of props * code clean up and some performance improvements; add period grace for deletion too * adjust migration serie number * hide bor messages when config is off * performance improvements on post component and code clean up * keep bor existing post functionality if config is disabled * Add read receipt store for burn on read message types * Add temporary posts table * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * avoid reacting to unrevealed bor messages * adjust migration number * Add read receipt store for burn on read message types * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * adjust post reveal and type with backend changes * use real config values, adjust icon usage and style * adjust the delete from from sender and receiver * improve self deleting logic by placing in badge, use burn endpoint * adjust websocket events handling for the read by sender label information * adjust styling for concealed and error state * update burn-on-read post event handling for improved recipient tracking and multi-device sync * replace burn_on_read with type in database migrations and model * remove burn_on_read metadata from PostMetadata and related structures * Added logic to associate files of BoR post with the post * Added test * adjust migration name and fix linter * Add read receipt store for burn on read message types * update mocks * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * Added logic to associate files of BoR post with the post * Added test * disable pinning posts and review comments * show attachment on bor reveal * remove unused translation * Enhance burn-on-read post handling and refine previous post ID retrieval logic * adjust the returning chunk to work with bor messages * read temp post from master db * read from master * show the copy link button to the sender * revert unnecessary check * restore correct json tag * remove unused error handling and clarify burn-on-read comment * improve type safety and use proper selectors * eliminate code duplication in deletion handler * optimize performance and add documentation * delete bor message for sender once all receivers reveal it * add burn on read to scheduled posts * add feature enable check * use master to avoid all read recipients race condition --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> * squash migrations into single file * add configuration for the scheduler * don't run messagehasbeenposted hook * remove parallel tests on burn on read * add clean up for closing opened modals from previous tests * simplify delete menu item rendering * add cleanup step to close open modals after each test to prevent pollution * streamline delete button visibility logic for Burn on Read posts * improve reliability of closing post menu and modals by using body ESC key --------- Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Pablo Vélez <pablovv2012@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
2025-12-11 01:59:50 -05:00
"BurnOnReadDurationSeconds": "1800",
},
},
{
"burn on read disabled",
&model.Config{
ServiceSettings: model.ServiceSettings{
EnableBurnOnRead: model.NewPointer(false),
[MM-61758] Burn on read feature (#34703) * Add read receipt store for burn on read message types * update mocks * fix invalidation target * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * add translations * Added logic to associate files of BoR post with the post * Added test * fixes * disable pinning posts and review comments * MM-66594 - Burn on read UI integration (#34647) * MM-66244 - add BoR visual components to message editor * MM-66246 - BoR visual indicator for sender and receiver * MM-66607 - bor - add timer countdown and autodeletion * add the system console max time to live config * use the max expire at and create global scheduler to register bor messages * use seconds for BoR config values in BE * implement the read by text shown in the tooltip logic * unestack the posts from same receiver and BoR and fix styling * avoid opening reply RHS * remove unused dispatchers * persis the BoR label in the drafts * move expiration value to metadata * adjust unit tests to metadata insted of props * code clean up and some performance improvements; add period grace for deletion too * adjust migration serie number * hide bor messages when config is off * performance improvements on post component and code clean up * keep bor existing post functionality if config is disabled * Add read receipt store for burn on read message types * Add temporary posts table * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * avoid reacting to unrevealed bor messages * adjust migration number * Add read receipt store for burn on read message types * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * adjust post reveal and type with backend changes * use real config values, adjust icon usage and style * adjust the delete from from sender and receiver * improve self deleting logic by placing in badge, use burn endpoint * adjust websocket events handling for the read by sender label information * adjust styling for concealed and error state * update burn-on-read post event handling for improved recipient tracking and multi-device sync * replace burn_on_read with type in database migrations and model * remove burn_on_read metadata from PostMetadata and related structures * Added logic to associate files of BoR post with the post * Added test * adjust migration name and fix linter * Add read receipt store for burn on read message types * update mocks * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * Added logic to associate files of BoR post with the post * Added test * disable pinning posts and review comments * show attachment on bor reveal * remove unused translation * Enhance burn-on-read post handling and refine previous post ID retrieval logic * adjust the returning chunk to work with bor messages * read temp post from master db * read from master * show the copy link button to the sender * revert unnecessary check * restore correct json tag * remove unused error handling and clarify burn-on-read comment * improve type safety and use proper selectors * eliminate code duplication in deletion handler * optimize performance and add documentation * delete bor message for sender once all receivers reveal it * add burn on read to scheduled posts * add feature enable check * use master to avoid all read recipients race condition --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> * squash migrations into single file * add configuration for the scheduler * don't run messagehasbeenposted hook * remove parallel tests on burn on read * add clean up for closing opened modals from previous tests * simplify delete menu item rendering * add cleanup step to close open modals after each test to prevent pollution * streamline delete button visibility logic for Burn on Read posts * improve reliability of closing post menu and modals by using body ESC key --------- Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Pablo Vélez <pablovv2012@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
2025-12-11 01:59:50 -05:00
BurnOnReadDurationSeconds: model.NewPointer(600), // 10 minutes in seconds
},
},
"",
nil,
map[string]string{
"EnableBurnOnRead": "false",
[MM-61758] Burn on read feature (#34703) * Add read receipt store for burn on read message types * update mocks * fix invalidation target * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * add translations * Added logic to associate files of BoR post with the post * Added test * fixes * disable pinning posts and review comments * MM-66594 - Burn on read UI integration (#34647) * MM-66244 - add BoR visual components to message editor * MM-66246 - BoR visual indicator for sender and receiver * MM-66607 - bor - add timer countdown and autodeletion * add the system console max time to live config * use the max expire at and create global scheduler to register bor messages * use seconds for BoR config values in BE * implement the read by text shown in the tooltip logic * unestack the posts from same receiver and BoR and fix styling * avoid opening reply RHS * remove unused dispatchers * persis the BoR label in the drafts * move expiration value to metadata * adjust unit tests to metadata insted of props * code clean up and some performance improvements; add period grace for deletion too * adjust migration serie number * hide bor messages when config is off * performance improvements on post component and code clean up * keep bor existing post functionality if config is disabled * Add read receipt store for burn on read message types * Add temporary posts table * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * avoid reacting to unrevealed bor messages * adjust migration number * Add read receipt store for burn on read message types * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * adjust post reveal and type with backend changes * use real config values, adjust icon usage and style * adjust the delete from from sender and receiver * improve self deleting logic by placing in badge, use burn endpoint * adjust websocket events handling for the read by sender label information * adjust styling for concealed and error state * update burn-on-read post event handling for improved recipient tracking and multi-device sync * replace burn_on_read with type in database migrations and model * remove burn_on_read metadata from PostMetadata and related structures * Added logic to associate files of BoR post with the post * Added test * adjust migration name and fix linter * Add read receipt store for burn on read message types * update mocks * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * Added logic to associate files of BoR post with the post * Added test * disable pinning posts and review comments * show attachment on bor reveal * remove unused translation * Enhance burn-on-read post handling and refine previous post ID retrieval logic * adjust the returning chunk to work with bor messages * read temp post from master db * read from master * show the copy link button to the sender * revert unnecessary check * restore correct json tag * remove unused error handling and clarify burn-on-read comment * improve type safety and use proper selectors * eliminate code duplication in deletion handler * optimize performance and add documentation * delete bor message for sender once all receivers reveal it * add burn on read to scheduled posts * add feature enable check * use master to avoid all read recipients race condition --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> * squash migrations into single file * add configuration for the scheduler * don't run messagehasbeenposted hook * remove parallel tests on burn on read * add clean up for closing opened modals from previous tests * simplify delete menu item rendering * add cleanup step to close open modals after each test to prevent pollution * streamline delete button visibility logic for Burn on Read posts * improve reliability of closing post menu and modals by using body ESC key --------- Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Pablo Vélez <pablovv2012@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
2025-12-11 01:59:50 -05:00
"BurnOnReadDurationSeconds": "600",
},
},
{
"burn on read default",
&model.Config{},
"",
nil,
map[string]string{
"EnableBurnOnRead": "true",
[MM-61758] Burn on read feature (#34703) * Add read receipt store for burn on read message types * update mocks * fix invalidation target * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * add translations * Added logic to associate files of BoR post with the post * Added test * fixes * disable pinning posts and review comments * MM-66594 - Burn on read UI integration (#34647) * MM-66244 - add BoR visual components to message editor * MM-66246 - BoR visual indicator for sender and receiver * MM-66607 - bor - add timer countdown and autodeletion * add the system console max time to live config * use the max expire at and create global scheduler to register bor messages * use seconds for BoR config values in BE * implement the read by text shown in the tooltip logic * unestack the posts from same receiver and BoR and fix styling * avoid opening reply RHS * remove unused dispatchers * persis the BoR label in the drafts * move expiration value to metadata * adjust unit tests to metadata insted of props * code clean up and some performance improvements; add period grace for deletion too * adjust migration serie number * hide bor messages when config is off * performance improvements on post component and code clean up * keep bor existing post functionality if config is disabled * Add read receipt store for burn on read message types * Add temporary posts table * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * avoid reacting to unrevealed bor messages * adjust migration number * Add read receipt store for burn on read message types * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * adjust post reveal and type with backend changes * use real config values, adjust icon usage and style * adjust the delete from from sender and receiver * improve self deleting logic by placing in badge, use burn endpoint * adjust websocket events handling for the read by sender label information * adjust styling for concealed and error state * update burn-on-read post event handling for improved recipient tracking and multi-device sync * replace burn_on_read with type in database migrations and model * remove burn_on_read metadata from PostMetadata and related structures * Added logic to associate files of BoR post with the post * Added test * adjust migration name and fix linter * Add read receipt store for burn on read message types * update mocks * have consistent case on index creation * Add temporary posts table * add mock * add transaction support * reflect review comments * wip: Add reveal endpoint * user check error id instead * wip: Add ws events and cleanup for burn on read posts * add burn endpoint for explicitly burning messages * Added logic to associate files of BoR post with the post * Added test * disable pinning posts and review comments * show attachment on bor reveal * remove unused translation * Enhance burn-on-read post handling and refine previous post ID retrieval logic * adjust the returning chunk to work with bor messages * read temp post from master db * read from master * show the copy link button to the sender * revert unnecessary check * restore correct json tag * remove unused error handling and clarify burn-on-read comment * improve type safety and use proper selectors * eliminate code duplication in deletion handler * optimize performance and add documentation * delete bor message for sender once all receivers reveal it * add burn on read to scheduled posts * add feature enable check * use master to avoid all read recipients race condition --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> * squash migrations into single file * add configuration for the scheduler * don't run messagehasbeenposted hook * remove parallel tests on burn on read * add clean up for closing opened modals from previous tests * simplify delete menu item rendering * add cleanup step to close open modals after each test to prevent pollution * streamline delete button visibility logic for Burn on Read posts * improve reliability of closing post menu and modals by using body ESC key --------- Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com> Co-authored-by: Pablo Vélez <pablovv2012@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
2025-12-11 01:59:50 -05:00
"BurnOnReadDurationSeconds": "600", // 10 minutes in seconds
},
},
{
"Intune MAM enabled with Enterprise Advanced license and Office365 AuthService",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(model.ServiceOffice365),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterpriseAdvanced,
},
map[string]string{
"IntuneMAMEnabled": "true",
"IntuneScope": "api://87654321-4321-4321-4321-210987654321/login.mattermost",
},
},
{
"Intune MAM disabled when not enabled",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(false),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(model.ServiceOffice365),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterpriseAdvanced,
},
map[string]string{
"IntuneMAMEnabled": "false",
},
},
{
"Intune MAM disabled when TenantId is missing",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer(""),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(model.ServiceOffice365),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterpriseAdvanced,
},
map[string]string{
"IntuneMAMEnabled": "false",
},
},
{
"Intune MAM disabled when ClientId is missing",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer(""),
AuthService: model.NewPointer(model.ServiceOffice365),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterpriseAdvanced,
},
map[string]string{
"IntuneMAMEnabled": "false",
},
},
{
"Intune MAM not exposed with lower license tier",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(model.ServiceOffice365),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuProfessional,
},
map[string]string{},
},
{
"Intune MAM not exposed without license",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(model.ServiceOffice365),
},
},
"",
nil,
map[string]string{},
},
{
"Intune MAM enabled with Enterprise Advanced license and SAML AuthService",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(model.UserAuthServiceSaml),
},
SamlSettings: model.SamlSettings{
Enable: model.NewPointer(true),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterpriseAdvanced,
},
map[string]string{
"IntuneMAMEnabled": "true",
"IntuneScope": "api://87654321-4321-4321-4321-210987654321/login.mattermost",
"IntuneAuthService": "saml",
},
},
{
"Intune MAM disabled when AuthService is missing",
&model.Config{
IntuneSettings: model.IntuneSettings{
Enable: model.NewPointer(true),
TenantId: model.NewPointer("12345678-1234-1234-1234-123456789012"),
ClientId: model.NewPointer("87654321-4321-4321-4321-210987654321"),
AuthService: model.NewPointer(""),
},
},
"",
&model.License{
Features: &model.Features{},
SkuShortName: model.LicenseShortSkuEnterpriseAdvanced,
},
map[string]string{
"IntuneMAMEnabled": "false",
},
},
}
for _, testCase := range testCases {
t.Run(testCase.description, func(t *testing.T) {
t.Parallel()
testCase.config.SetDefaults()
if testCase.license != nil {
testCase.license.Features.SetDefaults()
}
configMap := GenerateClientConfig(testCase.config, testCase.telemetryID, testCase.license)
for expectedField, expectedValue := range testCase.expectedFields {
actualValue, ok := configMap[expectedField]
if assert.True(t, ok, fmt.Sprintf("config does not contain %v", expectedField)) {
assert.Equal(t, expectedValue, actualValue)
}
}
})
}
}
func TestGetLimitedClientConfig(t *testing.T) {
t.Parallel()
testCases := []struct {
description string
config *model.Config
telemetryID string
license *model.License
expectedFields map[string]string
}{
{
"unlicensed",
&model.Config{
EmailSettings: model.EmailSettings{
EmailNotificationContentsType: model.NewPointer(model.EmailNotificationContentsFull),
},
ThemeSettings: model.ThemeSettings{
// Ignored, since not licensed.
AllowCustomThemes: model.NewPointer(false),
},
ServiceSettings: model.ServiceSettings{
WebsocketURL: model.NewPointer("ws://mattermost.example.com:8065"),
WebsocketPort: model.NewPointer(80),
WebsocketSecurePort: model.NewPointer(443),
},
},
"",
nil,
map[string]string{
"DiagnosticId": "",
"EnforceMultifactorAuthentication": "false",
"WebsocketURL": "ws://mattermost.example.com:8065",
"WebsocketPort": "80",
"WebsocketSecurePort": "443",
},
},
{
"password settings",
&model.Config{
PasswordSettings: model.PasswordSettings{
MinimumLength: model.NewPointer(15),
Lowercase: model.NewPointer(true),
Uppercase: model.NewPointer(true),
Number: model.NewPointer(true),
Symbol: model.NewPointer(false),
},
},
"",
nil,
map[string]string{
"PasswordMinimumLength": "15",
"PasswordRequireLowercase": "true",
"PasswordRequireUppercase": "true",
"PasswordRequireNumber": "true",
"PasswordRequireSymbol": "false",
},
},
{
"Feature Flags",
&model.Config{
FeatureFlags: &model.FeatureFlags{
TestFeature: "myvalue",
},
},
"",
nil,
map[string]string{
"FeatureFlagTestFeature": "myvalue",
},
},
}
for _, testCase := range testCases {
t.Run(testCase.description, func(t *testing.T) {
t.Parallel()
testCase.config.SetDefaults()
if testCase.license != nil {
testCase.license.Features.SetDefaults()
}
configMap := GenerateLimitedClientConfig(testCase.config, testCase.telemetryID, testCase.license)
for expectedField, expectedValue := range testCase.expectedFields {
actualValue, ok := configMap[expectedField]
if assert.True(t, ok, fmt.Sprintf("config does not contain %v", expectedField)) {
assert.Equal(t, expectedValue, actualValue)
}
}
})
}
}