コード例 #1
0
def test_sanity():
    sane_paths = [
        'foo/bar', 'foo', '/foo/bar', 'foo0', 'foo_bar', 'foo-bar', '0foo',
        '.foo', 'foo.bar'
    ]
    insane_paths = [
        '#foo', 'foo?', 'foo*', 'foo$', 'foo[bar]', 'foo`', "foo'", 'foo/*'
    ]
    for p in sane_paths:
        assert utils.is_path_sane(p)
    for p in insane_paths:
        assert not utils.is_path_sane(p)
    sane_filenames = ['foo', '0foo', '0', '.foo']
    insane_filenames = ['foo/bar']
    for p in sane_filenames:
        assert utils.is_filename_sane(p)
    for p in insane_filenames:
        assert not utils.is_filename_sane(p)
    sane_names = ['foo']
    insane_names = ["f'o"]
    for n in sane_names:
        assert utils.is_name_sane(n)
        assert utils.is_value_sane(n)
    for n in insane_names:
        assert not utils.is_name_sane(n)
        assert not utils.is_value_sane(n)
コード例 #2
0
ファイル: test_utils.py プロジェクト: ClusterLabs/crmsh
def test_sanity():
    sane_paths = ['foo/bar', 'foo', '/foo/bar', 'foo0',
                  'foo_bar', 'foo-bar', '0foo', '.foo',
                  'foo.bar']
    insane_paths = ['#foo', 'foo?', 'foo*', 'foo$', 'foo[bar]',
                    'foo`', "foo'", 'foo/*']
    for p in sane_paths:
        assert utils.is_path_sane(p)
    for p in insane_paths:
        assert not utils.is_path_sane(p)
    sane_filenames = ['foo', '0foo', '0', '.foo']
    insane_filenames = ['foo/bar']
    for p in sane_filenames:
        assert utils.is_filename_sane(p)
    for p in insane_filenames:
        assert not utils.is_filename_sane(p)
    sane_names = ['foo']
    insane_names = ["f'o"]
    for n in sane_names:
        assert utils.is_name_sane(n)
    for n in insane_names:
        assert not utils.is_name_sane(n)