mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
diagnostics: Add parameters to DiagnosticCheck
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
ab213138e0
commit
4612df954d
13 files changed
+131
-42
No files matched your search
@@ -149,7 +149,9 @@ def diagnose_url(url, kind=None, env=None, check_certificate=True,
|
||||
except FileNotFoundError:
|
||||
result = Result.ERROR
|
||||
|
||||
parameters = {'url': url}
|
||||
if kind:
|
||||
parameters['kind'] = kind
|
||||
check_id = f'apache-url-kind-{url}-{kind}'
|
||||
template = gettext_lazy('Access URL {url} on tcp{kind}')
|
||||
description = format_lazy(template, url=url, kind=kind)
|
||||
@@ -158,7 +160,7 @@ def diagnose_url(url, kind=None, env=None, check_certificate=True,
|
||||
template = gettext_lazy('Access URL {url}')
|
||||
description = format_lazy(template, url=url)
|
||||
|
||||
return DiagnosticCheck(check_id, description, result)
|
||||
return DiagnosticCheck(check_id, description, result, parameters)
|
||||
|
||||
|
||||
def diagnose_url_on_all(url, expect_redirects=False, **kwargs):
|
||||
|
||||
@@ -246,17 +246,18 @@ def test_diagnose_url(get_addresses, check):
|
||||
'wrapper': 'test-wrapper',
|
||||
'expected_output': 'test-expected'
|
||||
}
|
||||
parameters = {key: args[key] for key in ['url', 'kind']}
|
||||
check.return_value = True
|
||||
result = diagnose_url(**args)
|
||||
assert result == DiagnosticCheck(
|
||||
'apache-url-kind-https://localhost/test-4',
|
||||
'Access URL https://localhost/test on tcp4', Result.PASSED)
|
||||
'Access URL https://localhost/test on tcp4', Result.PASSED, parameters)
|
||||
|
||||
check.return_value = False
|
||||
result = diagnose_url(**args)
|
||||
assert result == DiagnosticCheck(
|
||||
'apache-url-kind-https://localhost/test-4',
|
||||
'Access URL https://localhost/test on tcp4', Result.FAILED)
|
||||
'Access URL https://localhost/test on tcp4', Result.FAILED, parameters)
|
||||
|
||||
del args['kind']
|
||||
args['url'] = 'https://{host}/test'
|
||||
@@ -272,14 +273,24 @@ def test_diagnose_url(get_addresses, check):
|
||||
'numeric': False,
|
||||
'url_address': 'test-host-2'
|
||||
}]
|
||||
parameters = [
|
||||
{
|
||||
'url': 'https://test-host-1/test',
|
||||
'kind': '4'
|
||||
},
|
||||
{
|
||||
'url': 'https://test-host-2/test',
|
||||
'kind': '6'
|
||||
},
|
||||
]
|
||||
results = diagnose_url_on_all(**args)
|
||||
assert results == [
|
||||
DiagnosticCheck('apache-url-kind-https://test-host-1/test-4',
|
||||
'Access URL https://test-host-1/test on tcp4',
|
||||
Result.PASSED),
|
||||
Result.PASSED, parameters[0]),
|
||||
DiagnosticCheck('apache-url-kind-https://test-host-2/test-6',
|
||||
'Access URL https://test-host-2/test on tcp6',
|
||||
Result.PASSED),
|
||||
Result.PASSED, parameters[1]),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user