diff --git a/src/tests/multihost/basic/test_sssctl_config_check.py b/src/tests/multihost/basic/test_sssctl_config_check.py index f003a8d196..f70967e605 100644 --- a/src/tests/multihost/basic/test_sssctl_config_check.py +++ b/src/tests/multihost/basic/test_sssctl_config_check.py @@ -9,8 +9,11 @@ import re +import pytest + class TestSssctlConfigCheck(object): + @pytest.mark.converted('test_sssctl_config_check.py', 'test_sssctl_config_check__typo_option_name') def test_verify_typo_option_name(self, multihost): """ :title: sssctl: Verify typos in option name (not value) @@ -41,6 +44,7 @@ def test_verify_typo_option_name(self, multihost): multihost.master[0].run_command(['/bin/cp', '-a', cfgput, cfgget], raiseonerr=False) + @pytest.mark.converted('test_sssctl_config_check.py', 'test_sssctl_config_check__typo_domain_name') def test_verify_typo_domain_name(self, multihost): """ :title: sssctl: Verify typos in domain name of configuration file @@ -70,6 +74,7 @@ def test_verify_typo_domain_name(self, multihost): multihost.master[0].run_command(['/bin/cp', '-a', cfgput, cfgget], raiseonerr=False) + @pytest.mark.converted('test_sssctl_config_check.py', 'test_sssctl_config_check__misplaced_option') def test_misplaced_option(self, multihost): """ :title: sssctl: Verify misplace options in default configuration file diff --git a/src/tests/system/tests/test_sssctl_config_check.py b/src/tests/system/tests/test_sssctl_config_check.py new file mode 100644 index 0000000000..14b3cfe273 --- /dev/null +++ b/src/tests/system/tests/test_sssctl_config_check.py @@ -0,0 +1,91 @@ +""" +sssctl config-check Test Cases + +:requirement: IDM-SSSD-REQ: Status utility +""" + +from __future__ import annotations + +import re + +import pytest +from pytest_mh.ssh import SSHProcessError +from sssd_test_framework.roles.client import Client +from sssd_test_framework.topology import KnownTopology + + +@pytest.mark.topology(KnownTopology.Client) +def test_sssctl_config_check__typo_option_name(client: Client): + """ + :title: sssctl config-check detects mistyped option name + :setup: + 1. Add wrong_option to domain section + 2. Start SSSD, without config check + :steps: + 1. Call sssctl config-check + 2. Check error message + :expectedresults: + 1. config-check detects an error in config + 2. Error message is properly set + :customerscenario: False + """ + client.sssd.common.local() + client.sssd.dom("test")["wrong_option"] = "true" + + client.sssd.start(check_config=False) + + result = client.sssctl.config_check() + assert result.rc != 0, "Config-check did not detect misconfigured config" + + pattern = re.compile(r"Attribute 'wrong_option' is not allowed.*") + assert pattern.search(result.stdout), "Wrong error message was returned" + + +@pytest.mark.topology(KnownTopology.Client) +def test_sssctl_config_check__typo_domain_name(client: Client): + """ + :title: sssctl config-check detects mistyped domain name + :setup: + 1. Create mistyped domain ("domain/") + 2. Start SSSD + :steps: + 1. Call sssctl config-check, implicitly + 2. Check error message + :expectedresults: + 1. config-check detects an error in config + 2. Error message is properly set + :customerscenario: False + """ + client.sssd.dom("")["debug_level"] = "9" + + with pytest.raises(SSHProcessError) as ex: + client.sssd.start(raise_on_error=True, check_config=True) + + assert ex.match(r"Section \[domain\/\] is not allowed. Check for typos.*"), "Wrong error message was returned" + + +@pytest.mark.topology(KnownTopology.Client) +def test_sssctl_config_check__misplaced_option(client: Client): + """ + :title: sssctl config-check detects misplaced option + :setup: + 1. In domain set "services" to "nss, pam" + 2. Start SSSD, without config check + :steps: + 1. Call sssctl config-check + 2. Check error message + :expectedresults: + 1. config-check detects an error in config + 2. Error message is properly set + :customerscenario: False + """ + client.sssd.common.local() + client.sssd.dom("test")["services"] = "nss, pam" + + client.sssd.start(check_config=False) + + result = client.sssctl.config_check() + assert result.rc != 0, "Config-check did not detect misconfigured config" + + pattern = re.compile(r".Attribute 'services' is not allowed in section .*") + assert pattern.search(result.stdout), "Wrong error message was returned"