예제 #1
0
def _schema_1():
    """Returns Voluptuous Schema object."""
    return Schema({
        Required('schema'): 1,
        Required('bugzilla'): {
            Required('product'): All(str, Length(min=1)),
            Required('component'): All(str, Length(min=1)),
        },
        'origin': {
            Required('name'): All(str, Length(min=1)),
            Required('description'): All(str, Length(min=1)),
            Required('url'): FqdnUrl(),
            Required('license'): Msg(License(), msg='Unsupported License'),
            Required('release'): All(str, Length(min=1)),
        },
        'vendoring': {
            Required('url'): FqdnUrl(),
            Required('revision'): Match(r'^[a-fA-F0-9]{12,40}$'),
            'patches': Unique([str]),
            'keep': Unique([str]),
            'exclude': Unique([str]),
            'include': Unique([str]),
            'run_after': Unique([str]),
        },
    })
예제 #2
0
def test_fqdnurl_validation_without_host():
    """ test with empty host FQDN URL """
    schema = Schema({"url": FqdnUrl()})
    try:
        schema({"url": 'http://'})
    except MultipleInvalid as e:
        assert_equal(str(e),
                     "expected a Fully qualified domain name URL for dictionary value @ data['url']")
    else:
        assert False, "Did not raise Invalid for empty string url"
예제 #3
0
def test_fqdnurl_validation_with_none():
    """ test with invalid None FQDN url"""
    schema = Schema({"url": FqdnUrl()})
    try:
        schema({"url": None})
    except MultipleInvalid as e:
        assert_equal(str(e),
                     "expected a Fully qualified domain name URL for dictionary value @ data['url']")
    else:
        assert False, "Did not raise Invalid for None url"
예제 #4
0
def test_fqdn_url_without_domain_name():
    """ test with invalid fully qualified domain name url """
    schema = Schema({"url": FqdnUrl()})
    try:
        schema({"url": "http://localhost/"})
    except MultipleInvalid as e:
        assert_equal(str(e),
                     "expected a Fully qualified domain name URL for dictionary value @ data['url']")
    else:
        assert False, "Did not raise Invalid for None url"
예제 #5
0
def test_fqdnurl_validation_with_empty_string():
    """ test with empty string FQDN URL """
    schema = Schema({"url": FqdnUrl()})
    try:
        schema({"url": ''})
    except MultipleInvalid as e:
        assert str(
            e
        ) == "expected a Fully qualified domain name URL for dictionary value @ data['url']"
    else:
        assert False, "Did not raise Invalid for empty string url"
예제 #6
0
def test_fqdn_url_validation():
    """ test with valid fully qualified domain name url """
    schema = Schema({"url": FqdnUrl()})
    out_ = schema({"url": "http://example.com/"})

    assert 'http://example.com/', out_.get("url")
예제 #7
0
def _schema_1():
    """Returns Voluptuous Schema object."""
    return Schema({
        Required("schema"): 1,
        Required("bugzilla"): {
            Required("product"): All(str, Length(min=1)),
            Required("component"): All(str, Length(min=1)),
        },
        "origin": {
            Required("name"):
            All(str, Length(min=1)),
            Required("description"):
            All(str, Length(min=1)),
            Required("url"):
            FqdnUrl(),
            Required("license"):
            Msg(License(), msg="Unsupported License"),
            "license-file":
            All(str, Length(min=1)),
            Required("release"):
            All(str, Length(min=1)),
            # The following regex defines a valid git reference
            # The first group [^ ~^:?*[\]] matches 0 or more times anything
            # that isn't a Space, ~, ^, :, ?, *, or ]
            # The second group [^ ~^:?*[\]\.]+ matches 1 or more times
            # anything that isn't a Space, ~, ^, :, ?, *, [, ], or .
            Required("revision"):
            Match(r"^[^ ~^:?*[\]]*[^ ~^:?*[\]\.]+$"),
        },
        "updatebot": {
            Required("maintainer-phab"):
            All(str, Length(min=1)),
            Required("maintainer-bz"):
            All(str, Length(min=1)),
            "tracking":
            All(str, Length(min=1)),
            "tasks":
            All(
                UpdatebotTasks(),
                [{
                    Required("type"):
                    In(
                        ["vendoring", "commit-alert"],
                        msg="Invalid type specified in tasks",
                    ),
                    "branch":
                    All(str, Length(min=1)),
                    "enabled":
                    Boolean(),
                    "cc":
                    Unique([str]),
                    "needinfo":
                    Unique([str]),
                    "filter":
                    In(
                        ["none", "security", "source-extensions"],
                        msg="Invalid filter value specified in tasks",
                    ),
                    "source-extensions":
                    Unique([str]),
                    "frequency":
                    Match(r"^(every|release|[1-9][0-9]* weeks?)$"),
                    "platform":
                    Match(r"^(windows|linux)$"),
                }],
            ),
        },
        "vendoring": {
            Required("url"):
            FqdnUrl(),
            Required("source-hosting"):
            All(
                str,
                Length(min=1),
                In(VALID_SOURCE_HOSTS, msg="Unsupported Source Hosting"),
            ),
            "vendor-directory":
            All(str, Length(min=1)),
            "patches":
            Unique([str]),
            "keep":
            Unique([str]),
            "exclude":
            Unique([str]),
            "include":
            Unique([str]),
            "update-actions":
            All(
                UpdateActions(),
                [{
                    Required("action"):
                    In(
                        [
                            "copy-file",
                            "replace-in-file",
                            "run-script",
                            "delete-path",
                        ],
                        msg="Invalid action specified in update-actions",
                    ),
                    "from":
                    All(str, Length(min=1)),
                    "to":
                    All(str, Length(min=1)),
                    "pattern":
                    All(str, Length(min=1)),
                    "with":
                    All(str, Length(min=1)),
                    "file":
                    All(str, Length(min=1)),
                    "script":
                    All(str, Length(min=1)),
                    "cwd":
                    All(str, Length(min=1)),
                    "path":
                    All(str, Length(min=1)),
                }],
            ),
        },
    })
예제 #8
0
파일: moz_yaml.py 프로젝트: jt9897253/mozjs
def _schema_1():
    """Returns Voluptuous Schema object."""
    return Schema({
        Required("schema"): 1,
        Required("bugzilla"): {
            Required("product"): All(str, Length(min=1)),
            Required("component"): All(str, Length(min=1)),
        },
        "origin": {
            Required("name"): All(str, Length(min=1)),
            Required("description"): All(str, Length(min=1)),
            Required("url"): FqdnUrl(),
            Required("license"): Msg(License(), msg="Unsupported License"),
            "license-file": All(str, Length(min=1)),
            Required("release"): All(str, Length(min=1)),
            Required("revision"): Match(r"^[a-fA-F0-9]{12,40}$"),
        },
        "updatebot": {
            Required("maintainer-phab"):
            All(str, Length(min=1)),
            Required("maintainer-bz"):
            All(str, Length(min=1)),
            "tasks":
            All(
                UpdatebotTasks(),
                [{
                    Required("type"):
                    In(
                        [
                            "vendoring",
                            "commit-alert",
                        ],
                        msg="Invalid type specified in tasks",
                    ),
                    "branch":
                    All(str, Length(min=1)),
                    "enabled":
                    Boolean(),
                    "cc":
                    Unique([str]),
                    "filter":
                    In(
                        [
                            "none",
                            "security",
                            "source-extensions",
                        ],
                        msg="Invalid filter value specified in tasks",
                    ),
                    "source-extensions":
                    Unique([str]),
                }],
            ),
        },
        "vendoring": {
            Required("url"):
            FqdnUrl(),
            Required("source-hosting"):
            All(
                str,
                Length(min=1),
                In(VALID_SOURCE_HOSTS, msg="Unsupported Source Hosting"),
            ),
            "vendor-directory":
            All(str, Length(min=1)),
            "patches":
            Unique([str]),
            "keep":
            Unique([str]),
            "exclude":
            Unique([str]),
            "include":
            Unique([str]),
            "update-actions":
            All(
                UpdateActions(),
                [{
                    Required("action"):
                    In(
                        [
                            "copy-file",
                            "replace-in-file",
                            "run-script",
                            "delete-path",
                        ],
                        msg="Invalid action specified in update-actions",
                    ),
                    "from":
                    All(str, Length(min=1)),
                    "to":
                    All(str, Length(min=1)),
                    "pattern":
                    All(str, Length(min=1)),
                    "with":
                    All(str, Length(min=1)),
                    "file":
                    All(str, Length(min=1)),
                    "script":
                    All(str, Length(min=1)),
                    "cwd":
                    All(str, Length(min=1)),
                    "path":
                    All(str, Length(min=1)),
                }],
            ),
        },
    })
예제 #9
0
    return _safe_path(_st_str(v))


def _dict_value_unique(v):
    if not len(v.values()) == len(set(v.values())):
        raise Invalid('contain duplicate items')
    return v


parsed_meta_schema = Schema({
    Required('name'):
    All(Length(min=1), _safepathcomp_str),
    Required('volumes'):
    Schema(
        All(dict, Length(min=1), _dict_value_unique,
            {All(Length(min=1), _safepathcomp_str): FqdnUrl()})),
    'finished':
    bool,
    'description':
    All(str, _st_str),
    'authors':
    All([_st_str], Unique()),
})

meta_schema = parsed_meta_schema.extend({
    Required('url'):
    FqdnUrl(),
    Required('volumes_checked_time'):
    DT.datetime,
    Required('volumes_modified_time'):
    DT.datetime,