Changes to filename and path validation (#45529)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
4739e8a207
commit
b1c2cde40b
10 changed files with 127 additions and 19 deletions
|
@ -24,6 +24,34 @@ def test_sanitize_path():
|
|||
assert util.sanitize_path("~/../test/path") == ""
|
||||
|
||||
|
||||
def test_raise_if_invalid_filename():
|
||||
"""Test raise_if_invalid_filename."""
|
||||
assert util.raise_if_invalid_filename("test") is None
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
util.raise_if_invalid_filename("/test")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
util.raise_if_invalid_filename("..test")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
util.raise_if_invalid_filename("\\test")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
util.raise_if_invalid_filename("\\../test")
|
||||
|
||||
|
||||
def test_raise_if_invalid_path():
|
||||
"""Test raise_if_invalid_path."""
|
||||
assert util.raise_if_invalid_path("test/path") is None
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
assert util.raise_if_invalid_path("~test/path")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
assert util.raise_if_invalid_path("~/../test/path")
|
||||
|
||||
|
||||
def test_slugify():
|
||||
"""Test slugify."""
|
||||
assert util.slugify("T-!@#$!#@$!$est") == "t_est"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue