예제 #1
0
파일: test_roles.py 프로젝트: keith923/jsl
def test_document_field():
    class B(Document):
        name = Var({
            'response': StringField(required=True),
            'request': StringField(),
        })

    class A(Document):
        id = Var({'response': StringField(required=True)})
        b = DocumentField(B)

    field = DocumentField(A)

    assert list(field.walk()) == [field]

    assert (sorted(field.walk(through_document_fields=True), key=id) ==
            sorted([field, A.b], key=id))

    assert (sorted(field.walk(role='response', through_document_fields=True), key=id) ==
            sorted([
                field,
                A.b,
                A.resolve_field('id', 'response').value,
                B.resolve_field('name', 'response').value,
            ], key=id))

    assert sorted(field.walk(through_document_fields=True, role='request'), key=id) == sorted([
        field,
        A.b,
        B.resolve_field('name', 'request').value,
    ], key=id)
예제 #2
0
class BaseNormalization(Document):
    """Base class for a normalization configuration."""

    domain_name = None

    class TimestampInfo(Document):
        field = StringField(required=True)
        format = StringField(required=True)

    class Fields(Document):
        scope = StringField()
        mapping = DictField()

    name = StringField(required=True)
    filter_query = BooleanField(default=False)
    os_types = ArrayField(StringField(), required=False)
    domain = StringField(required=True)
    strict = BooleanField(required=True)
    timestamp = DocumentField(TimestampInfo(), required=True)
    fields = DocumentField(Fields(), required=True)

    events = DictField(additional_properties=DictField(
        {
            'enum':
            DictField(additional_properties=DictField(
                additional_properties=StringField())),
            'mapping':
            DictField(),
            'filter':
            StringField(required=True)
        },
        required=True))
예제 #3
0
class InputsPage(DocumentWithoutAddProp):
    title = StringField(required=True, max_length=60)
    description = StringField(max_length=200)
    table = DocumentField(InputsTable, as_ref=True, required=True)
    services = ArrayField(DictField(
        properties={
            "name": StringField(required=True, pattern="^[0-9a-zA-Z][0-9a-zA-Z_-]*$", max_length=50),
            "title": StringField(required=True, max_length=100),
            "entity": ArrayField(DocumentField(InputsEntity, as_ref=True), required=True),
            "options": DocumentField(Hooks, as_ref=True),
            "groups": ArrayField(DictField(
                properties={
                    "options": DictField(
                        properties={
                            "isExpandable": BooleanField(),
                            "expand": BooleanField()
                        }
                    ),
                    "label": StringField(required=True, max_length=100),
                    "field": ArrayField(StringField(required=True, pattern="^\w+$"))
                }
            ), required=False),
            "style": StringField(required=False, enum=["page", "dialog"]),
            "hook": DictField(required=False),
            "conf": StringField(required=False, max_length=100),
            "restHandlerName": StringField(required=False, max_length=100)
        }
    ), required=True)
    menu = DictField(required=False)
예제 #4
0
class Alerts(DocumentWithoutAddProp):
    name = StringField(required=True,
                       pattern="^[a-zA-Z0-9_]+$",
                       max_length=100)
    label = StringField(required=True, max_length=100)
    description = StringField(required=True)
    activeResponse = DictField(properties={
        "task":
        ArrayField(StringField(required=True), required=True, min_items=1),
        "supportsAdhoc":
        BooleanField(required=True),
        "subject":
        ArrayField(StringField(required=True), required=True, min_items=1),
        "category":
        ArrayField(StringField(required=True), required=True, min_items=1),
        "technology":
        ArrayField(DocumentField(Technology, as_ref=True),
                   required=True,
                   min_items=1),
        "drilldownUri":
        StringField(required=False),
        "sourcetype":
        StringField(required=False, pattern="^[a-zA-Z0-9:-_]+$", max_length=50)
    },
                               required=False)
    entity = ArrayField(DocumentField(AlertEntity, as_ref=True))
예제 #5
0
class JobsDocument(Document):
    infinite_loops = BooleanField()
    jobs = ArrayField(
        OneOfField(fields=[
            DocumentField(WifiJobDocument),
            DocumentField(GnssAutonomousDocument),
            DocumentField(GnssAssistedDocument),
        ]))
예제 #6
0
class TabContent(DocumentWithoutAddProp):
    entity = ArrayField(DocumentField(ConfigurationEntity, as_ref=True), required=True)
    name = StringField(required=True, pattern="^[\/\w]+$", max_length=250)
    title = StringField(required=True, max_length=50)
    options = DocumentField(Hooks, as_ref=True)
    table = DocumentField(ConfigurationTable, as_ref=True)
    conf = StringField(required=False, max_length=100)
    restHandlerName = StringField(required=False, max_length=100)
    # Provisioning tab level hook on configuration page
    hook = DocumentField(Hooks, as_ref=True)
예제 #7
0
    class Child(Base):
        class Options(object):
            definition_id = 'child'
            title = 'Child'

        b = StringField()
        c = DocumentField(RECURSIVE_REFERENCE_CONSTANT)
예제 #8
0
    class Normalization(BaseNormalization):
        """Normalization schema for a specific domain."""

        domain_name = domain_schema['name']
        domain = StringField(enum=[domain_name], required=True)

        class Fields(BaseNormalization.Fields):
            mapping = StrictDict(
                {k: StringField()
                 for k in domain_schema['fields']})

        fields = DocumentField(Fields())

        events = DictField({
            event_name: StrictDict({
                'enum':
                StrictDict({
                    enum_name: StrictDict({
                        enum_option: StringField()
                        for enum_option in enum_options
                    })
                    for enum_name, enum_options in event_info.get('enum',
                                                                  {}).items()
                }),
                'mapping':
                StrictDict(
                    {k: StringField()
                     for k in event_info.get('fields', [])}),
                'filter':
                StringField(required=True)
            })
            for event_name, event_info in domain_schema['events'].items()
        })
예제 #9
0
class Analytic(Document):
    """Schema for an individual analytic."""

    metadata = DocumentField(AnalyticMetadata,
                             required=True,
                             additional_properties=True)
    query = StringField(required=True)
예제 #10
0
class GnssAssistedDocument(CommonJobDocument):
    gnss_assisted_option = GnssOptionField()
    gnss_assisted_capture_mode = GnssCaptureModeField()
    gnss_assisted_nb_satellite = NumberField(multiple_of=1,
                                             minimum=0,
                                             maximum=255)
    gnss_assisted_antenna_selection = GnssAntennaSelectionField()
    gnss_assisted_constellations = ArrayField(GnssConstellationField())
    assisted_coordinate = DocumentField(AssistedCoordinateDocument)
예제 #11
0
class Domain(Document):
    """Meta schema for defining a query domain."""
    class EventInfo(Document):
        enum = DictField(
            additional_properties=ArrayField(StringField(eql_name)))
        fields = ArrayField(StringField(eql_name))

    name = StringField(required=True)
    fields = ArrayField(StringField(), required=True)
    events = DictField(additional_properties=DocumentField(EventInfo()))
예제 #12
0
def test_document_field():
    class B(Document):
        name = Var(
            response=StringField(required=True),
            request=StringField()
        )

    class A(Document):
        id = Var(response=StringField(required=True))
        b = DocumentField(B)

    field = DocumentField(A)

    # test iter_fields method
    assert list(field.iter_fields()) == [A.b]
    assert (sorted(list(field.iter_fields(role='response')), key=id) ==
            sorted([A.b, A.id.values['response']], key=id))

    # test walk method
    w = list(field.walk())
    assert w == [field]

    w = list(field.walk(through_document_fields=True))
    assert w == [field, A.b]

    w = list(field.walk(through_document_fields=True, role='response'))
    assert (sorted(w, key=id) ==
            sorted([field, A.b, A.id.values['response'], B.name.values['response']], key=id))

    w = list(field.walk(through_document_fields=True, role='request'))
    assert sorted(w, key=id) == sorted([field, A.b, B.name.values['request']], key=id)

    class X(Document):
        pass
    class Y(Document):
        pass
    field = DocumentField(Var({
        'role_1': X,
        'role_2': Y
    }))
    assert field.get_document_cls() is None
    assert field.get_document_cls(role='role_1') == X
    assert field.get_document_cls(role='role_2') == Y
class JobsDocument(Document):
    infinite_loops = BooleanField(
        description="Configures the repetition of the jobs. If set to true, the job file will be repeated infinitely. If set to false, the field test will end at the end of the last job in this file."
    )
    scan_interval = NumberField(
        minimum=0,
        multiple_of=1,
        description="Number of seconds to wait between two consecutive list of jobs execution. Useful only if infinite_loops is true. Value in seconds. 0 means that there is no wait between list of jobs.",
        required=True,
    )
    jobs = ArrayField(
        OneOfField(
            fields=[
                DocumentField(WifiJobDocument),
                DocumentField(GnssAutonomousDocument),
                DocumentField(GnssAssistedDocument),
            ]
        ),
        description="Array of jobs description to be executed during field tests.",
    )
예제 #14
0
파일: test_roles.py 프로젝트: keith923/jsl
    class Task(Document):
        class Options(object):
            title = 'Task'
            description = 'A task.'
            definition_id = 'task'

        id = IntField(required=Var({'response': True}))
        name = StringField(required=True, min_length=5)
        type = StringField(required=True, enum=['TYPE_1', 'TYPE_2'])
        created_at = DateTimeField(required=True)
        author = Var({'response': DocumentField(User)})
예제 #15
0
    class User(Document):
        class Options(object):
            roles_to_propagate = not_(PARTIAL_RESPONSE_ROLE)

        with Scope(DB_ROLE) as db:
            db._id = StringField(required=True)
            db.version = StringField(required=True)
        with Scope(lambda r: r.startswith(RESPONSE_ROLE) or r == REQUEST_ROLE) as response:
            response.id = StringField(required=when_not(PARTIAL_RESPONSE_ROLE))
        with Scope(not_(REQUEST_ROLE)) as not_request:
            not_request.messages = ArrayField(DocumentField(Message), required=when_not(PARTIAL_RESPONSE_ROLE))
class GnssAssistedDocument(CommonGnssJobDocument):
    gnss_assisted_option = GnssOptionField()
    gnss_assisted_capture_mode = GnssCaptureModeField()
    gnss_assisted_nb_satellite = NumberField(
        multiple_of=1,
        minimum=0,
        maximum=255,
        description="Number of satellites to fetch during GNSS scan operation.",
    )
    gnss_assisted_antenna_selection = GnssAntennaSelectionField()
    gnss_assisted_constellations = ArrayField(GnssConstellationField())
    assisted_coordinate = DocumentField(AssistedCoordinateDocument)
예제 #17
0
파일: test_roles.py 프로젝트: keith923/jsl
def test_document_field():
    class B(Document):
        name = Var({
            'response': StringField(required=True),
            'request': StringField(),
        })

    class A(Document):
        id = Var({'response': StringField(required=True)})
        b = DocumentField(B)

    field = DocumentField(A)

    assert list(field.walk()) == [field]

    assert (sorted(field.walk(through_document_fields=True),
                   key=id) == sorted([field, A.b], key=id))

    assert (sorted(field.walk(role='response', through_document_fields=True),
                   key=id) == sorted([
                       field,
                       A.b,
                       A.resolve_field('id', 'response').value,
                       B.resolve_field('name', 'response').value,
                   ],
                                     key=id))

    assert sorted(field.walk(through_document_fields=True, role='request'),
                  key=id) == sorted([
                      field,
                      A.b,
                      B.resolve_field('name', 'request').value,
                  ],
                                    key=id)
예제 #18
0
def test_document_field():
    class A(Document):
        a = a
        b = b

    field = DocumentField(A)
    assert set(field.iter_all_fields()) == set([a, b])

    class B(Document):
        field = Var({'a': a, 'b': b})
        b = c

    field = DocumentField(B)
    assert set(field.iter_all_fields()) == set([a, b, c])

    class C(Document):
        pass

    field = DocumentField(C)
    assert set(field.iter_all_fields()) == set([])
예제 #19
0
class AlertEntity(DocumentWithoutAddProp):
    field = StringField(required=True, pattern="^\w+$")
    label = StringField(required=True, max_length=30)
    type = StringField(required=True,
                       enum=["text", "singleSelect", "checkbox", "radio", "singleSelectSplunkSearch"])
    help = StringField(max_length=200)
    defaultValue = OneOfField([
        NumberField(),
        StringField(max_length=250),
        BooleanField()
    ])
    required = BooleanField()
    search = StringField(max_length=200)
    valueField = StringField(max_length=200)
    labelField = StringField(max_length=200)
    options = DictField(
        properties={
            "items": ArrayField(DocumentField(ValueLabelPair, as_ref=True))
        }
    )
예제 #20
0
def test_document_field():
    class A(Document):
        a = a
        b = b

    field = DocumentField(A)
    assert set(field.iter_all_fields()) == set([a, b])

    class B(Document):
        field = Var({
            'a': a,
            'b': b
        })
        b = c

    field = DocumentField(B)
    assert set(field.iter_all_fields()) == set([a, b, c])

    class C(Document):
        pass

    field = DocumentField(C)
    assert set(field.iter_all_fields()) == set([])
예제 #21
0
class ErrorList(Document):
    value = ArrayField(items=DocumentField(Error, as_ref=True),
                       additional_items=False)
예제 #22
0
class CheckOutput(Document):
    checks = ArrayField(items=DocumentField(CheckEntry, as_ref=True),
                        additional_items=False)
예제 #23
0
class Entity(DocumentWithoutAddProp):
    field = StringField(required=True, pattern="^\w+$")
    label = StringField(required=True, max_length=30)
    type = StringField(required=True,
                       enum=["custom", "text", "singleSelect", "checkbox", "multipleSelect", "radio", "placeholder", "oauth", "helpLink"])
    help = StringField(max_length=200)
    tooltip = StringField(max_length=250)
    defaultValue = OneOfField([
        NumberField(),
        StringField(max_length=250),
        BooleanField()
    ])
    options = DictField(
        properties={
            "disableSearch": BooleanField(),
            "autoCompleteFields": OneOfField([
                ArrayField(DictField(
                    properties={
                        "label": StringField(required=True, max_length=150),
                        "children": ArrayField(DocumentField(ValueLabelPair, as_ref=True), required=True)
                    }
                )),
                ArrayField(DocumentField(ValueLabelPair, as_ref=True))
            ]),
            "endpointUrl": StringField(max_length=350),
            "denyList": StringField(max_length=350),
            "allowList": StringField(max_length=350),
            "delimiter": StringField(max_length=1),
            "items": ArrayField(DocumentField(ValueLabelPair, as_ref=True)),
            "referenceName": StringField(max_length=250),
            "enable": BooleanField(),
            "placeholder": StringField(max_length=250),
            "display": BooleanField(),
            "labelField": StringField(max_length=250),
            "src": StringField(max_length=250),
            "defaultValue": StringField(max_length=250),
            "disableonEdit": BooleanField(),
            "basic": ArrayField(DocumentField(OAuthFields, as_ref=True)),
            "oauth": ArrayField(DocumentField(OAuthFields, as_ref=True)),
            "auth_type": ArrayField(StringField(max_length=100)),
            "auth_label": StringField(max_length=250),
            "oauth_popup_width": NumberField(),
            "oauth_popup_height": NumberField(),
            "oauth_timeout": NumberField(),
            "auth_code_endpoint": StringField(max_length=350),
            "access_token_endpoint": StringField(max_length=350),
            "text": StringField(max_length=50),
            "link": StringField()
        }
    )
    required = BooleanField()
    encrypted = BooleanField()
    # List of inbuilt field validator
    validators = ArrayField(AnyOfField([
        DocumentField(StringValidator, as_ref=True),
        DocumentField(NumberValidator, as_ref=True),
        DocumentField(RegexValidator, as_ref=True),
        DocumentField(EmailValidator, as_ref=True),
        DocumentField(Ipv4Validator, as_ref=True),
        DocumentField(UrlValidator, as_ref=True),
        DocumentField(DateValidator, as_ref=True)
    ]))
예제 #24
0
class ConfigurationPage(DocumentWithoutAddProp):
    title = StringField(required=True, max_length=60)
    description = StringField(max_length=200)
    tabs = ArrayField(DocumentField(TabContent, as_ref=True), required=True, min_items=1)
예제 #25
0
파일: test_roles.py 프로젝트: keith923/jsl
 class A(Document):
     a = Var({'role_1': DocumentField('self')})
예제 #26
0
class Pages(DocumentWithoutAddProp):
    configuration = DocumentField(ConfigurationPage, as_ref=True, required=False)
    inputs = DocumentField(InputsPage, as_ref=True, required=False)
예제 #27
0
파일: test_roles.py 프로젝트: keith923/jsl
 class A(Document):
     id = Var({'response': StringField(required=True)})
     b = DocumentField(B)
예제 #28
0
class UCCConfig(DocumentWithoutAddProp):
    meta = DocumentField(Meta, as_ref=True, required=True)
    pages = DocumentField(Pages, as_ref=True, required=True)
    alerts = ArrayField(DocumentField(Alerts, as_ref=True), required=False, min_items=1)