From 0dd6462d6068a36af563bffd4d5d6b350b1a8f34 Mon Sep 17 00:00:00 2001 From: Michael Chisholm Date: Mon, 24 Aug 2020 18:58:53 -0400 Subject: [PATCH] Add some unit tests which try to version marking-definitions. --- stix2/test/v20/test_versioning.py | 24 ++++++++++++++++++++++++ stix2/test/v21/test_versioning.py | 27 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/stix2/test/v20/test_versioning.py b/stix2/test/v20/test_versioning.py index e37ff30..665ac4c 100644 --- a/stix2/test/v20/test_versioning.py +++ b/stix2/test/v20/test_versioning.py @@ -407,6 +407,30 @@ def test_version_sco_with_custom(): assert revoked_d["revoked"] +def test_version_marking(): + m = stix2.v20.MarkingDefinition( + created="1982-11-29T12:20:13.723Z", + definition_type="statement", + definition={"statement": "Copyright (c) 2000-2020 Acme Corp"}, + ) + + with pytest.raises(stix2.exceptions.TypeNotVersionableError): + stix2.versioning.new_version(m) + + m = { + "type": "marking-definition", + "id": "marking-definition--2a9f3f6e-5cbd-423b-a40d-02aefd29e612", + "created": "1982-11-29T12:20:13.723Z", + "definition_type": "statement", + "definition": { + "statement": "Copyright (c) 2000-2020 Acme Corp", + }, + } + + with pytest.raises(stix2.exceptions.TypeNotVersionableError): + stix2.versioning.new_version(m) + + def test_version_disable_custom(): m = stix2.v20.Malware( name="foo", labels=["label"], description="Steals your identity!", diff --git a/stix2/test/v21/test_versioning.py b/stix2/test/v21/test_versioning.py index 981fc6e..c7b6f11 100644 --- a/stix2/test/v21/test_versioning.py +++ b/stix2/test/v21/test_versioning.py @@ -452,6 +452,33 @@ def test_version_sco_id_contributing_properties_dict(): assert e.value.unchangable_properties == {"name"} +def test_version_marking(): + m = stix2.v21.MarkingDefinition( + name="a name", + created="1982-11-29T12:20:13.723Z", + definition_type="statement", + definition={"statement": "Copyright (c) 2000-2020 Acme Corp"}, + ) + + with pytest.raises(stix2.exceptions.TypeNotVersionableError): + stix2.versioning.new_version(m) + + m = { + "type": "marking-definition", + "id": "marking-definition--2a9f3f6e-5cbd-423b-a40d-02aefd29e612", + "spec_version": "2.1", + "name": "a name", + "created": "1982-11-29T12:20:13.723Z", + "definition_type": "statement", + "definition": { + "statement": "Copyright (c) 2000-2020 Acme Corp", + }, + } + + with pytest.raises(stix2.exceptions.TypeNotVersionableError): + stix2.versioning.new_version(m) + + def test_version_disable_custom(): m = stix2.v21.Malware( name="foo", description="Steals your identity!", is_family=False,