update to test cases
removing invalid test cases per new changes. updating some to reflect new changes to the Extensions Property, other minor onespull/1/head
parent
5cb52844dc
commit
1180da7cc7
|
@ -696,7 +696,7 @@ def test_observed_data_with_custom_observable_object():
|
|||
|
||||
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.DomainName, 'x-new-ext', [
|
||||
'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
],
|
||||
|
@ -758,8 +758,8 @@ def test_custom_extension_wrong_observable_type():
|
|||
)
|
||||
def test_custom_extension_with_list_and_dict_properties_observable_type(data):
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.UserAccount, 'some-extension', [
|
||||
('keys', stix2.properties.ListProperty(stix2.properties.DictionaryProperty, required=True)),
|
||||
'some-extension', [
|
||||
('keys', stix2.properties.ListProperty(stix2.properties.DictionaryProperty, required=True)),
|
||||
],
|
||||
)
|
||||
class SomeCustomExtension:
|
||||
|
@ -769,53 +769,11 @@ def test_custom_extension_with_list_and_dict_properties_observable_type(data):
|
|||
assert data == str(example)
|
||||
|
||||
|
||||
def test_custom_extension_invalid_observable():
|
||||
# These extensions are being applied to improperly-created Observables.
|
||||
# The Observable classes should have been created with the CustomObservable decorator.
|
||||
class Foo(object):
|
||||
pass
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v20.CustomExtension(
|
||||
Foo, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class FooExtension():
|
||||
pass # pragma: no cover
|
||||
assert str(excinfo.value) == "'observable' must be a valid Observable class!"
|
||||
|
||||
class Bar(stix2.v20.observables._Observable):
|
||||
pass
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v20.CustomExtension(
|
||||
Bar, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class BarExtension():
|
||||
pass
|
||||
assert "Unknown observable type" in str(excinfo.value)
|
||||
assert "Custom observables must be created with the @CustomObservable decorator." in str(excinfo.value)
|
||||
|
||||
class Baz(stix2.v20.observables._Observable):
|
||||
_type = 'Baz'
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v20.CustomExtension(
|
||||
Baz, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class BazExtension():
|
||||
pass
|
||||
assert "Unknown observable type" in str(excinfo.value)
|
||||
assert "Custom observables must be created with the @CustomObservable decorator." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_custom_extension_invalid_type_name():
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.File, 'x', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
'x', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
},
|
||||
)
|
||||
class FooExtension():
|
||||
|
@ -824,8 +782,8 @@ def test_custom_extension_invalid_type_name():
|
|||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.File, 'x_new_ext', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
'x_new_ext', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
},
|
||||
)
|
||||
class BlaExtension():
|
||||
|
@ -835,29 +793,29 @@ def test_custom_extension_invalid_type_name():
|
|||
|
||||
def test_custom_extension_no_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v20.CustomExtension(stix2.v20.DomainName, 'x-new-ext2', None)
|
||||
@stix2.v20.CustomExtension('x-new-ext2', None)
|
||||
class BarExtension():
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_extension_empty_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v20.CustomExtension(stix2.v20.DomainName, 'x-new-ext2', [])
|
||||
@stix2.v20.CustomExtension('x-new-ext2', [])
|
||||
class BarExtension():
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_extension_dict_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v20.CustomExtension(stix2.v20.DomainName, 'x-new-ext2', {})
|
||||
@stix2.v20.CustomExtension('x-new-ext2', {})
|
||||
class BarExtension():
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_extension_no_init_1():
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.DomainName, 'x-new-extension', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
'x-new-extension', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class NewExt():
|
||||
|
@ -869,8 +827,8 @@ def test_custom_extension_no_init_1():
|
|||
|
||||
def test_custom_extension_no_init_2():
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.DomainName, 'x-new-ext2', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
'x-new-ext2', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class NewExt2(object):
|
||||
|
@ -986,7 +944,7 @@ def test_register_custom_object():
|
|||
|
||||
def test_extension_property_location():
|
||||
assert 'extensions' in stix2.v20.OBJ_MAP_OBSERVABLE['x-new-observable']._properties
|
||||
assert 'extensions' not in stix2.v20.EXT_MAP['domain-name']['x-new-ext']._properties
|
||||
assert 'extensions' not in stix2.v20.EXT_MAP['x-new-ext']._properties
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -1107,8 +1065,8 @@ def test_register_marking_with_version():
|
|||
|
||||
def test_register_observable_extension_with_version():
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.UserAccount, 'some-extension-2', [
|
||||
('keys', stix2.properties.StringProperty(required=True)),
|
||||
'some-extension-2', [
|
||||
('keys', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class SomeCustomExtension2:
|
||||
|
@ -1117,15 +1075,15 @@ def test_register_observable_extension_with_version():
|
|||
v = 'v20'
|
||||
example = SomeCustomExtension2(keys='test123')
|
||||
|
||||
assert example._type in parsing.STIX2_OBJ_MAPS[v]['observable-extensions']['user-account']
|
||||
assert example._type in parsing.STIX2_OBJ_MAPS[v]['extensions']
|
||||
|
||||
|
||||
def test_register_duplicate_observable_extension():
|
||||
with pytest.raises(DuplicateRegistrationError) as excinfo:
|
||||
@stix2.v20.CustomExtension(
|
||||
stix2.v20.UserAccount, 'some-extension-2', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
'some-extension-2', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
],
|
||||
)
|
||||
class NewExtension2():
|
||||
|
|
|
@ -213,7 +213,7 @@ def test_embedded_property():
|
|||
|
||||
|
||||
def test_extension_property_valid():
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0", enclosing_type='file')
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0")
|
||||
assert ext_prop({
|
||||
'windows-pebinary-ext': {
|
||||
'pe_type': 'exe',
|
||||
|
@ -222,13 +222,13 @@ def test_extension_property_valid():
|
|||
|
||||
|
||||
def test_extension_property_invalid1():
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0", enclosing_type='file')
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0")
|
||||
with pytest.raises(ValueError):
|
||||
ext_prop.clean(1)
|
||||
|
||||
|
||||
def test_extension_property_invalid2():
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0", enclosing_type='file')
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0")
|
||||
with pytest.raises(CustomContentError):
|
||||
ext_prop.clean(
|
||||
{
|
||||
|
@ -239,19 +239,6 @@ def test_extension_property_invalid2():
|
|||
)
|
||||
|
||||
|
||||
def test_extension_property_invalid_type():
|
||||
ext_prop = ExtensionsProperty(spec_version="2.0", enclosing_type='indicator')
|
||||
with pytest.raises(CustomContentError) as excinfo:
|
||||
ext_prop.clean(
|
||||
{
|
||||
'windows-pebinary-ext': {
|
||||
'pe_type': 'exe',
|
||||
},
|
||||
},
|
||||
)
|
||||
assert "Can't parse unknown extension" in str(excinfo.value)
|
||||
|
||||
|
||||
def test_extension_at_least_one_property_constraint():
|
||||
with pytest.raises(AtLeastOnePropertyError):
|
||||
stix2.v20.TCPExt()
|
||||
|
|
|
@ -893,7 +893,7 @@ def test_custom_observable_object_no_id_contrib_props():
|
|||
|
||||
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new-ext', [
|
||||
'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
],
|
||||
|
@ -955,8 +955,8 @@ def test_custom_extension_wrong_observable_type():
|
|||
)
|
||||
def test_custom_extension_with_list_and_dict_properties_observable_type(data):
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.UserAccount, 'x-some-extension-ext', [
|
||||
('keys', stix2.properties.ListProperty(stix2.properties.DictionaryProperty, required=True)),
|
||||
'x-some-extension-ext', [
|
||||
('keys', stix2.properties.ListProperty(stix2.properties.DictionaryProperty, required=True)),
|
||||
],
|
||||
)
|
||||
class SomeCustomExtension:
|
||||
|
@ -966,53 +966,11 @@ def test_custom_extension_with_list_and_dict_properties_observable_type(data):
|
|||
assert data == str(example)
|
||||
|
||||
|
||||
def test_custom_extension_invalid_observable():
|
||||
# These extensions are being applied to improperly-created Observables.
|
||||
# The Observable classes should have been created with the CustomObservable decorator.
|
||||
class Foo(object):
|
||||
pass
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
Foo, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class FooExtension():
|
||||
pass # pragma: no cover
|
||||
assert str(excinfo.value) == "'observable' must be a valid Observable class!"
|
||||
|
||||
class Bar(stix2.v21.observables._Observable):
|
||||
pass
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
Bar, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class BarExtension():
|
||||
pass
|
||||
assert "Unknown observable type" in str(excinfo.value)
|
||||
assert "Custom observables must be created with the @CustomObservable decorator." in str(excinfo.value)
|
||||
|
||||
class Baz(stix2.v21.observables._Observable):
|
||||
_type = 'Baz'
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
Baz, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class BazExtension():
|
||||
pass
|
||||
assert "Unknown observable type" in str(excinfo.value)
|
||||
assert "Custom observables must be created with the @CustomObservable decorator." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_custom_extension_invalid_type_name():
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.File, 'x', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
'x', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
},
|
||||
)
|
||||
class FooExtension():
|
||||
|
@ -1021,8 +979,8 @@ def test_custom_extension_invalid_type_name():
|
|||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.File, 'x_new_ext', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
'x_new_ext', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
},
|
||||
)
|
||||
class BlaExtension():
|
||||
|
@ -1031,8 +989,8 @@ def test_custom_extension_invalid_type_name():
|
|||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.File, '7x-new-ext', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
'7x-new-ext', {
|
||||
'property1': stix2.properties.StringProperty(required=True),
|
||||
},
|
||||
)
|
||||
class Bla2Extension():
|
||||
|
@ -1042,29 +1000,29 @@ def test_custom_extension_invalid_type_name():
|
|||
|
||||
def test_custom_extension_no_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v21.CustomExtension(stix2.v21.DomainName, 'x-new2-ext', None)
|
||||
@stix2.v21.CustomExtension('x-new2-ext', None)
|
||||
class BarExtension():
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_extension_empty_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v21.CustomExtension(stix2.v21.DomainName, 'x-new2-ext', [])
|
||||
@stix2.v21.CustomExtension('x-new2-ext', [])
|
||||
class BarExtension():
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_extension_dict_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v21.CustomExtension(stix2.v21.DomainName, 'x-new2-ext', {})
|
||||
@stix2.v21.CustomExtension('x-new2-ext', {})
|
||||
class BarExtension():
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_extension_no_init_1():
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new-extension-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
'x-new-extension-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class NewExt():
|
||||
|
@ -1076,8 +1034,8 @@ def test_custom_extension_no_init_1():
|
|||
|
||||
def test_custom_extension_no_init_2():
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new2-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
'x-new2-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class NewExt2(object):
|
||||
|
@ -1090,8 +1048,8 @@ def test_custom_extension_no_init_2():
|
|||
def test_invalid_custom_property_in_extension():
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new3-ext', [
|
||||
('6property1', stix2.properties.StringProperty(required=True)),
|
||||
'x-new3-ext', [
|
||||
('6property1', stix2.properties.StringProperty(required=True)),
|
||||
],
|
||||
)
|
||||
class NewExt():
|
||||
|
@ -1205,7 +1163,7 @@ def test_register_custom_object():
|
|||
|
||||
def test_extension_property_location():
|
||||
assert 'extensions' in stix2.v21.OBJ_MAP_OBSERVABLE['x-new-observable']._properties
|
||||
assert 'extensions' not in stix2.v21.EXT_MAP['domain-name']['x-new-ext']._properties
|
||||
assert 'extensions' not in stix2.v21.EXT_MAP['x-new-ext']._properties
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -1312,9 +1270,9 @@ def test_register_duplicate_observable():
|
|||
|
||||
def test_register_observable_custom_extension():
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new-2-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
'x-new-2-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
],
|
||||
)
|
||||
class NewExtension2():
|
||||
|
@ -1324,15 +1282,15 @@ def test_register_observable_custom_extension():
|
|||
v = 'v21'
|
||||
|
||||
assert 'domain-name' in stix2.parsing.STIX2_OBJ_MAPS[v]['observables']
|
||||
assert example._type in stix2.parsing.STIX2_OBJ_MAPS[v]['observable-extensions']['domain-name']
|
||||
assert example._type in stix2.parsing.STIX2_OBJ_MAPS[v]['extensions']
|
||||
|
||||
|
||||
def test_register_duplicate_observable_extension():
|
||||
with pytest.raises(DuplicateRegistrationError) as excinfo:
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new-2-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
'x-new-2-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
('property2', stix2.properties.IntegerProperty()),
|
||||
],
|
||||
)
|
||||
class NewExtension2():
|
||||
|
|
|
@ -48,11 +48,7 @@ def test_no_contrib_props_defined():
|
|||
_properties = OrderedDict((
|
||||
('type', TypeProperty(_type, spec_version='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.1')),
|
||||
(
|
||||
'extensions', ExtensionsProperty(
|
||||
spec_version='2.1', enclosing_type=_type,
|
||||
),
|
||||
),
|
||||
('extensions', ExtensionsProperty(spec_version='2.1')),
|
||||
))
|
||||
_id_contributing_properties = []
|
||||
|
||||
|
@ -69,11 +65,7 @@ def test_json_compatible_prop_values():
|
|||
_properties = OrderedDict((
|
||||
('type', TypeProperty(_type, spec_version='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.1')),
|
||||
(
|
||||
'extensions', ExtensionsProperty(
|
||||
spec_version='2.1', enclosing_type=_type,
|
||||
),
|
||||
),
|
||||
('extensions', ExtensionsProperty(spec_version='2.1')),
|
||||
('string', StringProperty()),
|
||||
('int', IntegerProperty()),
|
||||
('float', FloatProperty()),
|
||||
|
@ -109,11 +101,7 @@ def test_json_incompatible_timestamp_value():
|
|||
_properties = OrderedDict((
|
||||
('type', TypeProperty(_type, spec_version='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.1')),
|
||||
(
|
||||
'extensions', ExtensionsProperty(
|
||||
spec_version='2.1', enclosing_type=_type,
|
||||
),
|
||||
),
|
||||
('extensions', ExtensionsProperty(spec_version='2.1')),
|
||||
('timestamp', TimestampProperty()),
|
||||
))
|
||||
_id_contributing_properties = ['timestamp']
|
||||
|
@ -145,11 +133,7 @@ def test_embedded_object():
|
|||
_properties = OrderedDict((
|
||||
('type', TypeProperty(_type, spec_version='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.1')),
|
||||
(
|
||||
'extensions', ExtensionsProperty(
|
||||
spec_version='2.1', enclosing_type=_type,
|
||||
),
|
||||
),
|
||||
('extensions', ExtensionsProperty(spec_version='2.1')),
|
||||
('sub_obj', EmbeddedObjectProperty(type=SubObj)),
|
||||
))
|
||||
_id_contributing_properties = ['sub_obj']
|
||||
|
@ -176,11 +160,7 @@ def test_empty_hash():
|
|||
_properties = OrderedDict((
|
||||
('type', TypeProperty(_type, spec_version='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.1')),
|
||||
(
|
||||
'extensions', ExtensionsProperty(
|
||||
spec_version='2.1', enclosing_type=_type,
|
||||
),
|
||||
),
|
||||
('extensions', ExtensionsProperty(spec_version='2.1')),
|
||||
('hashes', HashesProperty()),
|
||||
))
|
||||
_id_contributing_properties = ['hashes']
|
||||
|
|
|
@ -10,13 +10,9 @@ MALWARE_ANALYSIS_JSON = """{
|
|||
"type": "malware-analysis",
|
||||
"spec_version": "2.1",
|
||||
"id": "malware-analysis--f8afc020-f92f-4906-a971-88ee5882eb46",
|
||||
"created_by_ref": "identity--e0353ed3-991e-4f71-a332-114c2f10b84f",
|
||||
"created": "2017-11-28T09:44:58.418Z",
|
||||
"modified": "2017-12-31T21:27:49.754Z",
|
||||
"created_by_ref": "identity--e0353ed3-991e-4f71-a332-114c2f10b84f",
|
||||
"labels": [
|
||||
"label1",
|
||||
"label2"
|
||||
],
|
||||
"product": "Acme Malware Analyzer",
|
||||
"version": "2.5",
|
||||
"host_vm_ref": "software--1bda7336-fe67-469f-a8ca-ab6268b0449b",
|
||||
|
@ -40,7 +36,11 @@ MALWARE_ANALYSIS_JSON = """{
|
|||
"file--fc27e371-6c88-4c5c-868a-4dda0e60b167",
|
||||
"url--6f7a74cd-8eb2-4b88-a4da-aa878e50ac2e"
|
||||
],
|
||||
"sample_ref": "email-addr--499a32d7-74c1-4276-ace9-725ac933e243"
|
||||
"sample_ref": "email-addr--499a32d7-74c1-4276-ace9-725ac933e243",
|
||||
"labels": [
|
||||
"label1",
|
||||
"label2"
|
||||
]
|
||||
}"""
|
||||
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ def test_embedded_property():
|
|||
|
||||
|
||||
def test_extension_property_valid():
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1', enclosing_type='file')
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1')
|
||||
assert ext_prop({
|
||||
'windows-pebinary-ext': {
|
||||
'pe_type': 'exe',
|
||||
|
@ -253,13 +253,13 @@ def test_extension_property_valid():
|
|||
|
||||
|
||||
def test_extension_property_invalid1():
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1', enclosing_type='file')
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1')
|
||||
with pytest.raises(ValueError):
|
||||
ext_prop.clean(1)
|
||||
|
||||
|
||||
def test_extension_property_invalid2():
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1', enclosing_type='file')
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1')
|
||||
with pytest.raises(CustomContentError):
|
||||
ext_prop.clean(
|
||||
{
|
||||
|
@ -270,19 +270,6 @@ def test_extension_property_invalid2():
|
|||
)
|
||||
|
||||
|
||||
def test_extension_property_invalid_type():
|
||||
ext_prop = ExtensionsProperty(spec_version='2.1', enclosing_type='indicator')
|
||||
with pytest.raises(CustomContentError) as excinfo:
|
||||
ext_prop.clean(
|
||||
{
|
||||
'windows-pebinary-ext': {
|
||||
'pe_type': 'exe',
|
||||
},
|
||||
},
|
||||
)
|
||||
assert "Can't parse unknown extension" in str(excinfo.value)
|
||||
|
||||
|
||||
def test_extension_at_least_one_property_constraint():
|
||||
with pytest.raises(AtLeastOnePropertyError):
|
||||
stix2.v21.TCPExt()
|
||||
|
|
Loading…
Reference in New Issue