From 7fb7cfde4003f4d85753f30bbf59ffb44d87fa7c Mon Sep 17 00:00:00 2001 From: Angelique Date: Wed, 2 Oct 2024 08:48:20 +0200 Subject: [PATCH] Adding test coverage on initial Roles and Groups --- .../01-database/data-initialization-test.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/opencti-platform/opencti-graphql/tests/02-integration/01-database/data-initialization-test.ts b/opencti-platform/opencti-graphql/tests/02-integration/01-database/data-initialization-test.ts index 6ea79e06fe638..fbe009cf2d761 100644 --- a/opencti-platform/opencti-graphql/tests/02-integration/01-database/data-initialization-test.ts +++ b/opencti-platform/opencti-graphql/tests/02-integration/01-database/data-initialization-test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import { listAllEntities } from '../../../src/database/middleware-loader'; -import { ENTITY_TYPE_CAPABILITY } from '../../../src/schema/internalObject'; +import {ENTITY_TYPE_CAPABILITY, ENTITY_TYPE_GROUP, ENTITY_TYPE_ROLE} from '../../../src/schema/internalObject'; import { ADMIN_USER, testContext } from '../../utils/testQuery'; import type { BasicStoreEntity } from '../../../src/types/store'; @@ -51,4 +51,22 @@ describe('Data initialization test', () => { ]; expect(capabilitiesNames).toEqual(allExpectedNames); }); + + it('should create all initial roles', async () => { + const allRoles = await listAllEntities(testContext, ADMIN_USER, [ENTITY_TYPE_ROLE]); + const allRolesNames = allRoles.map((role) => role.name).sort(); + const allExpectedRoles = ['Administrator', 'Connector', 'Default']; + for (let i = 0; i < allExpectedRoles.length; i = i+1) { + expect(allRolesNames, `${allExpectedRoles[i]} Role is missing from initialization`).toContain(allExpectedRoles[i]); + } + }); + + it('should create all initial Groups', async () => { + const allGroups = await listAllEntities(testContext, ADMIN_USER, [ENTITY_TYPE_GROUP]); + const allGroupsNames = allGroups.map((group) => group.name).sort(); + const allExpectedGroups = ['Administrators', 'Connectors', 'Default']; + for (let i = 0; i < allExpectedGroups.length; i = i+1) { + expect(allGroupsNames, `${allExpectedGroups[i]} Group is missing from initialization`).toContain(allExpectedGroups[i]); + } + }); });