From 58ce293909b95510b7b507d9dab0604728c087f5 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 26 Jul 2022 18:38:44 +0530 Subject: [PATCH] UT: Add cases to CustomPBAConfigurationSchema filename validation tests --- .../common/configuration/test_agent_configuration.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py index 1991e726e..7941b9c17 100644 --- a/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/configuration/test_agent_configuration.py @@ -83,21 +83,25 @@ def test_custom_pba_configuration_schema__empty_filenames_allowed(): assert config.windows_filename == "" -def test_custom_pba_configuration_schema__invalid_linux_filename(): +@pytest.mark.parametrize("linux_filename", ["\\", "\\\\\\"]) +def test_custom_pba_configuration_schema__invalid_linux_filename(linux_filename): schema = CustomPBAConfigurationSchema() invalid_filename_configuration = CUSTOM_PBA_CONFIGURATION.copy() - invalid_filename_configuration["linux_filename"] = "\\" + invalid_filename_configuration["linux_filename"] = linux_filename with pytest.raises(ValidationError): schema.load(invalid_filename_configuration) -def test_custom_pba_configuration_schema__invalid_windows_filename(): +@pytest.mark.parametrize( + "windows_filename", ["CON", "CON.txt", "con.abc.pdf", " ", "abc.", "a?b", "d\\e"] +) +def test_custom_pba_configuration_schema__invalid_windows_filename(windows_filename): schema = CustomPBAConfigurationSchema() invalid_filename_configuration = CUSTOM_PBA_CONFIGURATION.copy() - invalid_filename_configuration["windows_filename"] = "?" + invalid_filename_configuration["windows_filename"] = windows_filename with pytest.raises(ValidationError): schema.load(invalid_filename_configuration)