mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add additional backup & restore checks
https://fedorahosted.org/freeipa/ticket/3893 Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
parent
c80a59eff4
commit
93422a54a3
@ -65,6 +65,12 @@ def check_admin_in_cli(host):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def check_admin_in_id(host):
|
||||||
|
result = host.run_command(['id', 'admin'])
|
||||||
|
assert 'admin' in result.stdout_text, result.stdout_text
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def check_certs(host):
|
def check_certs(host):
|
||||||
result = host.run_command(['ipa', 'cert-find'])
|
result = host.run_command(['ipa', 'cert-find'])
|
||||||
assert re.search('^Number of entries returned [1-9]\d*$',
|
assert re.search('^Number of entries returned [1-9]\d*$',
|
||||||
@ -72,20 +78,43 @@ def check_certs(host):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def check_dns(host):
|
||||||
|
result = host.run_command(['host', host.hostname, 'localhost'])
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def check_kinit(host):
|
||||||
|
result = host.run_command(['kinit', 'admin'],
|
||||||
|
stdin_text=host.config.admin_password)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
CHECKS = [
|
||||||
|
(check_admin_in_ldap, assert_entries_equal),
|
||||||
|
(check_admin_in_cli, assert_results_equal),
|
||||||
|
(check_admin_in_id, assert_results_equal),
|
||||||
|
(check_certs, assert_results_equal),
|
||||||
|
(check_dns, assert_results_equal),
|
||||||
|
(check_kinit, assert_results_equal),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def restore_checker(host):
|
def restore_checker(host):
|
||||||
"""Check that the IPA at host works the same at context enter and exit"""
|
"""Check that the IPA at host works the same at context enter and exit"""
|
||||||
tasks.kinit_admin(host)
|
tasks.kinit_admin(host)
|
||||||
|
|
||||||
admin_entry = check_admin_in_ldap(host)
|
results = []
|
||||||
admin_cli_result = check_admin_in_cli(host)
|
for check, assert_func in CHECKS:
|
||||||
certs_output = check_certs(host)
|
log.info('Storing result for %s', check)
|
||||||
|
results.append(check(host))
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
assert_entries_equal(admin_entry, check_admin_in_ldap(host))
|
for (check, assert_func), expected in zip(CHECKS, results):
|
||||||
assert_results_equal(admin_cli_result, check_admin_in_cli(host))
|
log.info('Checking result for %s', check)
|
||||||
assert_results_equal(certs_output, check_certs(host))
|
got = check(host)
|
||||||
|
assert_func(expected, got)
|
||||||
|
|
||||||
|
|
||||||
def backup(host):
|
def backup(host):
|
||||||
|
Loading…
Reference in New Issue
Block a user