diff --git a/stix2/test/test_custom.py b/stix2/test/test_custom.py index 918c7f0..a14503f 100644 --- a/stix2/test/test_custom.py +++ b/stix2/test/test_custom.py @@ -602,3 +602,8 @@ def test_register_custom_object(): stix2._register_type(CustomObject2) # Note that we will always check against newest OBJ_MAP. assert (CustomObject2._type, CustomObject2) in stix2.OBJ_MAP.items() + + +def test_extension_property_location(): + assert 'extensions' in stix2.v20.observables.OBJ_MAP_OBSERVABLE['x-new-observable']._properties + assert 'extensions' not in stix2.v20.observables.EXT_MAP['domain-name']['x-new-ext']._properties diff --git a/stix2/v20/observables.py b/stix2/v20/observables.py index dc1289b..39a8f19 100644 --- a/stix2/v20/observables.py +++ b/stix2/v20/observables.py @@ -979,6 +979,9 @@ def CustomObservable(type='x-custom-observable', properties=None): "is not a ListProperty containing ObjectReferenceProperty." % prop_name) _properties.update(properties) + _properties.update([ + ('extensions', ExtensionsProperty(enclosing_type=_type)), + ]) def __init__(self, **kwargs): _Observable.__init__(self, **kwargs) @@ -1030,9 +1033,7 @@ def CustomExtension(observable=None, type='x-custom-observable', properties=None class _Custom(cls, _Extension): _type = type - _properties = { - 'extensions': ExtensionsProperty(enclosing_type=_type), - } + _properties = OrderedDict() if not properties or not isinstance(properties, list): raise ValueError("Must supply a list, containing tuples. For example, [('property1', IntegerProperty())]")