Add tests for all different fields

stix2.1
Greg Back 2017-01-17 14:09:20 -08:00
parent 6761d1fdfc
commit d054b9deba
1 changed files with 17 additions and 7 deletions

View File

@ -21,11 +21,6 @@ def test_timestamp_formatting(dt, timestamp):
assert stix2.format_datetime(dt) == timestamp
def test_basic_indicator():
indicator = stix2.Indicator()
assert indicator.id.startswith("indicator")
EXPECTED = """{
"created": "2017-01-01T00:00:00Z",
"id": "indicator--01234567-89ab-cdef-0123-456789abcdef",
@ -46,11 +41,26 @@ def test_indicator_with_all_required_fields():
indicator = stix2.Indicator(
type="indicator",
id="indicator--01234567-89ab-cdef-0123-456789abcdef",
created=now,
modified=now,
labels=['malicious-activity'],
pattern="[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
created=now,
modified=now,
valid_from=epoch,
)
assert str(indicator) == EXPECTED
def test_indicator_autogenerated_fields():
indicator = stix2.Indicator(
labels=['malicious-activity'],
pattern="[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
)
assert indicator.type == 'indicator'
assert indicator.id.startswith('indicator--')
assert indicator.created is not None
assert indicator.modified is not None
assert indicator.labels == ['malicious-activity']
assert indicator.pattern == "[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']"
assert indicator.valid_from is not None