URL: https://github.com/SSSD/sssd/pull/5473 Author: madhuriupadhye Title: #5473: Tests: alltests: Check default debug level of sssd and corresponding logs Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/5473/head:pr5473 git checkout pr5473
From 2e5488201ed272ba9313c132884e737c2f9c4af7 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 22 Jan 2021 15:35:17 +0530 Subject: [PATCH 1/6] Check default debug level of sssd and corresponding logs It consists of four test cases: 1. Check default debug level when sssd start successfully 2. Check default debug level by successful authentication of the user 3. Check default level as 0 and 1 4. Check default level as 2 5. Check SBUS code should not trigger failure message during modules startup Verifies: Issues: #5422 #5425 Bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1893159 https://bugzilla.redhat.com/show_bug.cgi?id=1915319 Signed-off-by: Madhuri Upadhye <mupad...@redhat.com> --- src/tests/multihost/alltests/pytest.ini | 1 + .../alltests/test_default_debug_level.py | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 src/tests/multihost/alltests/test_default_debug_level.py diff --git a/src/tests/multihost/alltests/pytest.ini b/src/tests/multihost/alltests/pytest.ini index 7f625aa262..3ddc05302b 100644 --- a/src/tests/multihost/alltests/pytest.ini +++ b/src/tests/multihost/alltests/pytest.ini @@ -23,6 +23,7 @@ markers = fips: Tests related to fips when auth_provider is krb5 ssh: Tests related to ssh responder ldaplibdebuglevel: Test ldap_library_debug_level option + defaultdebuglevel: Test default debug level sssd tier1: tier1 test cases with run time of aproximately 60 minutes tier1_2: tier1 test cases split to keep runtime upto 60 minutes tier2: tier2 test cases diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py new file mode 100644 index 0000000000..1d4f6d7c40 --- /dev/null +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -0,0 +1,122 @@ +from __future__ import print_function +import re +import pytest +from sssd.testlib.common.utils import sssdTools +from sssd.testlib.common.expect import pexpect_ssh +from constants import ds_instance_name + + +@pytest.mark.usefixtures('setup_sssd', 'create_posix_usersgroups') +@pytest.mark.defaultdebuglevel +class TestDefaultDebugLevel(object): + """ Check sssd default debug level """ + @pytest.mark.tier1 + def test_0001_check_default_debug_level(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default debug level by authenticating the + user + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + user = 'foo1@%s' % ds_instance_name + client = pexpect_ssh(multihost.client[0].sys_hostname, user, + 'Secret123', debug=False) + client.login(login_timeout=30, sync_multiplier=5, + auto_prompt_reset=False) + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find1 = re.compile(r'0x0020') + find2 = re.compile(r'0x0010') + find3 = re.compile(r'0x0040') + find4 = re.compile(r'Starting with debug level = 0x0070') + if not (find1.search(log_str) or find2.search(log_str) or + find3.search(log_str)) and find4.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0002_bz1893159(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default level as 0 and 1 + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + multihost.client[0].service_sssd('stop') + chmod_cmd = 'chmod 444 /etc/sssd/sssd.conf' + cmd = multihost.client[0].run_command(chmod_cmd, raiseonerr=False) + if cmd.returncode == 1: + status = 'PASS' + tools.remove_sss_cache('/var/log/sssd') + multihost.client[0].run_command('systemctl start sssd', + raiseonerr=False) + slog = '/var/log/sssd/sssd.log' + log_str = multihost.client[0].get_file_contents(slog).decode('utf-8') + find1 = re.compile(r'0x0020') + find2 = re.compile(r'0x0010') + if not find1.search(log_str) and find2.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + restore_sssd = 'chmod 600 /etc/sssd/sssd.conf' + multihost.client[0].run_command(restore_sssd, raiseonerr=False) + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0003_bz1893159(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default level 2 + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + cmd_kill = 'kill -SIGUSR2 $(pidof sssd)' + multihost.client[0].run_command(cmd_kill, raiseonerr=False) + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find = re.compile(r'.0x0040.') + if not find.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0004_bz1915319(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during + modules startup + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find = re.compile(r'Unable to remove key.*') + if not find.search(log_str): + status = 'PASS' + else: + status = 'FAIL' + assert status == 'PASS' From e017f12516c9e10e481522beb73383491534f0c7 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 29 Jan 2021 11:09:15 +0530 Subject: [PATCH 2/6] Split the first test case in two cases: 1. Check default debug level when sssd start successfully 2. Check default debug level by successful authentication of the user Also change the test number of other test cases Signed-off-by: Madhuri Upadhye <mupad...@redhat.com> --- .../alltests/test_default_debug_level.py | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 1d4f6d7c40..55275f64bf 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -13,38 +13,66 @@ class TestDefaultDebugLevel(object): @pytest.mark.tier1 def test_0001_check_default_debug_level(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check default debug level by authenticating the - user + @Title: IDM-SSSD-TC: Check default debug level when sssd start + successfully """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} tools = sssdTools(multihost.client[0]) tools.sssd_conf(section, domain_params, action='delete') + # stop sssd, delete sssd logs and cache, start sssd + tools.clear_sssd_cache() + log_list = ['sssd', 'sssd_example1', 'sssd_nss', + 'sssd_pam', 'sssd_implicit_files'] + for log_filename in log_list: + log = '/var/log/sssd/%s.log' % log_filename + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', + '0x2000', '0x4000', '0x10000'] + for level in debug_level: + regex = r'%s' % level + if re.compile(regex).search(log_str): + assert False + else: + assert True + + @pytest.mark.tier1 + def test_0002_check_default_level_with_auth(self, multihost, + backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default debug level by + successful authentication of the user + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + # stop sssd, delete logs and cache, start sssd tools.clear_sssd_cache() user = 'foo1@%s' % ds_instance_name + # Authenticate user client = pexpect_ssh(multihost.client[0].sys_hostname, user, 'Secret123', debug=False) client.login(login_timeout=30, sync_multiplier=5, auto_prompt_reset=False) - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] - for log in log_list: - log = '/var/log/sssd/%s' % log + log_list = ['sssd', 'sssd_example1', 'sssd_nss', + 'sssd_pam', 'sssd_implicit_files'] + for log_filename in log_list: + log = '/var/log/sssd/%s.log' % log_filename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') - find1 = re.compile(r'0x0020') - find2 = re.compile(r'0x0010') - find3 = re.compile(r'0x0040') - find4 = re.compile(r'Starting with debug level = 0x0070') - if not (find1.search(log_str) or find2.search(log_str) or - find3.search(log_str)) and find4.search(log_str): - status = 'FAIL' - else: - status = 'PASS' - assert status == 'PASS' + debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', + '0x2000', '0x4000', '0x10000'] + for level in debug_level: + regex = r'%s' % level + if re.compile(regex).search(log_str): + assert False + else: + assert True @pytest.mark.tier1 - def test_0002_bz1893159(self, multihost, backupsssdconf): + def test_0003_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level as 0 and 1 """ @@ -73,7 +101,7 @@ def test_0002_bz1893159(self, multihost, backupsssdconf): assert status == 'PASS' @pytest.mark.tier1 - def test_0003_bz1893159(self, multihost, backupsssdconf): + def test_0004_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level 2 """ @@ -98,7 +126,7 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): assert status == 'PASS' @pytest.mark.tier1 - def test_0004_bz1915319(self, multihost, backupsssdconf): + def test_0005_bz1915319(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during modules startup From f0a53d923499bc3bca826f7e387c5f0bbbb0ac53 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 29 Jan 2021 11:20:27 +0530 Subject: [PATCH 3/6] Update the assert statements. Update the test case name five to Check SBUS code should not trigger failure message during modules startup --- .../alltests/test_default_debug_level.py | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 55275f64bf..0261267a09 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -83,8 +83,7 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): multihost.client[0].service_sssd('stop') chmod_cmd = 'chmod 444 /etc/sssd/sssd.conf' cmd = multihost.client[0].run_command(chmod_cmd, raiseonerr=False) - if cmd.returncode == 1: - status = 'PASS' + assert cmd.returncode == 0 tools.remove_sss_cache('/var/log/sssd') multihost.client[0].run_command('systemctl start sssd', raiseonerr=False) @@ -92,13 +91,12 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): log_str = multihost.client[0].get_file_contents(slog).decode('utf-8') find1 = re.compile(r'0x0020') find2 = re.compile(r'0x0010') - if not find1.search(log_str) and find2.search(log_str): - status = 'FAIL' - else: - status = 'PASS' restore_sssd = 'chmod 600 /etc/sssd/sssd.conf' multihost.client[0].run_command(restore_sssd, raiseonerr=False) - assert status == 'PASS' + if not find1.search(log_str) and find2.search(log_str): + assert False + else: + assert True @pytest.mark.tier1 def test_0004_bz1893159(self, multihost, backupsssdconf): @@ -112,39 +110,37 @@ def test_0004_bz1893159(self, multihost, backupsssdconf): tools.clear_sssd_cache() cmd_kill = 'kill -SIGUSR2 $(pidof sssd)' multihost.client[0].run_command(cmd_kill, raiseonerr=False) - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] - for log in log_list: - log = '/var/log/sssd/%s' % log + log_list = ['sssd', 'sssd_example1', 'sssd_nss', 'sssd_pam', + 'sssd_implicit_files'] + for logfilename in log_list: + log = '/var/log/sssd/%s.log' % logfilename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') find = re.compile(r'.0x0040.') if not find.search(log_str): - status = 'FAIL' + assert False else: - status = 'PASS' - assert status == 'PASS' + assert True @pytest.mark.tier1 def test_0005_bz1915319(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during - modules startup + @Title: IDM-SSSD-TC: Check SBUS code should not trigger failure + message during modules startup """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} tools = sssdTools(multihost.client[0]) tools.sssd_conf(section, domain_params, action='delete') tools.clear_sssd_cache() - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] + log_list = ['sssd', 'sssd_example1', 'sssd_nss', 'sssd_pam', + 'sssd_implicit_files'] for log in log_list: - log = '/var/log/sssd/%s' % log + log = '/var/log/sssd/%s.log' % log log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') find = re.compile(r'Unable to remove key.*') if not find.search(log_str): - status = 'PASS' + assert True else: - status = 'FAIL' - assert status == 'PASS' + assert False From 7db5489f876cbd29d7944f055ba2dea16c1be2d0 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 22 Jan 2021 15:35:17 +0530 Subject: [PATCH 4/6] Check default debug level of sssd and corresponding logs It consists of five test cases: 1. Check default debug level when sssd start successfully 2. Check default debug level by successful authentication of the user 3. Check default level as 0 and 1 4. Check default level as 2 5. Check SBUS code should not trigger failure message during modules startup Verifies: Issues: #5422 #5425 Bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1893159 https://bugzilla.redhat.com/show_bug.cgi?id=1915319 Signed-off-by: Madhuri Upadhye <mupad...@redhat.com> --- src/tests/multihost/alltests/pytest.ini | 1 + .../alltests/test_default_debug_level.py | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 src/tests/multihost/alltests/test_default_debug_level.py diff --git a/src/tests/multihost/alltests/pytest.ini b/src/tests/multihost/alltests/pytest.ini index 7f625aa262..3ddc05302b 100644 --- a/src/tests/multihost/alltests/pytest.ini +++ b/src/tests/multihost/alltests/pytest.ini @@ -23,6 +23,7 @@ markers = fips: Tests related to fips when auth_provider is krb5 ssh: Tests related to ssh responder ldaplibdebuglevel: Test ldap_library_debug_level option + defaultdebuglevel: Test default debug level sssd tier1: tier1 test cases with run time of aproximately 60 minutes tier1_2: tier1 test cases split to keep runtime upto 60 minutes tier2: tier2 test cases diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py new file mode 100644 index 0000000000..1d4f6d7c40 --- /dev/null +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -0,0 +1,122 @@ +from __future__ import print_function +import re +import pytest +from sssd.testlib.common.utils import sssdTools +from sssd.testlib.common.expect import pexpect_ssh +from constants import ds_instance_name + + +@pytest.mark.usefixtures('setup_sssd', 'create_posix_usersgroups') +@pytest.mark.defaultdebuglevel +class TestDefaultDebugLevel(object): + """ Check sssd default debug level """ + @pytest.mark.tier1 + def test_0001_check_default_debug_level(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default debug level by authenticating the + user + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + user = 'foo1@%s' % ds_instance_name + client = pexpect_ssh(multihost.client[0].sys_hostname, user, + 'Secret123', debug=False) + client.login(login_timeout=30, sync_multiplier=5, + auto_prompt_reset=False) + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find1 = re.compile(r'0x0020') + find2 = re.compile(r'0x0010') + find3 = re.compile(r'0x0040') + find4 = re.compile(r'Starting with debug level = 0x0070') + if not (find1.search(log_str) or find2.search(log_str) or + find3.search(log_str)) and find4.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0002_bz1893159(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default level as 0 and 1 + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + multihost.client[0].service_sssd('stop') + chmod_cmd = 'chmod 444 /etc/sssd/sssd.conf' + cmd = multihost.client[0].run_command(chmod_cmd, raiseonerr=False) + if cmd.returncode == 1: + status = 'PASS' + tools.remove_sss_cache('/var/log/sssd') + multihost.client[0].run_command('systemctl start sssd', + raiseonerr=False) + slog = '/var/log/sssd/sssd.log' + log_str = multihost.client[0].get_file_contents(slog).decode('utf-8') + find1 = re.compile(r'0x0020') + find2 = re.compile(r'0x0010') + if not find1.search(log_str) and find2.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + restore_sssd = 'chmod 600 /etc/sssd/sssd.conf' + multihost.client[0].run_command(restore_sssd, raiseonerr=False) + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0003_bz1893159(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default level 2 + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + cmd_kill = 'kill -SIGUSR2 $(pidof sssd)' + multihost.client[0].run_command(cmd_kill, raiseonerr=False) + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find = re.compile(r'.0x0040.') + if not find.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0004_bz1915319(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during + modules startup + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find = re.compile(r'Unable to remove key.*') + if not find.search(log_str): + status = 'PASS' + else: + status = 'FAIL' + assert status == 'PASS' From f75eeff860999e4f667fa8c98dca2c269daed354 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 29 Jan 2021 11:09:15 +0530 Subject: [PATCH 5/6] Split the first test case in two cases: 1. Check default debug level when sssd start successfully 2. Check default debug level by successful authentication of the user Also change the test number of other test cases Signed-off-by: Madhuri Upadhye <mupad...@redhat.com> --- .../alltests/test_default_debug_level.py | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 1d4f6d7c40..55275f64bf 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -13,38 +13,66 @@ class TestDefaultDebugLevel(object): @pytest.mark.tier1 def test_0001_check_default_debug_level(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check default debug level by authenticating the - user + @Title: IDM-SSSD-TC: Check default debug level when sssd start + successfully """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} tools = sssdTools(multihost.client[0]) tools.sssd_conf(section, domain_params, action='delete') + # stop sssd, delete sssd logs and cache, start sssd + tools.clear_sssd_cache() + log_list = ['sssd', 'sssd_example1', 'sssd_nss', + 'sssd_pam', 'sssd_implicit_files'] + for log_filename in log_list: + log = '/var/log/sssd/%s.log' % log_filename + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', + '0x2000', '0x4000', '0x10000'] + for level in debug_level: + regex = r'%s' % level + if re.compile(regex).search(log_str): + assert False + else: + assert True + + @pytest.mark.tier1 + def test_0002_check_default_level_with_auth(self, multihost, + backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default debug level by + successful authentication of the user + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + # stop sssd, delete logs and cache, start sssd tools.clear_sssd_cache() user = 'foo1@%s' % ds_instance_name + # Authenticate user client = pexpect_ssh(multihost.client[0].sys_hostname, user, 'Secret123', debug=False) client.login(login_timeout=30, sync_multiplier=5, auto_prompt_reset=False) - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] - for log in log_list: - log = '/var/log/sssd/%s' % log + log_list = ['sssd', 'sssd_example1', 'sssd_nss', + 'sssd_pam', 'sssd_implicit_files'] + for log_filename in log_list: + log = '/var/log/sssd/%s.log' % log_filename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') - find1 = re.compile(r'0x0020') - find2 = re.compile(r'0x0010') - find3 = re.compile(r'0x0040') - find4 = re.compile(r'Starting with debug level = 0x0070') - if not (find1.search(log_str) or find2.search(log_str) or - find3.search(log_str)) and find4.search(log_str): - status = 'FAIL' - else: - status = 'PASS' - assert status == 'PASS' + debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', + '0x2000', '0x4000', '0x10000'] + for level in debug_level: + regex = r'%s' % level + if re.compile(regex).search(log_str): + assert False + else: + assert True @pytest.mark.tier1 - def test_0002_bz1893159(self, multihost, backupsssdconf): + def test_0003_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level as 0 and 1 """ @@ -73,7 +101,7 @@ def test_0002_bz1893159(self, multihost, backupsssdconf): assert status == 'PASS' @pytest.mark.tier1 - def test_0003_bz1893159(self, multihost, backupsssdconf): + def test_0004_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level 2 """ @@ -98,7 +126,7 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): assert status == 'PASS' @pytest.mark.tier1 - def test_0004_bz1915319(self, multihost, backupsssdconf): + def test_0005_bz1915319(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during modules startup From 420fd89c67922dd7c7687cc77345e7854aec323c Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 29 Jan 2021 11:20:27 +0530 Subject: [PATCH 6/6] Update the assert statements. Update the test case name five to Check SBUS code should not trigger failure message during modules startup --- .../alltests/test_default_debug_level.py | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 55275f64bf..0261267a09 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -83,8 +83,7 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): multihost.client[0].service_sssd('stop') chmod_cmd = 'chmod 444 /etc/sssd/sssd.conf' cmd = multihost.client[0].run_command(chmod_cmd, raiseonerr=False) - if cmd.returncode == 1: - status = 'PASS' + assert cmd.returncode == 0 tools.remove_sss_cache('/var/log/sssd') multihost.client[0].run_command('systemctl start sssd', raiseonerr=False) @@ -92,13 +91,12 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): log_str = multihost.client[0].get_file_contents(slog).decode('utf-8') find1 = re.compile(r'0x0020') find2 = re.compile(r'0x0010') - if not find1.search(log_str) and find2.search(log_str): - status = 'FAIL' - else: - status = 'PASS' restore_sssd = 'chmod 600 /etc/sssd/sssd.conf' multihost.client[0].run_command(restore_sssd, raiseonerr=False) - assert status == 'PASS' + if not find1.search(log_str) and find2.search(log_str): + assert False + else: + assert True @pytest.mark.tier1 def test_0004_bz1893159(self, multihost, backupsssdconf): @@ -112,39 +110,37 @@ def test_0004_bz1893159(self, multihost, backupsssdconf): tools.clear_sssd_cache() cmd_kill = 'kill -SIGUSR2 $(pidof sssd)' multihost.client[0].run_command(cmd_kill, raiseonerr=False) - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] - for log in log_list: - log = '/var/log/sssd/%s' % log + log_list = ['sssd', 'sssd_example1', 'sssd_nss', 'sssd_pam', + 'sssd_implicit_files'] + for logfilename in log_list: + log = '/var/log/sssd/%s.log' % logfilename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') find = re.compile(r'.0x0040.') if not find.search(log_str): - status = 'FAIL' + assert False else: - status = 'PASS' - assert status == 'PASS' + assert True @pytest.mark.tier1 def test_0005_bz1915319(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during - modules startup + @Title: IDM-SSSD-TC: Check SBUS code should not trigger failure + message during modules startup """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} tools = sssdTools(multihost.client[0]) tools.sssd_conf(section, domain_params, action='delete') tools.clear_sssd_cache() - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] + log_list = ['sssd', 'sssd_example1', 'sssd_nss', 'sssd_pam', + 'sssd_implicit_files'] for log in log_list: - log = '/var/log/sssd/%s' % log + log = '/var/log/sssd/%s.log' % log log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') find = re.compile(r'Unable to remove key.*') if not find.search(log_str): - status = 'PASS' + assert True else: - status = 'FAIL' - assert status == 'PASS' + assert False
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org