Revert the import in the top-level stix2 package, to v20. This
additionally required: - Removing the v21 workbench test suite and reinstating the v20 test suite - Fixing up a few v20 unit tests to work with the workbench monkeypatching. - I didn't revert the analogous changes I'd previously made to the v21 unit tests, because I think they make sense even when the workbench monkeypatching isn't happening.master
parent
227383cdcb
commit
165d87e103
|
@ -54,7 +54,7 @@ from .patterns import (
|
||||||
WithinQualifier,
|
WithinQualifier,
|
||||||
)
|
)
|
||||||
from .utils import new_version, revoke
|
from .utils import new_version, revoke
|
||||||
from .v21 import * # This import will always be the latest STIX 2.X version
|
from .v20 import * # This import will always be the latest STIX 2.X version
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
|
||||||
_collect_stix2_mappings()
|
_collect_stix2_mappings()
|
||||||
|
|
|
@ -176,7 +176,7 @@ def test_parse_bundle(version):
|
||||||
|
|
||||||
assert bundle.type == "bundle"
|
assert bundle.type == "bundle"
|
||||||
assert bundle.id.startswith("bundle--")
|
assert bundle.id.startswith("bundle--")
|
||||||
assert type(bundle.objects[0]) is stix2.v20.Indicator
|
assert isinstance(bundle.objects[0], stix2.v20.Indicator)
|
||||||
assert bundle.objects[0].type == 'indicator'
|
assert bundle.objects[0].type == 'indicator'
|
||||||
assert bundle.objects[1].type == 'malware'
|
assert bundle.objects[1].type == 'malware'
|
||||||
assert bundle.objects[2].type == 'relationship'
|
assert bundle.objects[2].type == 'relationship'
|
||||||
|
|
|
@ -74,7 +74,9 @@ def test_register_object_with_version():
|
||||||
v = 'v20'
|
v = 'v20'
|
||||||
|
|
||||||
assert bundle.objects[0].type in core.STIX2_OBJ_MAPS[v]['objects']
|
assert bundle.objects[0].type in core.STIX2_OBJ_MAPS[v]['objects']
|
||||||
assert v in str(bundle.objects[0].__class__)
|
# spec_version is not in STIX 2.0, and is required in 2.1, so this
|
||||||
|
# suffices as a test for a STIX 2.0 object.
|
||||||
|
assert "spec_version" not in bundle.objects[0]
|
||||||
|
|
||||||
|
|
||||||
def test_register_marking_with_version():
|
def test_register_marking_with_version():
|
||||||
|
|
|
@ -96,7 +96,7 @@ def test_identity_custom_property_allowed():
|
||||||
def test_parse_identity_custom_property(data):
|
def test_parse_identity_custom_property(data):
|
||||||
with pytest.raises(stix2.exceptions.ExtraPropertiesError) as excinfo:
|
with pytest.raises(stix2.exceptions.ExtraPropertiesError) as excinfo:
|
||||||
stix2.parse(data, version="2.0")
|
stix2.parse(data, version="2.0")
|
||||||
assert excinfo.value.cls == stix2.v20.Identity
|
assert issubclass(excinfo.value.cls, stix2.v20.Identity)
|
||||||
assert excinfo.value.properties == ['foo']
|
assert excinfo.value.properties == ['foo']
|
||||||
assert "Unexpected properties for" in str(excinfo.value)
|
assert "Unexpected properties for" in str(excinfo.value)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ def test_workbench_environment():
|
||||||
save(ind)
|
save(ind)
|
||||||
|
|
||||||
resp = get(INDICATOR_ID)
|
resp = get(INDICATOR_ID)
|
||||||
assert resp['indicator_types'][0] == 'malicious-activity'
|
assert resp['labels'][0] == 'malicious-activity'
|
||||||
|
|
||||||
resp = all_versions(INDICATOR_ID)
|
resp = all_versions(INDICATOR_ID)
|
||||||
assert len(resp) == 1
|
assert len(resp) == 1
|
||||||
|
@ -147,7 +147,7 @@ def test_workbench_get_all_vulnerabilities():
|
||||||
|
|
||||||
def test_workbench_add_to_bundle():
|
def test_workbench_add_to_bundle():
|
||||||
vuln = Vulnerability(**VULNERABILITY_KWARGS)
|
vuln = Vulnerability(**VULNERABILITY_KWARGS)
|
||||||
bundle = stix2.v21.Bundle(vuln)
|
bundle = stix2.v20.Bundle(vuln)
|
||||||
assert bundle.objects[0].name == 'Heartbleed'
|
assert bundle.objects[0].name == 'Heartbleed'
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,10 +186,7 @@ def test_workbench_related():
|
||||||
|
|
||||||
|
|
||||||
def test_workbench_related_with_filters():
|
def test_workbench_related_with_filters():
|
||||||
malware = Malware(
|
malware = Malware(labels=["ransomware"], name="CryptorBit", created_by_ref=IDENTITY_ID)
|
||||||
malware_types=["ransomware"], name="CryptorBit",
|
|
||||||
created_by_ref=IDENTITY_ID, is_family=False,
|
|
||||||
)
|
|
||||||
rel = Relationship(malware.id, 'variant-of', MALWARE_ID)
|
rel = Relationship(malware.id, 'variant-of', MALWARE_ID)
|
||||||
save([malware, rel])
|
save([malware, rel])
|
||||||
|
|
||||||
|
@ -274,12 +271,12 @@ def test_default_object_marking_refs():
|
||||||
|
|
||||||
|
|
||||||
def test_workbench_custom_property_object_in_observable_extension():
|
def test_workbench_custom_property_object_in_observable_extension():
|
||||||
ntfs = stix2.v21.NTFSExt(
|
ntfs = stix2.v20.NTFSExt(
|
||||||
allow_custom=True,
|
allow_custom=True,
|
||||||
sid=1,
|
sid=1,
|
||||||
x_foo='bar',
|
x_foo='bar',
|
||||||
)
|
)
|
||||||
artifact = stix2.v21.File(
|
artifact = stix2.v20.File(
|
||||||
name='test',
|
name='test',
|
||||||
extensions={'ntfs-ext': ntfs},
|
extensions={'ntfs-ext': ntfs},
|
||||||
)
|
)
|
||||||
|
@ -296,7 +293,7 @@ def test_workbench_custom_property_object_in_observable_extension():
|
||||||
|
|
||||||
|
|
||||||
def test_workbench_custom_property_dict_in_observable_extension():
|
def test_workbench_custom_property_dict_in_observable_extension():
|
||||||
artifact = stix2.v21.File(
|
artifact = stix2.v20.File(
|
||||||
allow_custom=True,
|
allow_custom=True,
|
||||||
name='test',
|
name='test',
|
||||||
extensions={
|
extensions={
|
Loading…
Reference in New Issue