Add revoked property

stix2.1
clenk 2017-02-20 16:19:07 -05:00
parent e2f60bc8c5
commit 417b43b1fe
2 changed files with 12 additions and 0 deletions

View File

@ -24,6 +24,11 @@ REF_PROPERTY = {
'error_msg': "{type} {field} values must consist of a valid STIX type name and a valid UUID, separated by '--'."
}
BOOL_PROPERTY = {
'validate': (lambda x, val: isinstance(val, bool)),
'error_msg': "{type} {field} value must be a boolean."
}
COMMON_PROPERTIES = {
'type': TYPE_PROPERTY,
'id': ID_PROPERTY,
@ -33,6 +38,7 @@ COMMON_PROPERTIES = {
'modified': {
'default': NOW,
},
'revoked': BOOL_PROPERTY,
'created_by_ref': REF_PROPERTY
}

View File

@ -182,6 +182,12 @@ def test_indicator_created_ref_invalid_format():
assert str(excinfo.value) == "Indicator created_by_ref values must consist of a valid STIX type name and a valid UUID, separated by '--'."
def test_indicator_revoked_invalid():
with pytest.raises(ValueError) as excinfo:
indicator = stix2.Indicator(revoked='false', **INDICATOR_KWARGS)
assert str(excinfo.value) == "Indicator revoked value must be a boolean."
def test_cannot_assign_to_indicator_attributes(indicator):
with pytest.raises(ValueError) as excinfo:
indicator.valid_from = dt.datetime.now()