Skip to content

Commit

Permalink
[frontend/backend] Fix counters
Browse files Browse the repository at this point in the history
  • Loading branch information
Kedae committed Feb 28, 2024
1 parent ef715cb commit ce7d70f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ describe('Elasticsearch pagination', () => {
it('should entity paginate everything', async () => {
const data = await elPaginate(testContext, ADMIN_USER, READ_ENTITIES_INDICES, { first: ES_MAX_PAGINATION });
expect(data).not.toBeNull();
expect(data.edges.length).toEqual(502);
expect(data.edges.length).toEqual(506);
const filterBaseTypes = R.uniq(R.map((e) => e.node.base_type, data.edges));
expect(filterBaseTypes.length).toEqual(1);
expect(R.head(filterBaseTypes)).toEqual('ENTITY');
Expand Down Expand Up @@ -501,7 +501,7 @@ describe('Elasticsearch pagination', () => {
filterGroups: [],
};
const data = await elPaginate(testContext, ADMIN_USER, READ_ENTITIES_INDICES, { filters });
expect(data.edges.length).toEqual(7);
expect(data.edges.length).toEqual(11);
});
it('should entity paginate with equality filter', async () => {
// eq operation will use the field.keyword to do an exact field equality
Expand All @@ -511,7 +511,7 @@ describe('Elasticsearch pagination', () => {
filterGroups: [],
};
let data = await elPaginate(testContext, ADMIN_USER, READ_ENTITIES_INDICES, { filters });
expect(data.edges.length).toEqual(1);
expect(data.edges.length).toEqual(2);
// Special case when operator = eq + the field key is a dateFields => use a match
filters = {
mode: 'and',
Expand All @@ -528,7 +528,7 @@ describe('Elasticsearch pagination', () => {
filterGroups: [],
};
let data = await elPaginate(testContext, ADMIN_USER, READ_ENTITIES_INDICES, { filters });
expect(data.edges.length).toEqual(7); // The 4 Default TLP + MITRE Corporation
expect(data.edges.length).toEqual(11); // The 4 Default TLP + MITRE Corporation
// Verify that nothing is found in this case if using the eq operator
filters = {
mode: 'and',
Expand All @@ -555,7 +555,7 @@ describe('Elasticsearch pagination', () => {
filterGroups: [],
};
data = await elPaginate(testContext, ADMIN_USER, READ_ENTITIES_INDICES, { filters, first: ES_MAX_PAGINATION });
expect(data.edges.length).toEqual(356);
expect(data.edges.length).toEqual(360);
filters = {
mode: 'and',
filters: [
Expand All @@ -573,7 +573,7 @@ describe('Elasticsearch pagination', () => {
orderMode: 'asc',
first: ES_MAX_PAGINATION
});
expect(data.edges.length).toEqual(502);
expect(data.edges.length).toEqual(506);
const createdDates = R.map((e) => e.node.created, data.edges);
let previousCreatedDate = null;
for (let index = 0; index < createdDates.length; index += 1) {
Expand All @@ -600,20 +600,24 @@ describe('Elasticsearch pagination', () => {
orderBy: 'definition',
orderMode: 'desc',
});
expect(data.edges.length).toEqual(7);
expect(data.edges.length).toEqual(11);
const markings = R.map((e) => e.node.definition, data.edges);
expect(markings[0]).toEqual('TLP:TEST');
expect(markings[1]).toEqual('TLP:RED');
expect(markings[2]).toEqual('TLP:GREEN');
expect(markings[3]).toEqual('TLP:CLEAR');
expect(markings[4]).toEqual('TLP:AMBER+STRICT');
expect(markings[5]).toEqual('TLP:AMBER');
expect(markings[6]).toEqual('PAP:RED');
expect(markings[7]).toEqual('PAP:GREEN');
expect(markings[8]).toEqual('PAP:CLEAR');
expect(markings[9]).toEqual('PAP:AMBER');
});
it('should relation paginate everything', async () => {
let data = await elPaginate(testContext, ADMIN_USER, READ_RELATIONSHIPS_INDICES, { includeAuthorities: true });
expect(data).not.toBeNull();
const groupByIndices = R.groupBy((e) => e.node._index, data.edges);
expect(groupByIndices[`${ES_INDEX_PREFIX}_internal_relationships-000001`].length).toEqual(43);
expect(groupByIndices[`${ES_INDEX_PREFIX}_internal_relationships-000001`].length).toEqual(47);
expect(groupByIndices[`${ES_INDEX_PREFIX}_stix_core_relationships-000001`].length).toEqual(24);
expect(groupByIndices[`${ES_INDEX_PREFIX}_stix_meta_relationships-000001`].length).toEqual(124);
expect(groupByIndices[`${ES_INDEX_PREFIX}_stix_sighting_relationships-000001`].length).toEqual(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ describe('MarkingDefinition resolver standard behavior', () => {
expect(queryResult.data.markingDefinition.id).toEqual(markingDefinitionInternalId);
});
it('should list markingDefinitions', async () => {
const queryResult = await queryAsAdmin({ query: LIST_QUERY, variables: { first: 10 } });
expect(queryResult.data.markingDefinitions.edges.length).toEqual(8);
const queryResult = await queryAsAdmin({ query: LIST_QUERY, variables: { first: 20 } });
expect(queryResult.data.markingDefinitions.edges.length).toEqual(12);
});
it('should update markingDefinition', async () => {
const UPDATE_QUERY = gql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Raw streams tests', () => {
const createEvents = events.filter((e) => e.type === EVENT_TYPE_CREATE);
// Check some events count
const createEventsByTypes = R.groupBy((e) => e.data.data.type, createEvents);
expect(createEventsByTypes['marking-definition'].length).toBe(15);
expect(createEventsByTypes['marking-definition'].length).toBe(17);
expect(createEventsByTypes['external-reference'].length).toBe(17);
expect(createEventsByTypes.label.length).toBe(15);
expect(createEventsByTypes.identity.length).toBe(30);
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-graphql/tests/utils/testQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const SYNC_DIRECT_START_REMOTE_URI = conf.get('app:sync_direct_start_remo
export const SYNC_RESTORE_START_REMOTE_URI = conf.get('app:sync_restore_start_remote_uri');
export const SYNC_TEST_REMOTE_URI = `http://api-tests:${PORT}`;
export const RAW_EVENTS_SIZE = 947;
export const SYNC_LIVE_EVENTS_SIZE = 594;
export const SYNC_LIVE_EVENTS_SIZE = 596;

export const PYTHON_PATH = './src/python/testing';
export const API_URI = `http://localhost:${conf.get('app:port')}`;
Expand Down

0 comments on commit ce7d70f

Please sign in to comment.