Check custom extension properties is not empty
parent
2b65f7205b
commit
e57c36f525
|
@ -916,7 +916,7 @@ def CustomExtension(observable=None, type='x-custom-observable', properties=None
|
|||
'extensions': ExtensionsProperty(enclosing_type=_type),
|
||||
}
|
||||
|
||||
if not isinstance(properties, dict):
|
||||
if not isinstance(properties, dict) or not properties:
|
||||
raise ValueError("'properties' must be a dict!")
|
||||
|
||||
_properties.update(properties)
|
||||
|
|
|
@ -366,7 +366,15 @@ def test_custom_extension_invalid_observable():
|
|||
|
||||
def test_custom_extension_no_properties():
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.observables.CustomExtension(stix2.DomainName, 'x-new-ext', None)
|
||||
@stix2.observables.CustomExtension(stix2.DomainName, 'x-new-ext2', None)
|
||||
class BarExtension():
|
||||
pass
|
||||
assert "'properties' must be a dict!" in str(excinfo.value)
|
||||
|
||||
|
||||
def test_custom_extension_empty_properties():
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.observables.CustomExtension(stix2.DomainName, 'x-new-ext2', {})
|
||||
class BarExtension():
|
||||
pass
|
||||
assert "'properties' must be a dict!" in str(excinfo.value)
|
||||
|
|
Loading…
Reference in New Issue