Skip to content

Commit 14b437a

Browse files
[backend] update tests (#4538)
1 parent c24f33e commit 14b437a

File tree

1 file changed

+6
-95
lines changed

1 file changed

+6
-95
lines changed

opencti-platform/opencti-graphql/tests/02-integration/02-resolvers/case-incident-response-test.ts

+6-95
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import {
1010
PLATFORM_ORGANIZATION,
1111
queryAsAdmin,
1212
securityQuery,
13-
TEST_ORGANIZATION,
1413
USER_EDITOR,
15-
USER_SECURITY
1614
} from '../../utils/testQuery';
1715
import type { CaseIncident, EntitySettingEdge } from '../../../src/generated/graphql';
1816
import { ENTITY_TYPE_CONTAINER_CASE_INCIDENT } from '../../../src/modules/case/case-incident/case-incident-types';
@@ -350,20 +348,7 @@ describe('Case Incident Response standard behavior with authorized_members activ
350348
});
351349

352350
describe('Case Incident Response and organization sharing standard behavior without platform organization', () => {
353-
let testOrganizationId: string;
354351
let caseIrId: string;
355-
let userSecurityId: string;
356-
let settingsInternalId: string;
357-
const EE_QUERY = gql`
358-
mutation PoliciesFieldPatchMutation($id: ID!, $input: [EditInput]!) {
359-
settingsEdit(id: $id) {
360-
fieldPatch(input: $input) {
361-
enterprise_edition
362-
id
363-
}
364-
}
365-
}
366-
`;
367352
it('should Case Incident Response created', async () => {
368353
// Create Case Incident Response
369354
const caseIRCreateQueryResult = await adminQuery({
@@ -380,67 +365,13 @@ describe('Case Incident Response and organization sharing standard behavior with
380365
expect(caseIRCreateQueryResult?.data?.caseIncidentAdd.authorized_members).toEqual([]); // authorized members not activated
381366
caseIrId = caseIRCreateQueryResult?.data?.caseIncidentAdd.id;
382367
});
383-
it('should EE activated', async () => {
384-
// Get settings ID
385-
const SETTINGS_READ_QUERY = gql`
386-
query settings {
387-
settings {
388-
id
389-
}
390-
}
391-
`;
392-
const queryResult = await adminQuery({ query: SETTINGS_READ_QUERY, variables: {} });
393-
settingsInternalId = queryResult.data?.settings?.id;
394-
395-
// Set plateform organization
396-
const eeActivationQuery = await adminQuery({
397-
query: EE_QUERY,
398-
variables: {
399-
id: settingsInternalId,
400-
input: [
401-
{ key: 'enterprise_edition', value: new Date().getTime() },
402-
]
403-
}
404-
});
405-
406-
expect(eeActivationQuery).not.toBeNull();
407-
expect(eeActivationQuery?.data?.settingsEdit.fieldPatch.enterprise_edition).not.toBeUndefined();
408-
});
409-
it('should share Case Incident Response with Organization', async () => {
410-
// Get organization id
411-
testOrganizationId = await getOrganizationIdByName(TEST_ORGANIZATION.name);
412-
const ORGANIZATION_SHARING_QUERY = gql`
413-
mutation StixCoreObjectSharingGroupAddMutation(
414-
$id: ID!
415-
$organizationId: ID!
416-
) {
417-
stixCoreObjectEdit(id: $id) {
418-
restrictionOrganizationAdd(organizationId: $organizationId) {
419-
id
420-
objectOrganization {
421-
id
422-
name
423-
}
424-
}
425-
}
426-
}
427-
`;
428-
429-
const organizationSharingQueryResult = await adminQuery({
430-
query: ORGANIZATION_SHARING_QUERY,
431-
variables: { id: caseIrId, organizationId: testOrganizationId }
432-
});
433-
expect(organizationSharingQueryResult).not.toBeNull();
434-
expect(organizationSharingQueryResult?.data?.stixCoreObjectEdit.restrictionOrganizationAdd).not.toBeNull();
435-
expect(organizationSharingQueryResult?.data?.stixCoreObjectEdit.restrictionOrganizationAdd.objectOrganization[0].name).toEqual(TEST_ORGANIZATION.name);
436-
});
437-
it('should not access Case Incident Response', async () => {
438-
const caseIRQueryResult = await securityQuery({ query: READ_QUERY, variables: { id: caseIrId } }); // USER_SECURITY is not part of TEST_ORGANIZATION
368+
it('should access Case Incident Response', async () => {
369+
const caseIRQueryResult = await securityQuery({ query: READ_QUERY, variables: { id: caseIrId } });
439370
expect(caseIRQueryResult).not.toBeNull();
440-
expect(caseIRQueryResult.data?.caseIncident).toBeNull();
371+
expect(caseIRQueryResult?.data?.caseIncident).not.toBeUndefined();
372+
expect(caseIRQueryResult?.data?.caseIncident.id).toEqual(caseIrId);
441373
});
442374
it('should Authorized Members activated', async () => {
443-
userSecurityId = await getUserIdByEmail(USER_SECURITY.email);
444375
await queryAsAdmin({
445376
query: EDIT_AUTHORIZED_MEMBERS_QUERY,
446377
variables: {
@@ -449,10 +380,6 @@ describe('Case Incident Response and organization sharing standard behavior with
449380
{
450381
id: ADMIN_USER.id,
451382
access_right: 'admin'
452-
},
453-
{
454-
id: userSecurityId,
455-
access_right: 'view'
456383
}
457384
]
458385
}
@@ -468,18 +395,14 @@ describe('Case Incident Response and organization sharing standard behavior with
468395
{
469396
id: ADMIN_USER.id,
470397
access_right: 'admin'
471-
},
472-
{
473-
id: userSecurityId,
474-
access_right: 'view'
475398
}
476399
]);
477400
});
478-
it('should access Case Incident Response out of her organization if authorized members activated', async () => {
401+
it('should not access Case Incident Response if not in authorized members', async () => {
479402
const caseIRQueryResult = await securityQuery({ query: READ_QUERY, variables: { id: caseIrId } });
480403
expect(caseIRQueryResult).not.toBeNull();
481404
expect(caseIRQueryResult?.data?.caseIncident).not.toBeUndefined();
482-
expect(caseIRQueryResult?.data?.caseIncident.id).toEqual(caseIrId);
405+
expect(caseIRQueryResult?.data?.caseIncident).toBeNull();
483406
});
484407
it('should Case Incident Response deleted', async () => {
485408
// Delete the case
@@ -492,18 +415,6 @@ describe('Case Incident Response and organization sharing standard behavior with
492415
expect(queryResult).not.toBeNull();
493416
expect(queryResult?.data?.caseIncident).toBeNull();
494417
});
495-
it('should EE deactivated', async () => {
496-
// Remove EE
497-
const eeDeactivationQuery = await adminQuery({
498-
query: EE_QUERY,
499-
variables: { id: settingsInternalId,
500-
input: [
501-
{ key: 'enterprise_edition', value: [] },
502-
] }
503-
});
504-
expect(eeDeactivationQuery).not.toBeNull();
505-
expect(eeDeactivationQuery?.data?.settingsEdit.fieldPatch.enterprise_edition).toBeNull();
506-
});
507418
});
508419

509420
describe('Case Incident Response and organization sharing standard behavior with platform organization', () => {

0 commit comments

Comments
 (0)