URL: https://github.com/SSSD/sssd/pull/5473
Author: madhuriupadhye
 Title: #5473: Tests: alltests: Check default debug level of sssd and 
corresponding logs
Action: opened

PR body:
"""
Check default debug level of sssd and corresponding logs
It consists of four test cases:
  1. Check the default debug level by authenticating the
     user
  2. Check default level as 0 and 1
  3. Check default level as 2
  4. Check SBUS code triggers 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>
"""

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 bb3347f3997e55c333f7686667e916370b4c9b86 Mon Sep 17 00:00:00 2001
From: Madhuri Upadhye <mupad...@redhat.com>
Date: Fri, 22 Jan 2021 15:35:17 +0530
Subject: [PATCH] Check default debug level of sssd and corresponding logs

It consists of four test cases:
  1. Check the default debug level by authenticating the
     user
  2. Check default level as 0 and 1
  3. Check default level as 2
  4. Check SBUS code triggers 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'
_______________________________________________
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

Reply via email to