From d2d7161fb54a7c231ccb8d3495ff1af46dc931bb Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Thu, 19 Sep 2024 14:41:50 -0400 Subject: [PATCH 1/4] Fix issue #586. --- stix2/v21/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stix2/v21/common.py b/stix2/v21/common.py index 55c4a05d..103fff7d 100644 --- a/stix2/v21/common.py +++ b/stix2/v21/common.py @@ -77,7 +77,7 @@ class GranularMarking(_STIXBase21): def _check_object_constraints(self): super(GranularMarking, self)._check_object_constraints() self._check_at_least_one_property(['lang', 'marking_ref']) - + self._check_mutually_exclusive_properties(['lang', 'marking_ref']) class LanguageContent(_STIXBase21): """For more detailed information on this object's properties, see From 6299ff9b38d6d6543930654a61bb4e27f7c00fcc Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Fri, 20 Sep 2024 15:54:41 -0400 Subject: [PATCH 2/4] Add v21 test for GranularMarking to close #586. --- stix2/test/v21/test_markings.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stix2/test/v21/test_markings.py b/stix2/test/v21/test_markings.py index d3fd11bb..47925499 100644 --- a/stix2/test/v21/test_markings.py +++ b/stix2/test/v21/test_markings.py @@ -170,6 +170,18 @@ def test_granular_example_with_bad_selector(): assert str(excinfo.value) == "Invalid value for GranularMarking 'selectors': must adhere to selector syntax." +def test_granular_marking_mutual_exclusion_error(): + with pytest.raises(stix2.exceptions.MutuallyExclusivePropertiesError) as excinfo: + stix2.v21.GranularMarking( + lang="en", + marking_ref=stix2.TLP_GREEN, + selectors=["foo"] + ) + assert excinfo.value.cls == stix2.v21.GranularMarking + assert excinfo.value.properties == ["lang", "marking_ref"] + assert 'are mutually exclusive' in str(excinfo.value) + + def test_campaign_with_granular_markings_example(): campaign = stix2.v21.Campaign( id="campaign--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f", From 12ada44a63bfc5bbcab1687e81602223c7cecebe Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Tue, 24 Sep 2024 17:10:24 -0400 Subject: [PATCH 3/4] Add trailing comma expected by the pre-commit hook. --- stix2/test/v21/test_markings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stix2/test/v21/test_markings.py b/stix2/test/v21/test_markings.py index 47925499..0b2e950e 100644 --- a/stix2/test/v21/test_markings.py +++ b/stix2/test/v21/test_markings.py @@ -175,7 +175,7 @@ def test_granular_marking_mutual_exclusion_error(): stix2.v21.GranularMarking( lang="en", marking_ref=stix2.TLP_GREEN, - selectors=["foo"] + selectors=["foo"], ) assert excinfo.value.cls == stix2.v21.GranularMarking assert excinfo.value.properties == ["lang", "marking_ref"] From a2beb46f35ea070b483c61e2bc94e66ba97c440e Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Wed, 25 Sep 2024 11:53:29 -0400 Subject: [PATCH 4/4] Add extra blank line to make pre-commit happy. --- stix2/v21/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/stix2/v21/common.py b/stix2/v21/common.py index 103fff7d..ca795e02 100644 --- a/stix2/v21/common.py +++ b/stix2/v21/common.py @@ -79,6 +79,7 @@ def _check_object_constraints(self): self._check_at_least_one_property(['lang', 'marking_ref']) self._check_mutually_exclusive_properties(['lang', 'marking_ref']) + class LanguageContent(_STIXBase21): """For more detailed information on this object's properties, see `the STIX 2.1 specification `__.