Merge pull request #2124 from guardicore/2004-icmp-scan-configuration-validation
ICMPScanConfiguration docstring
This commit is contained in:
commit
ffd1773e92
|
@ -85,7 +85,7 @@ class ScanTargetConfigurationSchema(Schema):
|
|||
|
||||
|
||||
class ICMPScanConfigurationSchema(Schema):
|
||||
timeout = fields.Float()
|
||||
timeout = fields.Float(validate=validate.Range(min=0))
|
||||
|
||||
@post_load
|
||||
def _make_icmp_scan_configuration(self, data, **kwargs):
|
||||
|
|
|
@ -41,6 +41,13 @@ class ScanTargetConfiguration:
|
|||
|
||||
@dataclass(frozen=True)
|
||||
class ICMPScanConfiguration:
|
||||
"""
|
||||
A configuration for ICMP scanning
|
||||
|
||||
Attributes:
|
||||
:param timeout: Maximum time in seconds to wait for a response from the target
|
||||
"""
|
||||
|
||||
timeout: float
|
||||
|
||||
|
||||
|
|
|
@ -126,6 +126,16 @@ def test_icmp_scan_configuration_schema():
|
|||
assert config.timeout == TIMEOUT
|
||||
|
||||
|
||||
def test_icmp_scan_configuration_schema__negative_timeout():
|
||||
schema = ICMPScanConfigurationSchema()
|
||||
|
||||
negative_timeout_configuration = ICMP_CONFIGURATION.copy()
|
||||
negative_timeout_configuration["timeout"] = -1
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
schema.load(negative_timeout_configuration)
|
||||
|
||||
|
||||
def test_tcp_scan_configuration_schema():
|
||||
schema = TCPScanConfigurationSchema()
|
||||
|
||||
|
|
Loading…
Reference in New Issue