コード例 #1
0
def test_workbench_get_all_campaigns():
    cam = Campaign(id=constants.CAMPAIGN_ID, **constants.CAMPAIGN_KWARGS)
    save(cam)

    resp = campaigns()
    assert len(resp) == 1
    assert resp[0].id == constants.CAMPAIGN_ID
コード例 #2
0
def test_default_created_timestamp():
    timestamp = "2018-03-19T01:02:03.000Z"
    set_default_created(timestamp)
    campaign = Campaign(**CAMPAIGN_KWARGS)

    assert 'created' not in CAMPAIGN_KWARGS
    assert stix2.utils.format_datetime(campaign.created) == timestamp
    assert stix2.utils.format_datetime(campaign.modified) == timestamp
コード例 #3
0
def test_default_object_marking_refs():
    stmt_marking = StatementMarking("Copyright 2016, Example Corp")
    mark_def = MarkingDefinition(definition_type="statement",
                                 definition=stmt_marking)
    set_default_object_marking_refs(mark_def)
    campaign = Campaign(**CAMPAIGN_KWARGS)

    assert campaign.object_marking_refs[0] == mark_def.id
コード例 #4
0
def test_default_external_refs():
    ext_ref = ExternalReference(source_name="ACME Threat Intel",
                                description="Threat report")
    set_default_external_refs(ext_ref)
    campaign = Campaign(**CAMPAIGN_KWARGS)

    assert campaign.external_references[0].source_name == "ACME Threat Intel"
    assert campaign.external_references[0].description == "Threat report"
コード例 #5
0
def test_default_creator():
    set_default_creator(constants.IDENTITY_ID)
    campaign = Campaign(**constants.CAMPAIGN_KWARGS)

    assert 'created_by_ref' not in constants.CAMPAIGN_KWARGS
    assert campaign.created_by_ref == constants.IDENTITY_ID

    # turn off side-effects to avoid affecting future tests
    set_default_creator(None)
コード例 #6
0
def test_default_created_timestamp():
    timestamp = "2018-03-19T01:02:03.000Z"
    set_default_created(timestamp)
    campaign = Campaign(**constants.CAMPAIGN_KWARGS)

    assert 'created' not in constants.CAMPAIGN_KWARGS
    assert stix2.utils.format_datetime(campaign.created) == timestamp
    assert stix2.utils.format_datetime(campaign.modified) == timestamp

    # turn off side-effects to avoid affecting future tests
    set_default_created(None)
コード例 #7
0
def test_default_object_marking_refs():
    stmt_marking = StatementMarking("Copyright 2016, Example Corp")
    mark_def = MarkingDefinition(
        definition_type="statement",
        definition=stmt_marking,
    )
    set_default_object_marking_refs(mark_def)
    campaign = Campaign(**constants.CAMPAIGN_KWARGS)

    assert campaign.object_marking_refs[0] == mark_def.id

    # turn off side-effects to avoid affecting future tests
    set_default_object_marking_refs([])
コード例 #8
0
def test_default_external_refs():
    ext_ref = ExternalReference(
        source_name="ACME Threat Intel",
        description="Threat report",
    )
    set_default_external_refs(ext_ref)
    campaign = Campaign(**constants.CAMPAIGN_KWARGS)

    assert campaign.external_references[0].source_name == "ACME Threat Intel"
    assert campaign.external_references[0].description == "Threat report"

    # turn off side-effects to avoid affecting future tests
    set_default_external_refs([])
コード例 #9
0
def test_default_creator():
    set_default_creator(IDENTITY_ID)
    campaign = Campaign(**CAMPAIGN_KWARGS)

    assert 'created_by_ref' not in CAMPAIGN_KWARGS
    assert campaign.created_by_ref == IDENTITY_ID