summaryrefslogtreecommitdiff
path: root/testenv/tests/validators
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-10-15 08:21:04 +0300
committerDevaev Maxim <[email protected]>2019-10-15 08:31:00 +0300
commit7b4818ed1502271137b6860511f11b4f415d8230 (patch)
treea570fcaa8828666434b01ea3a0c1c82544ff0429 /testenv/tests/validators
parente58ad66da98917d66f58731d041d4ddbe18befed (diff)
msd: allow any printable characters in image name
Diffstat (limited to 'testenv/tests/validators')
-rw-r--r--testenv/tests/validators/test_kvm.py26
-rw-r--r--testenv/tests/validators/test_os.py48
2 files changed, 48 insertions, 26 deletions
diff --git a/testenv/tests/validators/test_kvm.py b/testenv/tests/validators/test_kvm.py
index c592b5ac..3bcbd0bf 100644
--- a/testenv/tests/validators/test_kvm.py
+++ b/testenv/tests/validators/test_kvm.py
@@ -32,7 +32,6 @@ from kvmd.validators.kvm import valid_atx_button
from kvmd.validators.kvm import valid_log_seek
from kvmd.validators.kvm import valid_stream_quality
from kvmd.validators.kvm import valid_stream_fps
-from kvmd.validators.kvm import valid_msd_image_name
from kvmd.validators.kvm import valid_hid_key
from kvmd.validators.kvm import valid_hid_mouse_move
from kvmd.validators.kvm import valid_hid_mouse_button
@@ -106,31 +105,6 @@ def test_fail__valid_stream_fps(arg: Any) -> None:
# =====
[email protected]("arg, retval", [
- ("archlinux-2018.07.01-i686.iso", "archlinux-2018.07.01-i686.iso"),
- ("archlinux-2018.07.01-x86_64.iso", "archlinux-2018.07.01-x86_64.iso"),
- ("dsl-4.11.rc1.iso", "dsl-4.11.rc1.iso"),
- ("systemrescuecd-x86-5.3.1.iso", "systemrescuecd-x86-5.3.1.iso"),
- ("ubuntu-16.04.5-desktop-i386.iso", "ubuntu-16.04.5-desktop-i386.iso"),
- (".", "_"),
- ("..", "__"),
- ("/..", "_.."),
- ("/..\0", "_.._"),
- ("/root/..", "_root_.."),
- (" тест(){}[ \t].iso\t", "тест()__[__].iso"),
- ("?" * 1000, "_" * 255),
-])
-def test_ok__valid_msd_image_name(arg: Any, retval: str) -> None:
- assert valid_msd_image_name(arg) == retval
-
-
[email protected]("arg", ["", None])
-def test_fail__valid_msd_image_name(arg: Any) -> None:
- with pytest.raises(ValidatorError):
- print(valid_msd_image_name(arg))
-
-
-# =====
def test_ok__valid_hid_key() -> None:
for key in KEYMAP:
print(valid_hid_key(key))
diff --git a/testenv/tests/validators/test_os.py b/testenv/tests/validators/test_os.py
index b280b4b3..353cb9e0 100644
--- a/testenv/tests/validators/test_os.py
+++ b/testenv/tests/validators/test_os.py
@@ -30,6 +30,7 @@ import pytest
from kvmd.validators import ValidatorError
from kvmd.validators.os import valid_abs_path
from kvmd.validators.os import valid_abs_path_exists
+from kvmd.validators.os import valid_printable_filename
from kvmd.validators.os import valid_unix_mode
from kvmd.validators.os import valid_command
@@ -80,6 +81,53 @@ def test_fail__valid_abs_path_exists(arg: Any) -> None:
# =====
[email protected]("arg, retval", [
+ ("archlinux-2018.07.01-i686.iso", "archlinux-2018.07.01-i686.iso"),
+ ("archlinux-2018.07.01-x86_64.iso", "archlinux-2018.07.01-x86_64.iso"),
+ ("dsl-4.11.rc1.iso", "dsl-4.11.rc1.iso"),
+ ("systemrescuecd-x86-5.3.1.iso", "systemrescuecd-x86-5.3.1.iso"),
+ ("ubuntu-16.04.5-desktop-i386.iso", "ubuntu-16.04.5-desktop-i386.iso"),
+ (" тест(){}[ \t].iso\t", "тест(){}[ _].iso"),
+ ("\n" + "x" * 1000, "x" * 255),
+ ("test", "test"),
+ ("test test [test] #test$", "test test [test] #test$"),
+ (".test", ".test"),
+ ("..test", "..test"),
+ ("..тест..", "..тест.."),
+ ("..те\\ст..", "..те\\ст.."),
+ (".....", "....."),
+ (".....txt", ".....txt"),
+ (" .. .", ".. ."),
+ ("..\n.", ".._."),
+])
+def test_ok__valid_printable_filename(arg: Any, retval: str) -> None:
+ assert valid_printable_filename(arg) == retval
+
+
+ ".",
+ "..",
+ " ..",
+ "test/",
+ "/test",
+ "../test",
+ "./.",
+ "../.",
+ "./..",
+ "../..",
+ "/ ..",
+ ".. /",
+ "/.. /",
+ "",
+ " ",
+ None,
+])
+def test_fail__valid_printable_filename(arg: Any) -> None:
+ with pytest.raises(ValidatorError):
+ valid_printable_filename(arg)
+
+
+# =====
@pytest.mark.parametrize("arg", [0, 5, "1000"])
def test_ok__valid_unix_mode(arg: Any) -> None:
value = valid_unix_mode(arg)