Test: test ipa-* commands when IPA is not configured

Add a test checking that ipa-* commands properly display
'IPA is not configured on this system' when called on a
system without IPA.

Related to: https://pagure.io/freeipa/issue/6261

Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Florence Blanc-Renaud
2018-08-22 18:31:24 +02:00
committed by Christian Heimes
parent a5a619abc1
commit 10c6258929

View File

@@ -342,3 +342,59 @@ def test_cli_fsencoding():
out, err = p.communicate()
assert p.returncode > 0, (out, err)
assert b'System encoding must be UTF-8' in err, (out, err)
IPA_NOT_CONFIGURED = b'IPA is not configured on this system'
IPA_CLIENT_NOT_CONFIGURED = b'IPA client is not configured on this system'
@pytest.mark.needs_ipaapi
@pytest.mark.skipif(
os.geteuid() != 0 or os.path.isfile('/etc/ipa/default.conf'),
reason="Must have root privileges to run this test "
"and IPA must not be installed")
@pytest.mark.parametrize(
"args, retcode, output, error",
[
# Commands delivered by the client pkg
(['ipa'], 1, None, IPA_CLIENT_NOT_CONFIGURED),
(['ipa-certupdate'], 1, None, IPA_CLIENT_NOT_CONFIGURED),
(['ipa-client-automount'], 1, IPA_CLIENT_NOT_CONFIGURED, None),
# Commands delivered by the server pkg
(['ipa-adtrust-install'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-advise'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-backup'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-cacert-manage'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-ca-install'], 1, None,
b'IPA server is not configured on this system'),
(['ipa-compat-manage'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-csreplica-manage'], 1, None, IPA_NOT_CONFIGURED),
(['ipactl', 'status'], 4, None, b'IPA is not configured'),
(['ipa-dns-install'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-kra-install'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-ldap-updater',
'/usr/share/ipa/updates/05-pre_upgrade_plugins.update'],
2, None, IPA_NOT_CONFIGURED),
(['ipa-managed-entries'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-nis-manage'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-pkinit-manage'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-replica-manage', 'list'], 1, IPA_NOT_CONFIGURED, None),
(['ipa-server-certinstall'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-server-upgrade'], 2, None, IPA_NOT_CONFIGURED),
(['ipa-winsync-migrate'], 1, None, IPA_NOT_CONFIGURED)
])
def test_command_ipa_not_installed(args, retcode, output, error):
"""
Test that the commands properly return that IPA client|server is not
configured on this system.
Launch the command specified in args.
Check that the exit code is as expected and that stdout and stderr
contain the expected strings.
"""
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
assert retcode == p.returncode
if output:
assert output in out
if error:
assert error in err