UT: Add tests for CustomPBAConfiguration filename validation

This commit is contained in:
Shreya Malviya 2022-07-26 16:30:10 +05:30
parent bcf7a2e8ff
commit 83e56a9028
1 changed files with 25 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import json
from copy import deepcopy
import pytest
from marshmallow import ValidationError
from tests.common.example_agent_configuration import (
AGENT_CONFIGURATION,
BLOCKED_IPS,
@ -68,6 +69,30 @@ def test_custom_pba_configuration_schema():
assert config.windows_filename == WINDOWS_FILENAME
def test_custom_pba_configuration_schema__empty_filename_allowed():
schema = CustomPBAConfigurationSchema()
empty_filename_configuration = CUSTOM_PBA_CONFIGURATION.copy()
empty_filename_configuration.update({"linux_filename": ""})
config = schema.load(empty_filename_configuration)
assert config.linux_command == LINUX_COMMAND
assert config.linux_filename == ""
assert config.windows_command == WINDOWS_COMMAND
assert config.windows_filename == WINDOWS_FILENAME
def test_custom_pba_configuration_schema__invalid_filename():
schema = CustomPBAConfigurationSchema()
invalid_filename_configuration = CUSTOM_PBA_CONFIGURATION.copy()
invalid_filename_configuration["linux_filename"] = "???"
with pytest.raises(ValidationError):
schema.load(invalid_filename_configuration)
def test_scan_target_configuration():
schema = ScanTargetConfigurationSchema()