diff options
author | Florence Blanc-Renaud <flo@redhat.com> | 2018-08-22 18:31:24 +0200 |
---|---|---|
committer | Christian Heimes <cheimes@redhat.com> | 2018-08-23 12:08:45 +0200 |
commit | 10c6258929510cb99aa162c95a57b26184a0faca (patch) | |
tree | 75cf2d30ebabf01492683fb79dfb4d1f6b64267e | |
parent | a5a619abc19af23cfb25d5ce35deb4338cee7822 (diff) | |
download | freeipa-10c6258929510cb99aa162c95a57b26184a0faca.tar.gz freeipa-10c6258929510cb99aa162c95a57b26184a0faca.tar.xz freeipa-10c6258929510cb99aa162c95a57b26184a0faca.zip |
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>
-rw-r--r-- | ipatests/test_cmdline/test_cli.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ipatests/test_cmdline/test_cli.py b/ipatests/test_cmdline/test_cli.py index 2b9d859d4..4dafcc4b1 100644 --- a/ipatests/test_cmdline/test_cli.py +++ b/ipatests/test_cmdline/test_cli.py @@ -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 |