Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
121 lines
4.1 KiB
TypeScript
121 lines
4.1 KiB
TypeScript
import type { IRoom, IUser } from '@rocket.chat/core-typings';
|
|
import { MongoClient } from 'mongodb';
|
|
|
|
import { IS_EE, URL_MONGODB } from './config/constants';
|
|
import { Users } from './fixtures/userStates';
|
|
import { HomeChannel } from './page-objects';
|
|
import { createTargetGroupAndReturnFullRoom, deleteRoom, setSettingValueById } from './utils';
|
|
import { convertHexToRGB } from './utils/convertHexToRGB';
|
|
import { expect, test } from './utils/test';
|
|
|
|
test.use({ storageState: Users.admin.state });
|
|
|
|
const attrKey = `clearance_${Date.now()}`;
|
|
|
|
const bannersConfig = {
|
|
version: 1,
|
|
enabled: true,
|
|
banner: {
|
|
style: 'classic',
|
|
uppercase: true,
|
|
monospace: false,
|
|
delimiter: ' // ',
|
|
colorMode: 'highest',
|
|
fallbackText: 'NO CLASSIFICATION DATA',
|
|
fallbackColor: '#6C727A',
|
|
},
|
|
attributes: [
|
|
{
|
|
id: 'clearance',
|
|
source: attrKey,
|
|
label: 'Clearance',
|
|
showInBanner: true,
|
|
showLabel: true,
|
|
bannerLabel: 'CLEARANCE',
|
|
labelSeparator: '-',
|
|
valueSeparator: '/',
|
|
sortAlpha: false,
|
|
groupThreshold: 0,
|
|
multipleLabel: 'MULTIPLE',
|
|
drivesColor: true,
|
|
values: [
|
|
{ source: 'TS', label: 'TOP SECRET', color: '#ff8c00' },
|
|
{ source: 'U', label: 'UNCLASSIFIED', color: '#007a33' },
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
test.describe.serial('abac-classification-banner', () => {
|
|
let poHomeChannel: HomeChannel;
|
|
let connection: MongoClient;
|
|
let room: IRoom;
|
|
let attributeId: string;
|
|
|
|
test.skip(!IS_EE, 'Enterprise Only');
|
|
|
|
test.beforeAll(async ({ api }) => {
|
|
connection = await MongoClient.connect(URL_MONGODB);
|
|
|
|
await Promise.all([
|
|
setSettingValueById(api, 'ABAC_Enabled', true),
|
|
setSettingValueById(api, 'ABAC_PDP_Type', 'local'),
|
|
setSettingValueById(api, 'ABAC_Attribute_Store', 'local'),
|
|
setSettingValueById(api, 'ABAC_Classification_Banners_Enabled', true),
|
|
setSettingValueById(api, 'ABAC_Classification_Banners_Config', JSON.stringify(bannersConfig)),
|
|
]);
|
|
|
|
expect((await api.post('/abac/attributes', { key: attrKey, values: ['TS', 'U'] })).status()).toBe(200);
|
|
const { attributes } = await (await api.get('/abac/attributes', { key: attrKey })).json();
|
|
attributeId = attributes.find((attribute: { key: string }) => attribute.key === attrKey)._id;
|
|
|
|
// the local PDP only keeps members whose own attributes match the room's,
|
|
// so the admin gets them straight in the database before the room is tagged
|
|
await connection
|
|
.db()
|
|
.collection<IUser>('users')
|
|
.updateOne({ username: Users.admin.data.username }, { $push: { abacAttributes: { key: attrKey, values: ['TS', 'U'] } } });
|
|
|
|
({ group: room } = await createTargetGroupAndReturnFullRoom(api));
|
|
expect((await api.put(`/abac/rooms/${room._id}/attributes/${attrKey}`, { values: ['TS'] })).status()).toBe(200);
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await deleteRoom(api, room._id);
|
|
await api.delete(`/abac/attributes/${attributeId}`);
|
|
await connection
|
|
.db()
|
|
.collection<IUser>('users')
|
|
.updateOne({ username: Users.admin.data.username }, { $pull: { abacAttributes: { key: attrKey } } });
|
|
await connection.close();
|
|
|
|
await Promise.all([
|
|
setSettingValueById(api, 'ABAC_Classification_Banners_Config', ''),
|
|
setSettingValueById(api, 'ABAC_Classification_Banners_Enabled', false),
|
|
setSettingValueById(api, 'ABAC_Enabled', false),
|
|
]);
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
poHomeChannel = new HomeChannel(page);
|
|
await poHomeChannel.goto();
|
|
});
|
|
|
|
test('should show the classification banner built from the config in an ABAC room', async ({ page }) => {
|
|
await poHomeChannel.navbar.openChat(room.name as string);
|
|
|
|
const banner = page.getByRole('region', { name: 'Room Attributes' });
|
|
await expect(banner).toBeVisible();
|
|
await expect(banner).toHaveText('CLEARANCE-TOP SECRET');
|
|
await expect(banner).toHaveCSS('background-color', convertHexToRGB('#ff8c00'));
|
|
});
|
|
|
|
test('should not show the banner when classification banners are disabled', async ({ page, api }) => {
|
|
await setSettingValueById(api, 'ABAC_Classification_Banners_Enabled', false);
|
|
|
|
await poHomeChannel.navbar.openChat(room.name as string);
|
|
await expect(poHomeChannel.composer.inputMessage).toBeVisible();
|
|
await expect(page.getByRole('region', { name: 'Room Attributes' })).toHaveCount(0);
|
|
});
|
|
});
|