Example #1
0
def test_validate_path():
    # a) max length is bounded by 3072 for absolute path and 2048 for
    #    relative ones.
    with pytest.raises(InvalidPath):
        validate_path(b"/foo/bar" * 3072)

    with pytest.raises(InvalidPath):
        validate_path(b"foo/bar" * 2048)

    # b) ASCII alphanumerics and -/_@ only!
    for char in string.punctuation:
        if char in "-/_@":
            continue

        with pytest.raises(InvalidPath):
            validate_path(b"/foo" + char.encode())

    # c) no trailing / -- except for root path.
    with pytest.raises(InvalidPath):
        validate_path(b"/foo/")

    # d) no //'s!.
    with pytest.raises(InvalidPath):
        validate_path(b"/foo//bar")

    # e) OK-case.
    validate_path(b"/")
Example #2
0
File: tests.py Project: brkt/pyxs
def test_validate_path():
    # a) max length is bounded by 3072 for absolute path and 2048 for
    #    relative ones.
    with pytest.raises(InvalidPath):
        validate_path("/foo/bar" * 3072)

    with pytest.raises(InvalidPath):
        validate_path("foo/bar" * 2048)

    # b) ASCII alphanumerics and -/_@ only!
    for char in string.punctuation:
        if char in "-/_@":
            continue

        with pytest.raises(InvalidPath):
            validate_path("/foo" + char)

    # c) no trailing / -- except for root path.
    with pytest.raises(InvalidPath):
        validate_path("/foo/")

    # d) no //'s!.
    with pytest.raises(InvalidPath):
        validate_path("/foo//bar")

    try:
        validate_path("/")
    except InvalidPath as p:
        pytest.fail("{0} is prefectly valid, baby :)".format(p.args))
Example #3
0
def test_validate_path():
    # a) max length is bounded by 3072 for absolute path and 2048 for
    #    relative ones.
    with pytest.raises(InvalidPath):
        validate_path("/foo/bar" * 3072)

    with pytest.raises(InvalidPath):
        validate_path("foo/bar" * 2048)

    # b) ASCII alphanumerics and -/_@ only!
    for char in string.punctuation:
        if char in "-/_@": continue

        with pytest.raises(InvalidPath):
            validate_path("/foo" + char)

    # c) no trailing / -- except for root path.
    with pytest.raises(InvalidPath):
        validate_path("/foo/")

    # d) no //'s!.
    with pytest.raises(InvalidPath):
        validate_path("/foo//bar")

    try:
        validate_path("/")
    except InvalidPath as p:
        pytest.fail("{0} is prefectly valid, baby :)".format(p.args))