Skip to content

Commit

Permalink
[client] Add relationship bundle test
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien committed Sep 22, 2024
1 parent e8db422 commit bf390a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/01-unit/utils/test_opencti_stix2_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def test_split_test_bundle():
), "Splitter must not have change the content"


def test_split_mono_bundle():
def test_split_mono_entity_bundle():
stix_splitter = OpenCTIStix2Splitter()
with open("./tests/data/mono-bundle.json") as file:
with open("./tests/data/mono-bundle-entity.json") as file:
content = file.read()
expectations, bundles = stix_splitter.split_bundle_with_expectations(content)
assert expectations == 1
Expand All @@ -54,6 +54,20 @@ def test_split_mono_bundle():
assert json_bundle["created_by_ref"] is None


def test_split_mono_relationship_bundle():
stix_splitter = OpenCTIStix2Splitter()
with open("../../../tests/data/mono-bundle-relationship.json") as file:
content = file.read()
expectations, bundles = stix_splitter.split_bundle_with_expectations(content)
assert expectations == 1
# Split with cleanup_inconsistent_bundle
stix_splitter = OpenCTIStix2Splitter()
expectations, bundles = stix_splitter.split_bundle_with_expectations(
bundle=content, cleanup_inconsistent_bundle=True
)
assert expectations == 0


def test_split_capec_bundle():
stix_splitter = OpenCTIStix2Splitter()
with open("./tests/data/mitre_att_capec.json") as file:
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/data/mono-bundle-relationship.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "bundle--1f126d0c-356c-43af-88f8-7a3b695dee83",
"objects": [
{
"id": "relationship--10e8c71d-a1b4-4e35-bca8-2e4a3785ea04",
"type": "relationship",
"relationship_type": "part-of",
"created_by_ref": "identity--not-available",
"source_ref": "malware--faa5b705-cf44-4e50-8472-29e5fec43c3c",
"target_ref": "malware--faa5b705-cf44-4e50-8472-29e5fec43c3d"
}
],
"spec_version": "2.1",
"type": "bundle",
"x_opencti_seq": 1
}

0 comments on commit bf390a1

Please sign in to comment.