Skip to content

Commit

Permalink
[backend] WIP: test (#8333)
Browse files Browse the repository at this point in the history
  • Loading branch information
marieflorescontact committed Sep 30, 2024
1 parent 1292264 commit af53da1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@ const DELETE_QUERY = gql`
}
`;

const PLATFORM_ORGANIZATION_QUERY = gql`
mutation PoliciesFieldPatchMutation($id: ID!, $input: [EditInput]!) {
settingsEdit(id: $id) {
fieldPatch(input: $input) {
platform_organization {
id
name
}
enterprise_edition
id
}
}
}
`;

const ORGANIZATION_SHARING_QUERY = gql`
mutation StixCoreObjectSharingGroupAddMutation(
$id: ID!
Expand Down Expand Up @@ -140,7 +125,7 @@ describe('Organization sharing standard behavior for container', () => {
});
expect(queryResult.data.report.objects.edges.length).toEqual(10);
});
it.skip('should delete Report', async () => {
it('should delete Report', async () => {
// Delete the case
await adminQuery({
query: DELETE_QUERY,
Expand All @@ -150,7 +135,7 @@ describe('Organization sharing standard behavior for container', () => {
const queryResult = await adminQueryWithSuccess({ query: READ_QUERY, variables: { id: reportInternalId } });
expect(queryResult?.data?.caseIncident).toBeNull();
});
it.skip('should plateform organization sharing and EE deactivated', async () => {
it('should plateform organization sharing and EE deactivated', async () => {
await enableCEAndUnSetOrganization();
});
});
22 changes: 6 additions & 16 deletions opencti-platform/opencti-graphql/tests/utils/testQueryHelper.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import { expect } from 'vitest';
import { print } from 'graphql/index';
import type { AxiosInstance } from 'axios';
import {
ADMIN_USER,
adminQuery,
createUnauthenticatedClient,
executeInternalQuery,
getOrganizationIdByName,
Organization,
PLATFORM_ORGANIZATION,
queryAsAdmin,
TEST_ORGANIZATION,
testContext
} from './testQuery';
import { ADMIN_USER, adminQuery, createUnauthenticatedClient, executeInternalQuery, getOrganizationIdByName, Organization, queryAsAdmin, testContext } from './testQuery';
import { downloadFile, streamConverter } from '../../src/database/file-storage';
import { logApp } from '../../src/config/conf';
import { AUTH_REQUIRED, FORBIDDEN_ACCESS } from '../../src/config/errors';
Expand Down Expand Up @@ -108,18 +97,16 @@ export const requestFileFromStorageAsAdmin = async (storageId: string) => {
export const enableEEAndSetOrganization = async (organization: Organization) => {
const platformOrganizationId = await getOrganizationIdByName(organization.name);
const platformSettings: any = await getSettings(testContext);
console.log('platformSettings:', platformSettings);

const input = [
{ key: 'enterprise_edition', value: [new Date().getTime()] },
{ key: 'platform_organization', value: [platformOrganizationId] }
];
const settingsResult = await settingsEditField(testContext, ADMIN_USER, platformSettings.id, input);
console.log('settingsResult:', settingsResult);

expect(settingsResult.platform_organization).not.toBeUndefined();
expect(settingsResult.enterprise_edition).not.toBeUndefined();
expect(settingsResult.platform_organization.id).toEqual(platformOrganizationId);
expect(settingsResult.platform_organization).toEqual(platformOrganizationId);
};

/**
Expand All @@ -132,5 +119,8 @@ export const enableCEAndUnSetOrganization = async () => {
{ key: 'enterprise_edition', value: [] },
{ key: 'platform_organization', value: [] }
];
const result = await settingsEditField(testContext, ADMIN_USER, platformSettings.id, input);
const settingsResult = await settingsEditField(testContext, ADMIN_USER, platformSettings.id, input);

expect(settingsResult.platform_organization).toBeUndefined();
expect(settingsResult.enterprise_edition).toBeUndefined();
};

0 comments on commit af53da1

Please sign in to comment.