Skip to content

Commit 56f68e5

Browse files
[backend] WIP: improve container orga sharing tests (#4538)
1 parent 44fee74 commit 56f68e5

File tree

1 file changed

+20
-43
lines changed

1 file changed

+20
-43
lines changed

opencti-platform/opencti-graphql/tests/02-integration/02-resolvers/container-authorized-members-test.ts

+20-43
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ const PLATFORM_ORGANIZATION_QUERY = gql`
8787
}
8888
`;
8989

90+
const ORGANIZATION_SHARING_QUERY = gql`
91+
mutation StixCoreObjectSharingGroupAddMutation(
92+
$id: ID!
93+
$organizationId: ID!
94+
) {
95+
stixCoreObjectEdit(id: $id) {
96+
restrictionOrganizationAdd(organizationId: $organizationId) {
97+
id
98+
objectOrganization {
99+
id
100+
name
101+
}
102+
}
103+
}
104+
}
105+
`;
106+
90107
describe('Case Incident Response standard behavior with authorized_members activation from entity', () => {
91108
let caseIncident: CaseIncident;
92109
let userEditorId: string;
@@ -485,26 +502,9 @@ describe('Case Incident Response and organization sharing standard behavior with
485502
it('should share Case Incident Response with Organization', async () => {
486503
// Get organization id
487504
organizationId = await getOrganizationIdByName(PLATFORM_ORGANIZATION.name);
488-
const ORGANIZATION_SHARING_QUERY = gql`
489-
mutation StixCoreObjectSharingGroupAddMutation(
490-
$id: ID!
491-
$organizationId: ID!
492-
) {
493-
stixCoreObjectEdit(id: $id) {
494-
restrictionOrganizationAdd(organizationId: $organizationId) {
495-
id
496-
objectOrganization {
497-
id
498-
name
499-
}
500-
}
501-
}
502-
}
503-
`;
504-
505505
const organizationSharingQueryResult = await adminQuery({
506506
query: ORGANIZATION_SHARING_QUERY,
507-
variables: { id: caseIrId, organizationId: PLATFORM_ORGANIZATION.id }
507+
variables: { id: caseIrId, organizationId }
508508
});
509509
expect(organizationSharingQueryResult).not.toBeNull();
510510
expect(organizationSharingQueryResult?.data?.stixCoreObjectEdit.restrictionOrganizationAdd).not.toBeNull();
@@ -659,17 +659,12 @@ describe('Case Incident Response and organization sharing standard behavior with
659659
expect(caseIRQueryResult?.data?.caseIncident.id).toEqual(caseIrId);
660660
});
661661
// 6. On enlève les authorized members, et on vérifie que l'editor n'as plus accès au case
662-
it('should Admin user removes Editor user from authorized members', async () => {
662+
it('should Admin user deactivate authorized members', async () => {
663663
await queryAsAdmin({
664664
query: EDIT_AUTHORIZED_MEMBERS_QUERY,
665665
variables: {
666666
id: caseIrId,
667-
input: [
668-
{
669-
id: ADMIN_USER.id,
670-
access_right: 'admin'
671-
}
672-
]
667+
input: null
673668
}
674669
});
675670
// Verify Editor user has no more access to Case incident
@@ -681,23 +676,6 @@ describe('Case Incident Response and organization sharing standard behavior with
681676
it('should share Case Incident Response with Organization', async () => {
682677
// Get organization id
683678
testOrganizationId = await getOrganizationIdByName(TEST_ORGANIZATION.name);
684-
const ORGANIZATION_SHARING_QUERY = gql`
685-
mutation StixCoreObjectSharingGroupAddMutation(
686-
$id: ID!
687-
$organizationId: ID!
688-
) {
689-
stixCoreObjectEdit(id: $id) {
690-
restrictionOrganizationAdd(organizationId: $organizationId) {
691-
id
692-
objectOrganization {
693-
id
694-
name
695-
}
696-
}
697-
}
698-
}
699-
`;
700-
701679
const organizationSharingQueryResult = await adminQuery({
702680
query: ORGANIZATION_SHARING_QUERY,
703681
variables: { id: caseIrId, organizationId: testOrganizationId }
@@ -708,7 +686,6 @@ describe('Case Incident Response and organization sharing standard behavior with
708686

709687
// Verify Editor user has access to Case incident
710688
const caseIRQueryResult = await editorQuery({ query: READ_QUERY, variables: { id: caseIrId } });
711-
console.log(JSON.stringify(caseIRQueryResult));
712689
expect(caseIRQueryResult).not.toBeNull();
713690
expect(caseIRQueryResult?.data?.caseIncident).not.toBeUndefined();
714691
expect(caseIRQueryResult?.data?.caseIncident.id).toEqual(caseIrId);

0 commit comments

Comments
 (0)