Ejemplo n.º 1
0
def test_register_object_with_version():
    bundle = core.dict_to_stix2(BUNDLE, version='2.1')
    core._register_object(bundle.objects[0].__class__)
    v = 'v21'

    assert bundle.objects[0].type in core.STIX2_OBJ_MAPS[v]['objects']
    assert bundle.objects[0].spec_version == "2.1"
Ejemplo n.º 2
0
def test_register_object_with_version():
    bundle = core.dict_to_stix2(BUNDLE, version='2.0')
    core._register_object(bundle.objects[0].__class__, version='2.0')
    v = 'v20'

    assert bundle.objects[0].type in core.STIX2_OBJ_MAPS[v]['objects']
    # spec_version is not in STIX 2.0, and is required in 2.1, so this
    # suffices as a test for a STIX 2.0 object.
    assert "spec_version" not in bundle.objects[0]
Ejemplo n.º 3
0
def test_dict_to_stix2_bundle_with_version():
    with pytest.raises(exceptions.InvalidValueError) as excinfo:
        core.dict_to_stix2(BUNDLE, version='2.0')

    msg = "Invalid value for Bundle 'objects': Spec version 2.0 bundles don't yet support containing objects of a different spec version."
    assert str(excinfo.value) == msg
Ejemplo n.º 4
0
def test_dict_to_stix2_bundle_with_version():
    with pytest.raises(exceptions.ExtraPropertiesError) as excinfo:
        core.dict_to_stix2(BUNDLE, version='2.1')

    assert str(
        excinfo.value) == "Unexpected properties for Bundle: (spec_version)."