UT: Add tests for checking that validators in ScanTargetConfiguration work

This commit is contained in:
Shreya Malviya 2022-08-31 00:43:53 +05:30
parent f7f0047868
commit fa1620ebb9
1 changed files with 29 additions and 0 deletions

View File

@ -98,6 +98,35 @@ def test_scan_target_configuration():
assert config.subnets == tuple(SUBNETS)
@pytest.mark.parametrize("invalid_blocked_ip_list", [["abc"], [1]])
def test_scan_target_configuration__invalid_blocked_ips(invalid_blocked_ip_list):
invalid_blocked_ips = SCAN_TARGET_CONFIGURATION.copy()
invalid_blocked_ips["blocked_ips"] = invalid_blocked_ip_list
with pytest.raises(ValueError):
ScanTargetConfiguration(**invalid_blocked_ips)
@pytest.mark.parametrize(
"invalid_inaccessible_subnets_list", [["1-2-3"], ["0.0.0.0/33"], ["www.invalid-.com"]]
)
def test_scan_target_configuration__invalid_inaccessible_subnets(invalid_inaccessible_subnets_list):
invalid_inaccessible_subnets = SCAN_TARGET_CONFIGURATION.copy()
invalid_inaccessible_subnets["inaccessible_subnets"] = invalid_inaccessible_subnets_list
with pytest.raises(ValueError):
ScanTargetConfiguration(**invalid_inaccessible_subnets)
@pytest.mark.parametrize("invalid_subnets_list", [["1-2-3"], ["0.0.0.0/33"], ["www.invalid-.com"]])
def test_scan_target_configuration__invalid_subnets(invalid_subnets_list):
invalid_subnets = SCAN_TARGET_CONFIGURATION.copy()
invalid_subnets["subnets"] = invalid_subnets_list
with pytest.raises(ValueError):
ScanTargetConfiguration(**invalid_subnets)
def test_icmp_scan_configuration_schema():
config = ICMPScanConfiguration(**ICMP_CONFIGURATION)