-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: multihost/basic/sssctl_config_check.py converted
Reviewed-by: Iker Pedrosa <[email protected]> Reviewed-by: Jakub Vávra <[email protected]> (cherry picked from commit 5ced015)
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |