Skip to content

Commit 164fc33

Browse files
committed
[backend] fix stix filtering tests
1 parent 30c561f commit 164fc33

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

opencti-platform/opencti-graphql/tests/03-integration/01-database/stixFiltering-test.js

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -167,66 +167,40 @@ describe('Filters testing', () => {
167167
mode: 'and',
168168
filters: [{
169169
key: ['objectLabel'],
170-
values: ['identity'],
170+
values: ['ryuk'],
171171
operator: 'only_eq_to',
172172
mode: 'or',
173173
}],
174174
filterGroups: [],
175175
};
176176
let filteredObjects = await applyFilters(filters);
177-
expect(filteredObjects.length).toBe(10);
178-
// With not_only_eq_to
179-
let filtersNot = {
180-
mode: 'and',
181-
filters: [{
182-
key: ['objectLabel'],
183-
values: ['attack-pattern'],
184-
operator: 'not_only_eq_to',
185-
mode: 'or',
186-
}],
187-
filterGroups: [],
188-
};
189-
let filteredObjectsNot = await applyFilters(filtersNot);
190-
expect(stixBundle.objects.length - filteredObjects.length).toBe(filteredObjectsNot.length);
177+
expect(filteredObjects.length).toBe(0);
191178
// With only_eq_to & AND local mode
192179
filters = {
193180
mode: 'and',
194181
filters: [{
195182
key: ['objectLabel'],
196-
values: ['identity', 'organization'],
183+
values: ['ryuk', 'TrickBot', 'COVID-19'],
197184
operator: 'only_eq_to',
198185
mode: 'and',
199186
}],
200187
filterGroups: [],
201188
};
202189
filteredObjects = await applyFilters(filters);
203-
// With not_only_eq_to & AND local mode
204-
filtersNot = {
205-
mode: 'and',
206-
filters: [{
207-
key: ['objectLabel'],
208-
values: ['identity', 'organization'],
209-
operator: 'not_only_eq_to',
210-
mode: 'and',
211-
}],
212-
filterGroups: [],
213-
};
214-
filteredObjectsNot = await applyFilters(filtersNot);
215-
expect(stixBundle.objects.length - filteredObjects.length).toBe(filteredObjectsNot.length);
216-
expect(filteredObjects.map((n) => n.node.name).includes('ANSSI')).toBeFalsy();
190+
expect(filteredObjects.length).toBe(2);
217191
// With only_eq_to & OR local mode
218192
filters = {
219193
mode: 'and',
220194
filters: [{
221195
key: ['objectLabel'],
222-
values: ['identity', 'organization'],
196+
values: ['ryuk', 'TrickBot', 'COVID-19'],
223197
operator: 'only_eq_to',
224198
mode: 'or',
225199
}],
226200
filterGroups: [],
227201
};
228202
filteredObjects = await applyFilters(filters);
229-
expect(filteredObjects.length).toBe(10);
203+
expect(filteredObjects.length).toBe(0);
230204
});
231205

232206
// revoked

opencti-platform/opencti-graphql/tests/data/DATA-TEST-STIX2_v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"spec_version": "2.1",
99
"name": "ANSSI",
1010
"identity_class": "organization",
11-
"labels": ["identity", "organization"],
11+
"labels": ["identity"],
1212
"created": "2020-02-23T23:40:53.575Z",
1313
"modified": "2020-02-27T08:45:39.351Z",
1414
"x_opencti_organization_type": "CSIRT",

0 commit comments

Comments
 (0)