Doug Lauder
2023-03-22 17:22:27 -04:00
коммит произвёл GitHub
родитель b61c096497
Коммит c943ed6859
13276 изменённых файлов: 1695615 добавлений и 223189 удалений

28
e2e/playwright/support/server/channel.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,28 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {getRandomId} from '@e2e-support/util';
import {Channel, ChannelType} from '@mattermost/types/channels';
export function createRandomChannel(
teamId: string,
name: string,
displayName: string,
type: ChannelType = 'O',
purpose = '',
header = '',
unique = true
): Channel {
const randomSuffix = getRandomId();
const channel = {
team_id: teamId,
name: unique ? `${name}-${randomSuffix}` : name,
display_name: unique ? `${displayName} ${randomSuffix}` : displayName,
type,
purpose,
header,
};
return channel as Channel;
}

213
e2e/playwright/support/server/client.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,213 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// This is based on "packages/client/src/client4.ts". Modified for node client.
// Update should be made in comparison with the base Client4.
import fs from 'node:fs';
import path from 'node:path';
import FormData from 'form-data';
import 'isomorphic-unfetch';
import testConfig from '@e2e-test.config';
import Client4 from '@mattermost/client/client4';
import {Options, StatusOK} from '@mattermost/types/client4';
import {License} from '@mattermost/types/config';
import {CustomEmoji} from '@mattermost/types/emojis';
import {PluginManifest} from '@mattermost/types/plugins';
import {UserProfile} from '@mattermost/types/users';
export default class Client extends Client4 {
getFormDataOptions = (formData: FormData): Options => {
return {
method: 'post',
body: formData,
headers: {
'Content-Type': `multipart/form-data; boundary=${formData.getBoundary()}`,
},
};
};
uploadProfileImageX = (userId: string, filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('image', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getUserRoute(userId)}/image`, options);
};
setTeamIconX = (teamId: string, filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('image', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getTeamRoute(teamId)}/image`, options);
};
createCustomEmojiX = (emoji: CustomEmoji, filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('image', fileData, path.basename(filePath));
formData.append('emoji', JSON.stringify(emoji));
const options = this.getFormDataOptions(formData);
return this.doFetch<CustomEmoji>(`${this.getEmojisRoute()}`, options);
};
uploadBrandImageX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('image', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getBrandRoute()}/image`, options);
};
uploadPublicSamlCertificateX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('certificate', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getBaseRoute()}/saml/certificate/public`, options);
};
uploadPrivateSamlCertificateX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('certificate', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getBaseRoute()}/saml/certificate/private`, options);
};
uploadPublicLdapCertificateX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('certificate', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getBaseRoute()}/ldap/certificate/public`, options);
};
uploadPrivateLdapCertificateX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('certificate', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getBaseRoute()}/ldap/certificate/private`, options);
};
uploadIdpSamlCertificateX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('certificate', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<StatusOK>(`${this.getBaseRoute()}/saml/certificate/idp`, options);
};
uploadLicenseX = (filePath: string) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('license', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<License>(`${this.getBaseRoute()}/license`, options);
};
uploadPluginX = async (filePath: string, force = false) => {
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
if (force) {
formData.append('force', 'true');
}
formData.append('plugin', fileData, path.basename(filePath));
const options = this.getFormDataOptions(formData);
return this.doFetch<PluginManifest>(this.getPluginsRoute(), options);
};
// *****************************************************************************
// Boards client
// based on https://github.com/mattermost/focalboard/blob/main/webapp/src/octoClient.ts
// *****************************************************************************
async patchUserConfig(userID: string, patch: UserConfigPatch): Promise<UserPreference[] | undefined> {
const path = `/users/${encodeURIComponent(userID)}/config`;
const options = {
method: 'put',
body: JSON.stringify(patch),
};
return this.doFetch<UserPreference[]>(this.getBoardsRoute() + path, options);
}
}
// Variable to hold cache
const clients: Record<string, ClientCache> = {};
async function makeClient(userRequest?: UserRequest, useCache = true): Promise<ClientCache> {
const client = new Client();
client.setUrl(testConfig.baseURL);
try {
if (!userRequest) {
return {client, user: null};
}
const cacheKey = userRequest.username + userRequest.password;
if (useCache && clients[cacheKey] != null) {
return clients[cacheKey];
}
const userProfile = await client.login(userRequest.username, userRequest.password);
const user = {...userProfile, password: userRequest.password};
const config = await client.getClientConfigOld();
client.setUseBoardsProduct(config.FeatureFlagBoardsProduct === 'true');
if (useCache) {
clients[cacheKey] = {client, user};
}
return {client, user};
} catch (err) {
// log an error for debugging
// eslint-disable-next-line no-console
console.log('makeClient', err);
return {client, user: null};
}
}
// Client types
type UserRequest = {
username: string;
email?: string;
password: string;
};
type ClientCache = {
client: Client;
user: UserProfile | null;
};
// Boards types
interface UserPreference {
user_id: string;
category: string;
name: string;
value: any;
}
interface UserConfigPatch {
updatedFields?: Record<string, string>;
deletedFields?: string[];
}
export {Client, makeClient};

Просмотреть файл

@@ -0,0 +1,713 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import merge from 'deepmerge';
import {
AdminConfig,
ExperimentalSettings,
FeatureFlags,
PasswordSettings,
ServiceSettings,
TeamSettings,
PluginSettings,
ClusterSettings,
CollapsedThreads,
} from '@mattermost/types/config';
import testConfig from '@e2e-test.config';
export function getOnPremServerConfig(): AdminConfig {
return merge<AdminConfig>(defaultServerConfig, onPremServerConfig() as AdminConfig);
}
type TestAdminConfig = {
ClusterSettings: Partial<ClusterSettings>;
ExperimentalSettings: Partial<ExperimentalSettings>;
FeatureFlags: Partial<FeatureFlags>;
PasswordSettings: Partial<PasswordSettings>;
PluginSettings: Partial<PluginSettings>;
ServiceSettings: Partial<ServiceSettings>;
TeamSettings: Partial<TeamSettings>;
};
// On-prem setting that is different from the default
const onPremServerConfig = (): Partial<TestAdminConfig> => {
return {
ClusterSettings: {
Enable: testConfig.haClusterEnabled,
ClusterName: testConfig.haClusterName,
},
ExperimentalSettings: {
EnableAppBar: true,
},
FeatureFlags: {
BoardsProduct: testConfig.boardsProductEnabled,
},
PasswordSettings: {
MinimumLength: 5,
Lowercase: false,
Number: false,
Uppercase: false,
Symbol: false,
},
PluginSettings: {
EnableUploads: true,
Plugins: {
'com.mattermost.calls': {
defaultenabled: true,
},
},
PluginStates: {
focalboard: {
Enable: !testConfig.boardsProductEnabled,
},
},
},
ServiceSettings: {
SiteURL: testConfig.baseURL,
EnableOnboardingFlow: false,
},
TeamSettings: {
EnableOpenServer: true,
},
};
};
// Should be based only from the generated default config from mattermost-server via "make config-reset"
// Based on v7.9 server
const defaultServerConfig: AdminConfig = {
ServiceSettings: {
SiteURL: '',
WebsocketURL: '',
LicenseFileLocation: '',
ListenAddress: ':8065',
ConnectionSecurity: '',
TLSCertFile: '',
TLSKeyFile: '',
TLSMinVer: '1.2',
TLSStrictTransport: false,
TLSStrictTransportMaxAge: 63072000,
TLSOverwriteCiphers: [],
UseLetsEncrypt: false,
LetsEncryptCertificateCacheFile: './config/letsencrypt.cache',
Forward80To443: false,
TrustedProxyIPHeader: [],
ReadTimeout: 300,
WriteTimeout: 300,
IdleTimeout: 60,
MaximumLoginAttempts: 10,
GoroutineHealthThreshold: -1,
EnableOAuthServiceProvider: true,
EnableIncomingWebhooks: true,
EnableOutgoingWebhooks: true,
EnableCommands: true,
EnablePostUsernameOverride: false,
EnablePostIconOverride: false,
GoogleDeveloperKey: '',
EnableLinkPreviews: true,
EnablePermalinkPreviews: true,
RestrictLinkPreviews: '',
EnableTesting: false,
EnableDeveloper: false,
DeveloperFlags: '',
EnableClientPerformanceDebugging: false,
EnableOpenTracing: false,
EnableSecurityFixAlert: true,
EnableInsecureOutgoingConnections: false,
AllowedUntrustedInternalConnections: '',
EnableMultifactorAuthentication: false,
EnforceMultifactorAuthentication: false,
EnableUserAccessTokens: false,
AllowCorsFrom: '',
CorsExposedHeaders: '',
CorsAllowCredentials: false,
CorsDebug: false,
AllowCookiesForSubdomains: false,
ExtendSessionLengthWithActivity: true,
SessionLengthWebInDays: 30,
SessionLengthWebInHours: 720,
SessionLengthMobileInDays: 30,
SessionLengthMobileInHours: 720,
SessionLengthSSOInDays: 30,
SessionLengthSSOInHours: 720,
SessionCacheInMinutes: 10,
SessionIdleTimeoutInMinutes: 43200,
WebsocketSecurePort: 443,
WebsocketPort: 80,
WebserverMode: 'gzip',
EnableGifPicker: true,
GfycatAPIKey: '2_KtH_W5',
GfycatAPISecret: '3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof',
EnableCustomEmoji: true,
EnableEmojiPicker: true,
PostEditTimeLimit: -1,
TimeBetweenUserTypingUpdatesMilliseconds: 5000,
EnablePostSearch: true,
EnableFileSearch: true,
MinimumHashtagLength: 3,
EnableUserTypingMessages: true,
EnableChannelViewedMessages: true,
EnableUserStatuses: true,
ExperimentalEnableAuthenticationTransfer: true,
ClusterLogTimeoutMilliseconds: 2000,
EnablePreviewFeatures: true,
EnableTutorial: true,
EnableOnboardingFlow: true,
ExperimentalEnableDefaultChannelLeaveJoinMessages: true,
ExperimentalGroupUnreadChannels: 'disabled',
EnableAPITeamDeletion: false,
EnableAPITriggerAdminNotifications: false,
EnableAPIUserDeletion: false,
ExperimentalEnableHardenedMode: false,
ExperimentalStrictCSRFEnforcement: false,
EnableEmailInvitations: false,
DisableBotsWhenOwnerIsDeactivated: true,
EnableBotAccountCreation: false,
EnableSVGs: false,
EnableLatex: false,
EnableInlineLatex: true,
PostPriority: true,
EnableAPIChannelDeletion: false,
EnableLocalMode: false,
LocalModeSocketLocation: '/var/tmp/mattermost_local.socket',
EnableAWSMetering: false,
SplitKey: '',
FeatureFlagSyncIntervalSeconds: 30,
DebugSplit: false,
ThreadAutoFollow: true,
CollapsedThreads: CollapsedThreads.ALWAYS_ON,
ManagedResourcePaths: '',
EnableCustomGroups: true,
SelfHostedPurchase: true,
AllowSyncedDrafts: true,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
SelfHostedExpansion: false,
},
TeamSettings: {
SiteName: 'Mattermost',
MaxUsersPerTeam: 50,
EnableUserCreation: true,
EnableOpenServer: false,
EnableUserDeactivation: false,
RestrictCreationToDomains: '',
EnableCustomUserStatuses: true,
EnableCustomBrand: false,
CustomBrandText: '',
CustomDescriptionText: '',
RestrictDirectMessage: 'any',
EnableLastActiveTime: true,
UserStatusAwayTimeout: 300,
MaxChannelsPerTeam: 2000,
MaxNotificationsPerChannel: 1000,
EnableConfirmNotificationsToChannel: true,
TeammateNameDisplay: 'username',
ExperimentalViewArchivedChannels: true,
ExperimentalEnableAutomaticReplies: false,
LockTeammateNameDisplay: false,
ExperimentalPrimaryTeam: '',
ExperimentalDefaultChannels: [],
},
ClientRequirements: {
AndroidLatestVersion: '',
AndroidMinVersion: '',
IosLatestVersion: '',
IosMinVersion: '',
},
SqlSettings: {
DriverName: 'postgres',
DataSource:
'postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable\u0026connect_timeout=10\u0026binary_parameters=yes',
DataSourceReplicas: [],
DataSourceSearchReplicas: [],
MaxIdleConns: 20,
ConnMaxLifetimeMilliseconds: 3600000,
ConnMaxIdleTimeMilliseconds: 300000,
MaxOpenConns: 300,
Trace: false,
AtRestEncryptKey: '',
QueryTimeout: 30,
DisableDatabaseSearch: false,
MigrationsStatementTimeoutSeconds: 100000,
ReplicaLagSettings: [],
},
LogSettings: {
EnableConsole: true,
ConsoleLevel: 'DEBUG',
ConsoleJson: true,
EnableColor: false,
EnableFile: true,
FileLevel: 'INFO',
FileJson: true,
FileLocation: '',
EnableWebhookDebugging: true,
EnableDiagnostics: true,
VerboseDiagnostics: false,
EnableSentry: true,
AdvancedLoggingConfig: '',
},
ExperimentalAuditSettings: {
FileEnabled: false,
FileName: '',
FileMaxSizeMB: 100,
FileMaxAgeDays: 0,
FileMaxBackups: 0,
FileCompress: false,
FileMaxQueueSize: 1000,
AdvancedLoggingConfig: '',
},
NotificationLogSettings: {
EnableConsole: true,
ConsoleLevel: 'DEBUG',
ConsoleJson: true,
EnableColor: false,
EnableFile: true,
FileLevel: 'INFO',
FileJson: true,
FileLocation: '',
AdvancedLoggingConfig: '',
},
PasswordSettings: {
MinimumLength: 8,
Lowercase: false,
Number: false,
Uppercase: false,
Symbol: false,
},
FileSettings: {
EnableFileAttachments: true,
EnableMobileUpload: true,
EnableMobileDownload: true,
MaxFileSize: 104857600,
MaxImageResolution: 33177600,
MaxImageDecoderConcurrency: -1,
DriverName: 'local',
Directory: './data/',
EnablePublicLink: false,
ExtractContent: true,
ArchiveRecursion: false,
PublicLinkSalt: '',
InitialFont: 'nunito-bold.ttf',
AmazonS3AccessKeyId: '',
AmazonS3SecretAccessKey: '',
AmazonS3Bucket: '',
AmazonS3PathPrefix: '',
AmazonS3Region: '',
AmazonS3Endpoint: 's3.amazonaws.com',
AmazonS3SSL: true,
AmazonS3SignV2: false,
AmazonS3SSE: false,
AmazonS3Trace: false,
AmazonS3RequestTimeoutMilliseconds: 30000,
},
EmailSettings: {
EnableSignUpWithEmail: true,
EnableSignInWithEmail: true,
EnableSignInWithUsername: true,
SendEmailNotifications: true,
UseChannelInEmailNotifications: false,
RequireEmailVerification: false,
FeedbackName: '',
FeedbackEmail: 'test@example.com',
ReplyToAddress: 'test@example.com',
FeedbackOrganization: '',
EnableSMTPAuth: false,
SMTPUsername: '',
SMTPPassword: '',
SMTPServer: 'localhost',
SMTPPort: '10025',
SMTPServerTimeout: 10,
ConnectionSecurity: '',
SendPushNotifications: true,
PushNotificationServer: 'https://push-test.mattermost.com',
PushNotificationContents: 'full',
PushNotificationBuffer: 1000,
EnableEmailBatching: false,
EmailBatchingBufferSize: 256,
EmailBatchingInterval: 30,
EnablePreviewModeBanner: true,
SkipServerCertificateVerification: false,
EmailNotificationContentsType: 'full',
LoginButtonColor: '#0000',
LoginButtonBorderColor: '#2389D7',
LoginButtonTextColor: '#2389D7',
EnableInactivityEmail: true,
},
RateLimitSettings: {
Enable: false,
PerSec: 10,
MaxBurst: 100,
MemoryStoreSize: 10000,
VaryByRemoteAddr: true,
VaryByUser: false,
VaryByHeader: '',
},
PrivacySettings: {
ShowEmailAddress: true,
ShowFullName: true,
},
SupportSettings: {
TermsOfServiceLink: 'https://mattermost.com/terms-of-use/',
PrivacyPolicyLink: 'https://mattermost.com/privacy-policy/',
AboutLink: 'https://docs.mattermost.com/about/product.html/',
HelpLink: 'https://mattermost.com/default-help/',
ReportAProblemLink: 'https://mattermost.com/default-report-a-problem/',
SupportEmail: '',
CustomTermsOfServiceEnabled: false,
CustomTermsOfServiceReAcceptancePeriod: 365,
EnableAskCommunityLink: true,
},
AnnouncementSettings: {
EnableBanner: false,
BannerText: '',
BannerColor: '#f2a93b',
BannerTextColor: '#333333',
AllowBannerDismissal: true,
AdminNoticesEnabled: true,
UserNoticesEnabled: true,
NoticesURL: 'https://notices.mattermost.com/',
NoticesFetchFrequency: 3600,
NoticesSkipCache: false,
},
ThemeSettings: {
EnableThemeSelection: true,
DefaultTheme: 'default',
AllowCustomThemes: true,
AllowedThemes: [],
},
GitLabSettings: {
Enable: false,
Secret: '',
Id: '',
Scope: '',
AuthEndpoint: '',
TokenEndpoint: '',
UserAPIEndpoint: '',
DiscoveryEndpoint: '',
ButtonText: '',
ButtonColor: '',
},
GoogleSettings: {
Enable: false,
Secret: '',
Id: '',
Scope: 'profile email',
AuthEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
TokenEndpoint: 'https://www.googleapis.com/oauth2/v4/token',
UserAPIEndpoint:
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata',
DiscoveryEndpoint: '',
ButtonText: '',
ButtonColor: '',
},
Office365Settings: {
Enable: false,
Secret: '',
Id: '',
Scope: 'User.Read',
AuthEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
TokenEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
UserAPIEndpoint: 'https://graph.microsoft.com/v1.0/me',
DiscoveryEndpoint: '',
DirectoryId: '',
},
OpenIdSettings: {
Enable: false,
Secret: '',
Id: '',
Scope: 'profile openid email',
AuthEndpoint: '',
TokenEndpoint: '',
UserAPIEndpoint: '',
DiscoveryEndpoint: '',
ButtonText: '',
ButtonColor: '#145DBF',
},
LdapSettings: {
Enable: false,
EnableSync: false,
LdapServer: '',
LdapPort: 389,
ConnectionSecurity: '',
BaseDN: '',
BindUsername: '',
BindPassword: '',
UserFilter: '',
GroupFilter: '',
GuestFilter: '',
EnableAdminFilter: false,
AdminFilter: '',
GroupDisplayNameAttribute: '',
GroupIdAttribute: '',
FirstNameAttribute: '',
LastNameAttribute: '',
EmailAttribute: '',
UsernameAttribute: '',
NicknameAttribute: '',
IdAttribute: '',
PositionAttribute: '',
LoginIdAttribute: '',
PictureAttribute: '',
SyncIntervalMinutes: 60,
SkipCertificateVerification: false,
PublicCertificateFile: '',
PrivateKeyFile: '',
QueryTimeout: 60,
MaxPageSize: 0,
LoginFieldName: '',
LoginButtonColor: '#0000',
LoginButtonBorderColor: '#2389D7',
LoginButtonTextColor: '#2389D7',
Trace: false,
},
ComplianceSettings: {
Enable: false,
Directory: './data/',
EnableDaily: false,
BatchSize: 30000,
},
LocalizationSettings: {
DefaultServerLocale: 'en',
DefaultClientLocale: 'en',
AvailableLocales: '',
},
SamlSettings: {
Enable: false,
EnableSyncWithLdap: false,
EnableSyncWithLdapIncludeAuth: false,
IgnoreGuestsLdapSync: false,
Verify: true,
Encrypt: true,
SignRequest: false,
IdpURL: '',
IdpDescriptorURL: '',
IdpMetadataURL: '',
ServiceProviderIdentifier: '',
AssertionConsumerServiceURL: '',
SignatureAlgorithm: 'RSAwithSHA1',
CanonicalAlgorithm: 'Canonical1.0',
ScopingIDPProviderId: '',
ScopingIDPName: '',
IdpCertificateFile: '',
PublicCertificateFile: '',
PrivateKeyFile: '',
IdAttribute: '',
GuestAttribute: '',
EnableAdminAttribute: false,
AdminAttribute: '',
FirstNameAttribute: '',
LastNameAttribute: '',
EmailAttribute: '',
UsernameAttribute: '',
NicknameAttribute: '',
LocaleAttribute: '',
PositionAttribute: '',
LoginButtonText: 'SAML',
LoginButtonColor: '#34a28b',
LoginButtonBorderColor: '#2389D7',
LoginButtonTextColor: '#ffffff',
},
NativeAppSettings: {
AppCustomURLSchemes: ['mmauth://', 'mmauthbeta://'],
AppDownloadLink: 'https://mattermost.com/download/#mattermostApps',
AndroidAppDownloadLink: 'https://mattermost.com/mattermost-android-app/',
IosAppDownloadLink: 'https://mattermost.com/mattermost-ios-app/',
},
ClusterSettings: {
Enable: false,
ClusterName: '',
OverrideHostname: '',
NetworkInterface: '',
BindAddress: '',
AdvertiseAddress: '',
UseIPAddress: true,
EnableGossipCompression: true,
EnableExperimentalGossipEncryption: false,
ReadOnlyConfig: true,
GossipPort: 8074,
StreamingPort: 8075,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 128,
IdleConnTimeoutMilliseconds: 90000,
},
MetricsSettings: {
Enable: false,
BlockProfileRate: 0,
ListenAddress: ':8067',
},
ExperimentalSettings: {
ClientSideCertEnable: false,
ClientSideCertCheck: 'secondary',
LinkMetadataTimeoutMilliseconds: 5000,
RestrictSystemAdmin: false,
UseNewSAMLLibrary: false,
EnableSharedChannels: false,
EnableRemoteClusterService: false,
EnableAppBar: false,
PatchPluginsReactDOM: false,
},
AnalyticsSettings: {
MaxUsersForStatistics: 2500,
},
ElasticsearchSettings: {
ConnectionURL: 'http://localhost:9200',
Username: 'elastic',
Password: 'changeme',
EnableIndexing: false,
EnableSearching: false,
EnableAutocomplete: false,
Sniff: true,
PostIndexReplicas: 1,
PostIndexShards: 1,
ChannelIndexReplicas: 1,
ChannelIndexShards: 1,
UserIndexReplicas: 1,
UserIndexShards: 1,
AggregatePostsAfterDays: 365,
PostsAggregatorJobStartTime: '03:00',
IndexPrefix: '',
LiveIndexingBatchSize: 1,
BatchSize: 10000,
RequestTimeoutSeconds: 30,
SkipTLSVerification: false,
CA: '',
ClientCert: '',
ClientKey: '',
Trace: '',
},
BleveSettings: {
IndexDir: '',
EnableIndexing: false,
EnableSearching: false,
EnableAutocomplete: false,
BatchSize: 10000,
},
DataRetentionSettings: {
EnableMessageDeletion: false,
EnableFileDeletion: false,
EnableBoardsDeletion: false,
MessageRetentionDays: 365,
FileRetentionDays: 365,
BoardsRetentionDays: 365,
DeletionJobStartTime: '02:00',
BatchSize: 3000,
},
MessageExportSettings: {
EnableExport: false,
ExportFormat: 'actiance',
DailyRunTime: '01:00',
ExportFromTimestamp: 0,
BatchSize: 10000,
DownloadExportResults: false,
GlobalRelaySettings: {
CustomerType: 'A9',
SMTPUsername: '',
SMTPPassword: '',
EmailAddress: '',
SMTPServerTimeout: 1800,
},
},
JobSettings: {
RunJobs: true,
RunScheduler: true,
CleanupJobsThresholdDays: -1,
CleanupConfigThresholdDays: -1,
},
ProductSettings: {
EnablePublicSharedBoards: false,
},
PluginSettings: {
Enable: true,
EnableUploads: false,
AllowInsecureDownloadURL: false,
EnableHealthCheck: true,
Directory: './plugins',
ClientDirectory: './client/plugins',
Plugins: {},
PluginStates: {
'com.mattermost.apps': {
Enable: true,
},
'com.mattermost.calls': {
Enable: true,
},
'com.mattermost.nps': {
Enable: true,
},
focalboard: {
Enable: false,
},
playbooks: {
Enable: true,
},
},
EnableMarketplace: true,
EnableRemoteMarketplace: true,
AutomaticPrepackagedPlugins: true,
RequirePluginSignature: false,
MarketplaceURL: 'https://api.integrations.mattermost.com',
SignaturePublicKeyFiles: [],
ChimeraOAuthProxyURL: '',
},
DisplaySettings: {
CustomURLSchemes: [],
ExperimentalTimezone: true,
},
GuestAccountsSettings: {
Enable: false,
AllowEmailAccounts: true,
EnforceMultifactorAuthentication: false,
RestrictCreationToDomains: '',
},
ImageProxySettings: {
Enable: false,
ImageProxyType: 'local',
RemoteImageProxyURL: '',
RemoteImageProxyOptions: '',
},
CloudSettings: {
CWSURL: 'https://customers.mattermost.com',
CWSAPIURL: 'https://portal.internal.prod.cloud.mattermost.com',
},
FeatureFlags: {
TestFeature: 'off',
TestBoolFeature: false,
EnableRemoteClusterService: false,
AppsEnabled: true,
PluginPlaybooks: '',
PluginApps: '',
PluginFocalboard: '',
PluginCalls: '',
PermalinkPreviews: true,
CallsEnabled: true,
BoardsFeatureFlags: '',
BoardsDataRetention: false,
NormalizeLdapDNs: false,
EnableInactivityCheckJob: true,
UseCaseOnboarding: true,
GraphQL: false,
InsightsEnabled: true,
CommandPalette: false,
BoardsProduct: true,
SendWelcomePost: true,
WorkTemplate: false,
PostPriority: true,
WysiwygEditor: false,
PeopleProduct: false,
AnnualSubscription: false,
ReduceOnBoardingTaskList: false,
OnboardingAutoShowLinkedBoard: true,
ThreadsEverywhere: false,
GlobalDrafts: true,
OnboardingTourTips: true,
},
ImportSettings: {
Directory: './import',
RetentionDays: 30,
},
ExportSettings: {
Directory: './export',
RetentionDays: 30,
},
};

9
e2e/playwright/support/server/index.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export {Client, makeClient} from './client';
export {createRandomChannel} from './channel';
export {getOnPremServerConfig} from './default_config';
export {initSetup, getAdminClient} from './init';
export {createRandomTeam} from './team';
export {createRandomUser, getDefaultAdminUser} from './user';

100
e2e/playwright/support/server/init.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,100 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import path from 'node:path';
import {expect} from '@playwright/test';
import {PreferenceType} from '@mattermost/types/preferences';
import testConfig from '@e2e-test.config';
import {makeClient} from '.';
import {getOnPremServerConfig} from './default_config';
import {createRandomTeam} from './team';
import {createRandomUser} from './user';
const boardsUserConfigPatch = {
updatedFields: {
welcomePageViewed: '1',
onboardingTourStep: '999',
tourCategory: 'board',
version72MessageCanceled: 'true',
},
};
export async function initSetup({
userPrefix = 'user',
teamPrefix = {name: 'team', displayName: 'Team'},
withDefaultProfileImage = true,
skipBoardsUserConfig = true,
} = {}) {
try {
// Login the admin user via API
const {adminClient, adminUser} = await getAdminClient();
if (!adminClient) {
throw new Error(
"Failed to setup admin: Check that you're able to access the server using the same admin credential."
);
}
// Reset server config
const adminConfig = await adminClient.updateConfig(getOnPremServerConfig());
// Create new team
const team = await adminClient.createTeam(createRandomTeam(teamPrefix.name, teamPrefix.displayName));
// Create new user and add to newly created team
const randomUser = createRandomUser(userPrefix);
const user = await adminClient.createUser(randomUser, '', '');
user.password = randomUser.password;
await adminClient.addToTeam(team.id, user.id);
// Log in new user via API
const {client: userClient} = await makeClient(user);
if (withDefaultProfileImage) {
// Set user profile image
const fullPath = path.join(path.resolve(__dirname), '../', 'asset/mattermost-icon_128x128.png');
await userClient.uploadProfileImageX(user.id, fullPath);
}
// Update user preference
const preferences: PreferenceType[] = [
{user_id: user.id, category: 'tutorial_step', name: user.id, value: '999'},
];
await userClient.savePreferences(user.id, preferences);
if (skipBoardsUserConfig) {
await userClient.patchUserConfig(user.id, boardsUserConfigPatch);
}
return {
adminClient,
adminUser,
adminConfig,
user,
userClient,
team,
offTopicUrl: getUrl(team.name, 'off-topic'),
townSquareUrl: getUrl(team.name, 'town-square'),
};
} catch (err) {
// log an error for debugging
// eslint-disable-next-line no-console
console.log(err);
expect(err, 'Should not throw an error').toBeFalsy();
throw err;
}
}
export async function getAdminClient() {
const {client: adminClient, user: adminUser} = await makeClient({
username: testConfig.adminUsername,
password: testConfig.adminPassword,
});
return {adminClient, adminUser};
}
function getUrl(teamName: string, channelName: string) {
return `/${teamName}/channels/${channelName}`;
}

17
e2e/playwright/support/server/team.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,17 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Team, TeamType} from '@mattermost/types/teams';
import {getRandomId} from '@e2e-support/util';
export function createRandomTeam(name = 'team', displayName = 'Team', type: TeamType = 'O', unique = true): Team {
const randomSuffix = getRandomId();
const team = {
name: unique ? `${name}-${randomSuffix}` : name,
display_name: unique ? `${displayName} ${randomSuffix}` : displayName,
type,
};
return team as Team;
}

33
e2e/playwright/support/server/user.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,33 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {UserProfile} from '@mattermost/types/users';
import {getRandomId} from '@e2e-support/util';
import testConfig from '@e2e-test.config';
export function createRandomUser(prefix = 'user') {
const randomId = getRandomId();
const user = {
email: `${prefix}${randomId}@sample.mattermost.com`,
username: `${prefix}${randomId}`,
password: 'passwd',
first_name: `First${randomId}`,
last_name: `Last${randomId}`,
nickname: `Nickname${randomId}`,
};
return user as UserProfile;
}
export function getDefaultAdminUser() {
const admin = {
username: testConfig.adminUsername,
password: testConfig.adminPassword,
first_name: 'Kenneth',
last_name: 'Moreno',
email: testConfig.adminEmail,
};
return admin as UserProfile;
}