diff --git a/stix2/test/test_observed_data.py b/stix2/test/test_observed_data.py index a3bff7b..6a56963 100644 --- a/stix2/test/test_observed_data.py +++ b/stix2/test/test_observed_data.py @@ -626,7 +626,7 @@ def test_file_example_with_empty_NTFSExt(): }) assert excinfo.value.cls == stix2.NTFSExt - assert excinfo.value.fields == sorted(list(stix2.NTFSExt._properties.keys())) + assert excinfo.value.properties == sorted(list(stix2.NTFSExt._properties.keys())) def test_file_example_with_PDFExt(): @@ -871,7 +871,7 @@ def test_mutex_example(): def test_process_example(): - p = stix2.Process(_valid_refs=["0"], + p = stix2.Process(_valid_refs={"0": "file"}, pid=1221, name="gedit-bin", created="2016-01-20T14:11:25.55Z", @@ -889,7 +889,7 @@ def test_process_example_empty_error(): assert excinfo.value.cls == stix2.Process properties_of_process = list(stix2.Process._properties.keys()) properties_of_process.remove("type") - assert excinfo.value.fields == sorted(properties_of_process) + assert excinfo.value.properties == sorted(properties_of_process) def test_process_example_empty_with_extensions(): @@ -900,7 +900,7 @@ def test_process_example_empty_with_extensions(): assert excinfo.value.cls == stix2.WindowsProcessExt properties_of_extension = list(stix2.WindowsProcessExt._properties.keys()) - assert excinfo.value.fields == sorted(properties_of_extension) + assert excinfo.value.properties == sorted(properties_of_extension) def test_process_example_windows_process_ext_empty(): @@ -913,7 +913,7 @@ def test_process_example_windows_process_ext_empty(): assert excinfo.value.cls == stix2.WindowsProcessExt properties_of_extension = list(stix2.WindowsProcessExt._properties.keys()) - assert excinfo.value.fields == sorted(properties_of_extension) + assert excinfo.value.properties == sorted(properties_of_extension) def test_process_example_extensions_empty(): @@ -924,7 +924,7 @@ def test_process_example_extensions_empty(): assert excinfo.value.cls == stix2.Process properties_of_process = list(stix2.Process._properties.keys()) properties_of_process.remove("type") - assert excinfo.value.fields == sorted(properties_of_process) + assert excinfo.value.properties == sorted(properties_of_process) def test_process_example_with_WindowsProcessExt_Object(): diff --git a/stix2/test/test_properties.py b/stix2/test/test_properties.py index 5dc0084..59e0dd9 100644 --- a/stix2/test/test_properties.py +++ b/stix2/test/test_properties.py @@ -1,7 +1,7 @@ import pytest from stix2 import TCPExt -from stix2.exceptions import DictionaryKeyError +from stix2.exceptions import AtLeastOnePropertyError, DictionaryKeyError from stix2.observables import EmailMIMEComponent from stix2.properties import (BinaryProperty, BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, @@ -272,7 +272,6 @@ def test_extension_property_valid(): {'foobar-ext': { 'pe_type': 'exe' }}, - {'windows-pebinary-ext': TCPExt()}, ]) def test_extension_property_invalid(data): ext_prop = ExtensionsProperty(enclosing_type='file') @@ -289,3 +288,8 @@ def test_extension_property_invalid_type(): }} ) assert 'no extensions defined' in str(excinfo.value) + + +def test_extension_at_least_one_property_constraint(): + with pytest.raises(AtLeastOnePropertyError): + TCPExt()