snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {expect, test} from '@mattermost/playwright-lib';
|
||||
|
||||
import {ensureUserAttributes} from '../support';
|
||||
|
||||
/**
|
||||
* Check whether the PermissionPolicies feature flag is enabled at runtime.
|
||||
* Returns true when the server exposes the permission_policies route.
|
||||
*/
|
||||
async function isPermissionPoliciesEnabled(adminClient: any): Promise<boolean> {
|
||||
const config = await adminClient.getConfig();
|
||||
return config.FeatureFlags?.PermissionPolicies === true || config.FeatureFlags?.PermissionPolicies === 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* ABAC Basic Operations - Enable/Disable
|
||||
* Tests basic ABAC system-wide enable/disable functionality
|
||||
*/
|
||||
|
||||
test('MM-T5782 System admin can enable or disable system-wide ABAC', async ({pw}) => {
|
||||
test.setTimeout(120000);
|
||||
|
||||
// # Skip test if no license for ABAC
|
||||
await pw.skipIfNoLicense();
|
||||
|
||||
// # Set up admin user and login
|
||||
const {adminUser, adminClient} = await pw.initSetup();
|
||||
|
||||
// # Ensure user attributes exist BEFORE logging in
|
||||
await ensureUserAttributes(adminClient);
|
||||
|
||||
// # Reset ABAC to disabled via API before testing the UI toggle.
|
||||
// Parallel tests may have already enabled it, which would leave the radio
|
||||
// pre-selected and the Save button permanently disabled (no dirty state).
|
||||
await adminClient.patchConfig({
|
||||
AccessControlSettings: {
|
||||
EnableAttributeBasedAccessControl: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
// # Now login - this ensures the UI will have the attributes loaded
|
||||
const {systemConsolePage} = await pw.testBrowser.login(adminUser);
|
||||
|
||||
// # Navigate to ABAC page
|
||||
await systemConsolePage.goto();
|
||||
await systemConsolePage.toBeVisible();
|
||||
await systemConsolePage.sidebar.systemAttributes.attributeBasedAccess.click();
|
||||
|
||||
// Re-apply the ABAC=false reset right before UI interaction: a concurrent
|
||||
// initSetup() on another shard may have re-enabled ABAC between the initial
|
||||
// patchConfig call above and here. If it's already enabled when we click
|
||||
// enableRadio the radio is a no-op and Save stays disabled.
|
||||
await adminClient.patchConfig({
|
||||
AccessControlSettings: {
|
||||
EnableAttributeBasedAccessControl: false,
|
||||
},
|
||||
} as any);
|
||||
await pw.waitUntil(async () => {
|
||||
const cfg = await adminClient.getConfig();
|
||||
return cfg.AccessControlSettings?.EnableAttributeBasedAccessControl === false;
|
||||
});
|
||||
await systemConsolePage.page.reload();
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
|
||||
// * Verify we're on the correct page
|
||||
const abacSection = systemConsolePage.page.getByTestId('sysconsole_section_AttributeBasedAccessControl');
|
||||
await expect(abacSection).toBeVisible();
|
||||
|
||||
const enableRadio = systemConsolePage.page.locator(
|
||||
'#AccessControlSettings\\.EnableAttributeBasedAccessControltrue',
|
||||
);
|
||||
const disableRadio = systemConsolePage.page.locator(
|
||||
'#AccessControlSettings\\.EnableAttributeBasedAccessControlfalse',
|
||||
);
|
||||
const saveButton = systemConsolePage.page.getByRole('button', {name: 'Save'});
|
||||
|
||||
// # Test enable ABAC
|
||||
await enableRadio.click();
|
||||
await expect(enableRadio).toBeChecked();
|
||||
await saveButton.click();
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
|
||||
// * Verify the Attribute-Based Access page only has the toggle — no policy management here
|
||||
await expect(systemConsolePage.page.getByRole('button', {name: 'Add policy'})).not.toBeVisible();
|
||||
|
||||
// * Verify Membership Policies page shows "Add policy" when ABAC is enabled
|
||||
// Re-apply enable guard: a concurrent shard may have disabled ABAC between the
|
||||
// save above and this navigation, which would cause a redirect to the license page.
|
||||
await adminClient.patchConfig({AccessControlSettings: {EnableAttributeBasedAccessControl: true}});
|
||||
await pw.waitUntil(async () => {
|
||||
const cfg = await adminClient.getConfig();
|
||||
return cfg.AccessControlSettings?.EnableAttributeBasedAccessControl === true;
|
||||
});
|
||||
await systemConsolePage.page.goto('/admin_console/system_attributes/membership_policies');
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
await expect(systemConsolePage.page.getByRole('button', {name: 'Add policy'})).toBeVisible();
|
||||
|
||||
// * Verify Permission Policies page shows "Add policy" when ABAC is enabled
|
||||
// This section is only testable when the PermissionPolicies feature flag is on.
|
||||
if (await isPermissionPoliciesEnabled(adminClient)) {
|
||||
await systemConsolePage.page.goto('/admin_console/system_attributes/permission_policies');
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
await expect(systemConsolePage.page.getByRole('button', {name: 'Add policy'})).toBeVisible();
|
||||
}
|
||||
|
||||
// # Navigate back to Attribute-Based Access to test disable
|
||||
await systemConsolePage.page.goto('/admin_console/system_attributes/attribute_based_access_control');
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
|
||||
// # Test disable ABAC
|
||||
await disableRadio.click();
|
||||
await expect(disableRadio).toBeChecked();
|
||||
await saveButton.click();
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
|
||||
// * Verify Membership Policies no longer shows "Add policy" when ABAC is disabled
|
||||
await systemConsolePage.page.goto('/admin_console/system_attributes/membership_policies');
|
||||
await systemConsolePage.page.waitForLoadState('networkidle');
|
||||
await expect(systemConsolePage.page.getByRole('button', {name: 'Add policy'})).not.toBeVisible();
|
||||
|
||||
// # Re-enable ABAC for subsequent tests via API — avoids the race where a concurrent
|
||||
// shard's initSetup() re-enables ABAC between the disable save and here, leaving the
|
||||
// radio already checked so the UI save button stays disabled.
|
||||
await adminClient.patchConfig({AccessControlSettings: {EnableAttributeBasedAccessControl: true}});
|
||||
});
|
||||
Reference in New Issue
Block a user