class SomeSCO(stix2.v21._Observable):
     _type = "some-sco"
     _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,
             ),
         ),
         ('string', StringProperty()),
         ('int', IntegerProperty()),
         ('float', FloatProperty()),
         ('bool', BooleanProperty()),
         ('list', ListProperty(IntegerProperty())),
         ('dict', DictionaryProperty(spec_version="2.1")),
     ))
     _id_contributing_properties = [
         'string',
         'int',
         'float',
         'bool',
         'list',
         'dict',
     ]
Esempio n. 2
0
class StixObservedData(_STIXBase):
    _type = 'observed-data'
    _properties = OrderedDict()
    _properties.update([
        ('type', TypeProperty(_type)), ('id', IDProperty(_type)),
        ('created_by_ref', ReferenceProperty(type="device_ref")),
        ('created',
         TimestampProperty(default=lambda: NOW, precision='millisecond')),
        ('modified',
         TimestampProperty(default=lambda: NOW, precision='millisecond')),
        ('first_observed', TimestampProperty(required=True)),
        ('last_observed', TimestampProperty(required=True)),
        ('number_observed', IntegerProperty(required=True)),
        ('objects', ObservableProperty()), ('revoked', BooleanProperty()),
        ('labels', ListProperty(StringProperty)),
        ('external_references', ListProperty(ExternalReference)),
        ('object_marking_refs',
         ListProperty(ReferenceProperty(type="marking-definition"))),
        ('granular_markings', ListProperty(GranularMarking)),
        ('device_ref', DeviceProperty('device'))
    ])
Esempio n. 3
0
def test_integer_property_invalid(value):
    int_prop = IntegerProperty()
    with pytest.raises(ValueError):
        int_prop.clean(value)
Esempio n. 4
0
def test_integer_property_valid(value):
    int_prop = IntegerProperty()
    assert int_prop.clean(value) is not None
def test_integer_property_invalid_max_with_constraints(value):
    int_prop = IntegerProperty(min=0, max=180)
    with pytest.raises(ValueError) as excinfo:
        int_prop.clean(value)
    assert "maximum value is" in str(excinfo.value)