diff --git a/stix2/__init__.py b/stix2/__init__.py index 68e0264..714bf46 100644 --- a/stix2/__init__.py +++ b/stix2/__init__.py @@ -54,7 +54,7 @@ from .patterns import ( WithinQualifier, ) 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__ _collect_stix2_mappings() diff --git a/stix2/test/v20/test_bundle.py b/stix2/test/v20/test_bundle.py index df59f89..f53d0cb 100644 --- a/stix2/test/v20/test_bundle.py +++ b/stix2/test/v20/test_bundle.py @@ -176,7 +176,7 @@ def test_parse_bundle(version): assert bundle.type == "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[1].type == 'malware' assert bundle.objects[2].type == 'relationship' diff --git a/stix2/test/v20/test_core.py b/stix2/test/v20/test_core.py index c2056b8..d2efa22 100644 --- a/stix2/test/v20/test_core.py +++ b/stix2/test/v20/test_core.py @@ -74,7 +74,9 @@ def test_register_object_with_version(): v = 'v20' 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(): diff --git a/stix2/test/v20/test_custom.py b/stix2/test/v20/test_custom.py index 8a99b2c..3cfc23f 100644 --- a/stix2/test/v20/test_custom.py +++ b/stix2/test/v20/test_custom.py @@ -96,7 +96,7 @@ def test_identity_custom_property_allowed(): def test_parse_identity_custom_property(data): with pytest.raises(stix2.exceptions.ExtraPropertiesError) as excinfo: 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 "Unexpected properties for" in str(excinfo.value) diff --git a/stix2/test/v21/test_workbench.py b/stix2/test/v20/test_workbench.py similarity index 96% rename from stix2/test/v21/test_workbench.py rename to stix2/test/v20/test_workbench.py index 3a4a3fd..c254966 100644 --- a/stix2/test/v21/test_workbench.py +++ b/stix2/test/v20/test_workbench.py @@ -29,7 +29,7 @@ def test_workbench_environment(): save(ind) resp = get(INDICATOR_ID) - assert resp['indicator_types'][0] == 'malicious-activity' + assert resp['labels'][0] == 'malicious-activity' resp = all_versions(INDICATOR_ID) assert len(resp) == 1 @@ -147,7 +147,7 @@ def test_workbench_get_all_vulnerabilities(): def test_workbench_add_to_bundle(): vuln = Vulnerability(**VULNERABILITY_KWARGS) - bundle = stix2.v21.Bundle(vuln) + bundle = stix2.v20.Bundle(vuln) assert bundle.objects[0].name == 'Heartbleed' @@ -186,10 +186,7 @@ def test_workbench_related(): def test_workbench_related_with_filters(): - malware = Malware( - malware_types=["ransomware"], name="CryptorBit", - created_by_ref=IDENTITY_ID, is_family=False, - ) + malware = Malware(labels=["ransomware"], name="CryptorBit", created_by_ref=IDENTITY_ID) rel = Relationship(malware.id, 'variant-of', MALWARE_ID) save([malware, rel]) @@ -274,12 +271,12 @@ def test_default_object_marking_refs(): def test_workbench_custom_property_object_in_observable_extension(): - ntfs = stix2.v21.NTFSExt( + ntfs = stix2.v20.NTFSExt( allow_custom=True, sid=1, x_foo='bar', ) - artifact = stix2.v21.File( + artifact = stix2.v20.File( name='test', 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(): - artifact = stix2.v21.File( + artifact = stix2.v20.File( allow_custom=True, name='test', extensions={