Make QSS validation errors more descriptive
This commit is contained in:
parent
de07dc1a78
commit
b017133cc6
2 changed files with 14 additions and 12 deletions
|
@ -11,26 +11,25 @@ def test_validate_noop(unvalidated_config, app):
|
|||
SecurityScannerValidator.validate(unvalidated_config, None, None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('unvalidated_config, expected_error, error_message', [
|
||||
@pytest.mark.parametrize('unvalidated_config, expected_error', [
|
||||
({
|
||||
'TESTING': True,
|
||||
'DISTRIBUTED_STORAGE_PREFERENCE': [],
|
||||
'FEATURE_SECURITY_SCANNER': True,
|
||||
'SECURITY_SCANNER_ENDPOINT': 'http://invalidhost',
|
||||
}, Exception, 'Connection error when trying to connect to security scanner endpoint'),
|
||||
}, Exception),
|
||||
|
||||
({
|
||||
'TESTING': True,
|
||||
'DISTRIBUTED_STORAGE_PREFERENCE': [],
|
||||
'FEATURE_SECURITY_SCANNER': True,
|
||||
'SECURITY_SCANNER_ENDPOINT': 'http://fakesecurityscanner',
|
||||
}, None, None),
|
||||
}, None),
|
||||
])
|
||||
def test_validate(unvalidated_config, expected_error, error_message, app):
|
||||
def test_validate(unvalidated_config, expected_error, app):
|
||||
with fake_security_scanner(hostname='fakesecurityscanner'):
|
||||
if expected_error is not None:
|
||||
with pytest.raises(expected_error) as ipe:
|
||||
with pytest.raises(expected_error):
|
||||
SecurityScannerValidator.validate(unvalidated_config, None, None)
|
||||
assert ipe.value.message == error_message
|
||||
else:
|
||||
SecurityScannerValidator.validate(unvalidated_config, None, None)
|
||||
|
|
Reference in a new issue