Skip to content

Commit

Permalink
tests: multihost/basic/sssctl_config_check.py converted
Browse files Browse the repository at this point in the history
Reviewed-by: Iker Pedrosa <[email protected]>
Reviewed-by: Jakub Vávra <[email protected]>
  • Loading branch information
patriki01 authored and pbrezina committed Jul 26, 2023
1 parent e3dd7cf commit 5ced015
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tests/multihost/basic/test_sssctl_config_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
91 changes: 91 additions & 0 deletions src/tests/system/tests/test_sssctl_config_check.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 5ced015

Please sign in to comment.