mirror of
https://github.com/ceph/ceph
synced 2024-12-26 21:43:10 +00:00
589560e6c9
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
from .. import safepath
|
|
|
|
class TestSafepath(object):
|
|
def test_simple(self):
|
|
got = safepath.munge('foo')
|
|
assert got == 'foo'
|
|
|
|
def test_empty(self):
|
|
# really odd corner case
|
|
got = safepath.munge('')
|
|
assert got == '_'
|
|
|
|
def test_slash(self):
|
|
got = safepath.munge('/')
|
|
assert got == '_'
|
|
|
|
def test_slashslash(self):
|
|
got = safepath.munge('//')
|
|
assert got == '_'
|
|
|
|
def test_absolute(self):
|
|
got = safepath.munge('/evil')
|
|
assert got == 'evil'
|
|
|
|
def test_absolute_subdir(self):
|
|
got = safepath.munge('/evil/here')
|
|
assert got == 'evil/here'
|
|
|
|
def test_dot_leading(self):
|
|
got = safepath.munge('./foo')
|
|
assert got == 'foo'
|
|
|
|
def test_dot_middle(self):
|
|
got = safepath.munge('evil/./foo')
|
|
assert got == 'evil/foo'
|
|
|
|
def test_dot_trailing(self):
|
|
got = safepath.munge('evil/foo/.')
|
|
assert got == 'evil/foo'
|
|
|
|
def test_dotdot(self):
|
|
got = safepath.munge('../evil/foo')
|
|
assert got == '_./evil/foo'
|
|
|
|
def test_dotdot_subdir(self):
|
|
got = safepath.munge('evil/../foo')
|
|
assert got == 'evil/_./foo'
|
|
|
|
def test_hidden(self):
|
|
got = safepath.munge('.evil')
|
|
assert got == '_evil'
|
|
|
|
def test_hidden_subdir(self):
|
|
got = safepath.munge('foo/.evil')
|
|
assert got == 'foo/_evil'
|