From 78ffb8861364c6a56507413244c366028472f372 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Mon, 19 Aug 2019 12:28:30 +0200
Subject: [PATCH 01/19] ci: use python2 version of pytest

Fedora 31 changed symlink of /usr/bin/py.test from pytest2 to pytest3.
We need to run the python2 version in order to run our tests with python2.

Reviewed-by: Sumit Bose <sbose@redhat.com>
---
 src/external/intgcheck.m4  | 7 +++++--
 src/tests/intg/Makefile.am | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4
index 60a7bf306d..8a8df5b3e4 100644
--- a/src/external/intgcheck.m4
+++ b/src/external/intgcheck.m4
@@ -1,7 +1,10 @@
 AC_CHECK_PROG([HAVE_FAKEROOT], [fakeroot], [yes], [no])
 
+dnl Check for pytest binary. When available, we will use py.test-2 for python2
+dnl version. If it is not available we will try to use py.test.
 AC_PATH_PROG([PYTEST], [py.test])
-AS_IF([test -n "$PYTEST"], [HAVE_PYTEST=yes], [HAVE_PYTEST=no])
+AC_PATH_PROG([PYTEST2], [py.test-2], [$PYTEST])
+AS_IF([test -n "$PYTEST2"], [HAVE_PYTEST2=yes], [HAVE_PYTEST2=no])
 
 dnl Check for variable and fail unless value is "yes"
 dnl The second argument will be printed in error message in case of error
@@ -26,7 +29,7 @@ AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
         SSS_INTGCHECK_REQ([HAVE_LDAPMODIFY], [ldapmodify])
         SSS_INTGCHECK_REQ([HAVE_FAKEROOT], [fakeroot])
         SSS_INTGCHECK_REQ([HAVE_PYTHON2], [python2])
-        SSS_INTGCHECK_REQ([HAVE_PYTEST], [pytest])
+        SSS_INTGCHECK_REQ([HAVE_PYTEST2], [pytest2])
         SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [python-ldap])
         SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [pyldb])
     fi
diff --git a/src/tests/intg/Makefile.am b/src/tests/intg/Makefile.am
index 884c903b60..2e64d03aac 100644
--- a/src/tests/intg/Makefile.am
+++ b/src/tests/intg/Makefile.am
@@ -170,5 +170,5 @@ intgcheck-installed: config.py passwd group pam_sss_service pam_sss_alt_service
 	DBUS_SESSION_BUS_ADDRESS="unix:path=$$DBUS_SOCK_DIR/fake_socket" \
 	DBUS_SYSTEM_BUS_ADDRESS="unix:path=$$DBUS_SOCK_DIR/system_bus_socket" \
 	DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="$$DBUS_SYSTEM_BUS_ADDRESS" \
-	    fakeroot $(PYTHON2) $(PYTEST) -v -r a --tb=native $(INTGCHECK_PYTEST_ARGS) .
+	    fakeroot $(PYTHON2) $(PYTEST2) -v -r a --tb=native $(INTGCHECK_PYTEST_ARGS) .
 	rm -f $(DESTDIR)$(logpath)/*

From 13fd5a274e688b8ecefd0c37654f7fad1710ba50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Tue, 20 Aug 2019 12:00:26 +0200
Subject: [PATCH 02/19] ci: pep8 was renamed to pycodestyle in Fedora 31

Reviewed-by: Sumit Bose <sbose@redhat.com>
---
 contrib/ci/deps.sh | 2 +-
 contrib/ci/run     | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/contrib/ci/deps.sh b/contrib/ci/deps.sh
index bc811a2c33..73471aeae4 100644
--- a/contrib/ci/deps.sh
+++ b/contrib/ci/deps.sh
@@ -55,7 +55,7 @@ if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
 
     if [[ "$DISTRO_BRANCH" == -redhat-fedora-3[1-9]* ]]; then
         DEPS_LIST+=(
-            python3-pep8
+            python3-pycodestyle
         )
     else
         DEPS_LIST+=(
diff --git a/contrib/ci/run b/contrib/ci/run
index bf29f87531..488b964408 100755
--- a/contrib/ci/run
+++ b/contrib/ci/run
@@ -58,6 +58,12 @@ declare BASE_DIR=`pwd`
 declare MODERATE=false
 declare RIGOROUS=false
 
+# pep8 was renamed to pycodestyle
+declare PEP8_BIN="pep8"
+if which pycodestyle &> /dev/null; then
+  PEP8_BIN="pycodestyle"
+fi
+
 # Output program usage information.
 function usage()
 {
@@ -398,7 +404,7 @@ if [[ "$DISTRO_BRANCH" != redhat-* ]]; then
     PEP8_IGNORE+=",E722"
 fi
 stage pep8          find . -path ./src/config -prune -o \
-                           -name \*.py -exec pep8 $PEP8_IGNORE {} +
+                           -name \*.py -exec $PEP8_BIN $PEP8_IGNORE {} +
 stage autoreconf    autoreconf --install --force
 run_build debug     build_debug
 if "$RIGOROUS"; then

From aca98fb6a7d562c3efd258ecb4aa744bcb4e941d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Fri, 23 Aug 2019 11:28:13 +0200
Subject: [PATCH 03/19] ci: remove left overs from previous rebase

If previous run of a PR failed to rebase, the code was left in rebase
in progress and was not correctly overwritten by new changes in the
patches.

Reviewed-by: Tomas Halman <thalman@redhat.com>
---
 Jenkinsfile | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index 2ebfe52ece..75ae3fb8d0 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -122,6 +122,18 @@ class CI {
       ctx.env.CHANGE_TARGET
     )
 
+    // Remove left overs from previous rebase if there are any
+    ctx.sh String.format(
+      'git -C %s rebase --abort || :',
+      "${ctx.env.WORKSPACE}/sssd"
+    )
+
+    // Just to be sure
+    ctx.sh String.format(
+      'rm -fr "%s/.git/rebase-apply" || :',
+      "${ctx.env.WORKSPACE}/sssd"
+    )
+
     ctx.sh String.format(
       'git -C %s rebase origin/%s',
       "${ctx.env.WORKSPACE}/sssd",

From 53acb9aca3b59de40299e2485c4e3a25da23357b Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 04/19] BUILD: Add macro for checking python3 modules
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/external/python.m4 | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/external/python.m4 b/src/external/python.m4
index b45f9331a0..8bb352a33c 100644
--- a/src/external/python.m4
+++ b/src/external/python.m4
@@ -126,3 +126,30 @@ AC_DEFUN([AM_PYTHON2_MODULE],[
         fi
     fi
 ])
+
+AC_DEFUN([AM_PYTHON3_MODULE],[
+    if test x"$PYTHON3" = x; then
+        if test -n "$2"; then
+            AC_MSG_ERROR([cannot look for $1 module: Python 3 not found])
+        else
+            AC_MSG_NOTICE([cannot look for $1 module: Python 3 not found])
+            eval AS_TR_CPP(HAVE_PY3MOD_$1)=no
+        fi
+    else
+        AC_MSG_CHECKING($(basename $PYTHON3) module: $1)
+        $PYTHON3 -c "import $1" 2>/dev/null
+        if test $? -eq 0; then
+            AC_MSG_RESULT(yes)
+            eval AS_TR_CPP(HAVE_PY3MOD_$1)=yes
+        else
+            AC_MSG_RESULT(no)
+            eval AS_TR_CPP(HAVE_PY3MOD_$1)=no
+            #
+            if test -n "$2"
+            then
+                AC_MSG_ERROR(failed to find required module $1)
+                exit 1
+            fi
+        fi
+    fi
+])

From ee8eb538aa3db4b11a162f1d005eafd8c8e73663 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 05/19] BUILD: Fix typo of detecting python module for
 intgcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/external/intgcheck.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4
index 8a8df5b3e4..d65b0aeab7 100644
--- a/src/external/intgcheck.m4
+++ b/src/external/intgcheck.m4
@@ -31,7 +31,7 @@ AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
         SSS_INTGCHECK_REQ([HAVE_PYTHON2], [python2])
         SSS_INTGCHECK_REQ([HAVE_PYTEST2], [pytest2])
         SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [python-ldap])
-        SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [pyldb])
+        SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDB], [pyldb])
     fi
 ])
 

From aad92c0b363c9f175f4d84b8b4b51c8052758971 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 06/19] BUILD: Move checking of python2 modules for intgcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 configure.ac              | 2 --
 src/external/intgcheck.m4 | 7 +++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9df463d9c8..7f23393f70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -372,8 +372,6 @@ AM_CONDITIONAL([BUILD_PYTHON_BINDINGS],
                [test x"$with_python2_bindings" = xyes \
                      -o x"$with_python3_bindings" = xyes])
 
-AM_PYTHON2_MODULE([ldap])
-
 if test x$HAVE_SELINUX != x; then
     AM_CHECK_SELINUX
 fi
diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4
index d65b0aeab7..22e4cfea18 100644
--- a/src/external/intgcheck.m4
+++ b/src/external/intgcheck.m4
@@ -28,6 +28,13 @@ AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
         SSS_INTGCHECK_REQ([HAVE_SLAPD], [slapd])
         SSS_INTGCHECK_REQ([HAVE_LDAPMODIFY], [ldapmodify])
         SSS_INTGCHECK_REQ([HAVE_FAKEROOT], [fakeroot])
+
+        AM_PYTHON2_MODULE([ldap])
+        AM_PYTHON2_MODULE([ldb])
+        AM_PYTHON2_MODULE([requests])
+        AM_PYTHON2_MODULE([dbus])
+        AM_PYTHON2_MODULE([psutil])
+
         SSS_INTGCHECK_REQ([HAVE_PYTHON2], [python2])
         SSS_INTGCHECK_REQ([HAVE_PYTEST2], [pytest2])
         SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [python-ldap])

From 54bedf00f7c3445f52f5460ac3a90868ae86b8cd Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 07/19] BUILD: Add macro for checking pytest for intgcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/external/intgcheck.m4 |  1 +
 src/external/python.m4    | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4
index 22e4cfea18..ade6eecf5a 100644
--- a/src/external/intgcheck.m4
+++ b/src/external/intgcheck.m4
@@ -29,6 +29,7 @@ AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
         SSS_INTGCHECK_REQ([HAVE_LDAPMODIFY], [ldapmodify])
         SSS_INTGCHECK_REQ([HAVE_FAKEROOT], [fakeroot])
 
+        SSS_CHECK_PYTEST([$PYTHON2], [PY2_PYTEST])
         AM_PYTHON2_MODULE([ldap])
         AM_PYTHON2_MODULE([ldb])
         AM_PYTHON2_MODULE([requests])
diff --git a/src/external/python.m4 b/src/external/python.m4
index 8bb352a33c..c20054417c 100644
--- a/src/external/python.m4
+++ b/src/external/python.m4
@@ -153,3 +153,31 @@ AC_DEFUN([AM_PYTHON3_MODULE],[
         fi
     fi
 ])
+
+dnl SYNOPSIS
+dnl
+dnl   SSS_CHECK_PYTEST(python_interpreter, have_suffix)
+dnl
+dnl DESCRIPTION
+dnl
+dnl   Checks for pytest
+AC_DEFUN([SSS_CHECK_PYTEST],[
+    if test x"$1" = x; then
+        if test -n "$2"; then
+            AC_MSG_ERROR([cannot look for pytest: $(basename $1) not found])
+        else
+            AC_MSG_NOTICE([cannot look for pytest module: $(basename $1) not found])
+            eval AS_TR_CPP(HAVE_$2)=no
+        fi
+    else
+        AC_MSG_CHECKING($(basename $1) pytest)
+        $1 -m pytest --version 2>/dev/null
+        if test $? -eq 0; then
+            AC_MSG_RESULT(yes)
+            eval AS_TR_CPP(HAVE_$2)=yes
+        else
+            AC_MSG_RESULT(no)
+            eval AS_TR_CPP(HAVE_$2)=no
+        fi
+    fi
+])

From a3cbf392af064d9ba836d25328db5da94dc0bd42 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 08/19] BUILD: Change value of variable HAVE_PYTHON2/3_BINDINGS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It will simplify detection in following patches

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 configure.ac       | 11 +++++++++--
 src/conf_macros.m4 |  4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7f23393f70..5154918b17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -316,7 +316,7 @@ AC_CHECK_PROG(HAVE_PYTHON3, python3, yes, no)
 AS_IF([test x$HAVE_PYTHON3 = xyes],
       [AC_PATH_PROG(PYTHON3, python3)])
 
-if test x$HAVE_PYTHON2_BINDINGS = x1; then
+if test x$HAVE_PYTHON2_BINDINGS = xyes; then
     AS_IF([test x$HAVE_PYTHON2 != xyes],
           [AC_MSG_ERROR([
 The program python2 was not found in search path.
@@ -342,7 +342,7 @@ them please use argument --without-python2-bindings when running configure.])])
     SSS_CLEAN_PYTHON_VARIABLES
 fi
 
-if test x$HAVE_PYTHON3_BINDINGS = x1; then
+if test x$HAVE_PYTHON3_BINDINGS = xyes; then
     AS_IF([test x$HAVE_PYTHON3 != xyes],
           [AC_MSG_ERROR([
 The program python3 was not found in search path.
@@ -368,6 +368,13 @@ them please use argument --without-python3-bindings when running configure.])])
     SSS_CLEAN_PYTHON_VARIABLES
 fi
 
+if test x$HAVE_PYTHON3_BINDINGS = xyes; then
+    PYTHON_EXEC=$PYTHON3
+else
+    PYTHON_EXEC=$PYTHON2
+fi
+AC_SUBST(PYTHON_EXEC)
+
 AM_CONDITIONAL([BUILD_PYTHON_BINDINGS],
                [test x"$with_python2_bindings" = xyes \
                      -o x"$with_python3_bindings" = xyes])
diff --git a/src/conf_macros.m4 b/src/conf_macros.m4
index 7001a3eee8..32d7a50019 100644
--- a/src/conf_macros.m4
+++ b/src/conf_macros.m4
@@ -383,7 +383,7 @@ AC_DEFUN([WITH_PYTHON2_BINDINGS],
                 [with_python2_bindings=yes]
                )
     if test x"$with_python2_bindings" = xyes; then
-        AC_SUBST([HAVE_PYTHON2_BINDINGS], [1])
+        AC_SUBST([HAVE_PYTHON2_BINDINGS], [yes])
         AC_DEFINE_UNQUOTED([HAVE_PYTHON2_BINDINGS], [1],
                            [Build with python2 bindings])
     fi
@@ -400,7 +400,7 @@ AC_DEFUN([WITH_PYTHON3_BINDINGS],
                 [with_python3_bindings=yes]
                )
     if test x"$with_python3_bindings" = xyes; then
-        AC_SUBST([HAVE_PYTHON3_BINDINGS], [1])
+        AC_SUBST([HAVE_PYTHON3_BINDINGS], [yes])
         AC_DEFINE_UNQUOTED([HAVE_PYTHON3_BINDINGS], [1],
                            [Build with python3 bindings])
     fi

From 72878964ea77f629152d1646124a47cd3b9ac684 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 09/19] BUILD: Move python checks for intgcheck to macro
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/external/intgcheck.m4 | 74 ++++++++++++++++++++++++++++++---------
 1 file changed, 57 insertions(+), 17 deletions(-)

diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4
index ade6eecf5a..66b831a1fd 100644
--- a/src/external/intgcheck.m4
+++ b/src/external/intgcheck.m4
@@ -1,11 +1,5 @@
 AC_CHECK_PROG([HAVE_FAKEROOT], [fakeroot], [yes], [no])
 
-dnl Check for pytest binary. When available, we will use py.test-2 for python2
-dnl version. If it is not available we will try to use py.test.
-AC_PATH_PROG([PYTEST], [py.test])
-AC_PATH_PROG([PYTEST2], [py.test-2], [$PYTEST])
-AS_IF([test -n "$PYTEST2"], [HAVE_PYTEST2=yes], [HAVE_PYTEST2=no])
-
 dnl Check for variable and fail unless value is "yes"
 dnl The second argument will be printed in error message in case of error
 dnl Usage:
@@ -16,6 +10,62 @@ AC_DEFUN([SSS_INTGCHECK_REQ], [
           AC_MSG_ERROR([cannot enable integration tests: $2 not found])])
 ])
 
+dnl Check for python variable and fail/warn unless value is "yes"
+dnl The second argument will be printed in error message in case of error
+dnl Any value in 3rd argument will make change error to info
+dnl Usage:
+dnl     SSS_INTGCHECK_PYTHON_REQ(variable, message, [non_fatal])
+
+AC_DEFUN([SSS_INTGCHECK_PYTHON_REQ], [
+    AS_IF([test x$$1 = xyes], [],
+          [sss_have_py_intg_deps=no
+           AS_IF([test -n "$3"],
+                 [AC_MSG_NOTICE([missing python dependency for integration tests: $2 not found])],
+                 [AC_MSG_ERROR([cannot enable integration tests: $2 not found])])
+          ])
+])
+
+dnl Check for variable and fail unless value is "yes"
+dnl The second argument will be printed in error message in case of error
+dnl Usage:
+dnl     SSS_CHECK_PYTHON_INTG_REQ(python_version, [non_fatal])
+AC_DEFUN([SSS_CHECK_PYTHON_INTG_REQ], [
+    sss_have_py_intg_deps="no"
+
+    SSS_INTGCHECK_PYTHON_REQ([HAVE_PYTHON$1_BINDINGS],
+                             [sssd python$1 bindings], [$2])
+
+    AS_IF([test x$HAVE_PYTHON$1_BINDINGS = xyes],
+          [SSS_CHECK_PYTEST([$PYTHON$1], [PY$1_PYTEST])
+           []AM_PYTHON$1_MODULE([ldap])
+           []AM_PYTHON$1_MODULE([ldb])
+           []AM_PYTHON$1_MODULE([requests])
+           []AM_PYTHON$1_MODULE([dbus])
+           []AM_PYTHON$1_MODULE([psutil])
+
+           sss_have_py_intg_deps="yes"
+
+           SSS_INTGCHECK_PYTHON_REQ([HAVE_PY$1_PYTEST],
+                                    [python$1 pytest], [$2])
+           SSS_INTGCHECK_PYTHON_REQ([HAVE_PY$1MOD_LDAP],
+                                    [python$1 module ldap], [$2])
+           SSS_INTGCHECK_PYTHON_REQ([HAVE_PY$1MOD_LDB],
+                                    [python$1 module ldb], [$2])
+           SSS_INTGCHECK_PYTHON_REQ([HAVE_PY$1MOD_REQUESTS],
+                                    [python$1 module requests], [$2])
+           SSS_INTGCHECK_PYTHON_REQ([HAVE_PY$1MOD_DBUS],
+                                    [python$1 module dbus], [$2])
+           SSS_INTGCHECK_PYTHON_REQ([HAVE_PY$1MOD_PSUTIL],
+                             [python$1 module psutil], [$2])])
+
+    AS_IF([test "x$sss_have_py_intg_deps" = xyes],
+          [HAVE_PYTHON_INTG_DEPS=yes
+           PYTHON_EXEC_INTG=$PYTHON$1
+           AC_SUBST(PYTHON_EXEC_INTG)],
+          [HAVE_PYTHON_INTG_DEPS=no])
+    unset sss_have_py_intg_deps
+])
+
 AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
     AC_ARG_ENABLE(intgcheck-reqs,
         [AS_HELP_STRING([--enable-intgcheck-reqs],
@@ -29,17 +79,7 @@ AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
         SSS_INTGCHECK_REQ([HAVE_LDAPMODIFY], [ldapmodify])
         SSS_INTGCHECK_REQ([HAVE_FAKEROOT], [fakeroot])
 
-        SSS_CHECK_PYTEST([$PYTHON2], [PY2_PYTEST])
-        AM_PYTHON2_MODULE([ldap])
-        AM_PYTHON2_MODULE([ldb])
-        AM_PYTHON2_MODULE([requests])
-        AM_PYTHON2_MODULE([dbus])
-        AM_PYTHON2_MODULE([psutil])
-
-        SSS_INTGCHECK_REQ([HAVE_PYTHON2], [python2])
-        SSS_INTGCHECK_REQ([HAVE_PYTEST2], [pytest2])
-        SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [python-ldap])
-        SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDB], [pyldb])
+        SSS_CHECK_PYTHON_INTG_REQ([2])
     fi
 ])
 

From cd036e8296a96284e4cc6de5ee44bb7ca7759a29 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:56:52 +0000
Subject: [PATCH 10/19] INTG: Do hot hardcode version of python/pytest in
 intgcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/tests/intg/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tests/intg/Makefile.am b/src/tests/intg/Makefile.am
index 2e64d03aac..f7d3a5634e 100644
--- a/src/tests/intg/Makefile.am
+++ b/src/tests/intg/Makefile.am
@@ -170,5 +170,5 @@ intgcheck-installed: config.py passwd group pam_sss_service pam_sss_alt_service
 	DBUS_SESSION_BUS_ADDRESS="unix:path=$$DBUS_SOCK_DIR/fake_socket" \
 	DBUS_SYSTEM_BUS_ADDRESS="unix:path=$$DBUS_SOCK_DIR/system_bus_socket" \
 	DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="$$DBUS_SYSTEM_BUS_ADDRESS" \
-	    fakeroot $(PYTHON2) $(PYTEST2) -v -r a --tb=native $(INTGCHECK_PYTEST_ARGS) .
+	    fakeroot $(PYTHON_EXEC_INTG) -m pytest -v -r a --tb=native $(INTGCHECK_PYTEST_ARGS) .
 	rm -f $(DESTDIR)$(logpath)/*

From 7786040dd0186da804950e7cf3b5a85eb2759821 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 23:03:31 +0000
Subject: [PATCH 11/19] BUILD: Prefer python3 for intgcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Samba 4.11.0 dropped support for python2 and thus it was also
dropped from samba related libraries (ldb ...)
which is required by integration tests

Merges: https://pagure.io/SSSD/sssd/pull-request/4075

Resolves:
https://pagure.io/SSSD/sssd/issue/4074

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/external/intgcheck.m4 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4
index 66b831a1fd..ef81ec7183 100644
--- a/src/external/intgcheck.m4
+++ b/src/external/intgcheck.m4
@@ -79,7 +79,12 @@ AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [
         SSS_INTGCHECK_REQ([HAVE_LDAPMODIFY], [ldapmodify])
         SSS_INTGCHECK_REQ([HAVE_FAKEROOT], [fakeroot])
 
-        SSS_CHECK_PYTHON_INTG_REQ([2])
+        SSS_CHECK_PYTHON_INTG_REQ([3], [just_warning])
+
+        AS_IF([test "x$HAVE_PYTHON_INTG_DEPS" = xyes], [],
+              dnl fallback to python2 checks due to missing
+              dnl python3 dependencies for intgcheck
+              [SSS_CHECK_PYTHON_INTG_REQ([2])])
     fi
 ])
 

From be8760050b9191e34ca987933fdbaad61eae353b Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 23:03:56 +0000
Subject: [PATCH 12/19] intg: Install python3 dependencies for intgcheck on new
 distros
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Samba 4.11.0 dropped support for python3 and thus it was also
dropped from samba related libraries (ldb ...)
which is required by integration tests

Merges: https://pagure.io/SSSD/sssd/pull-request/4075

Resolves:
https://pagure.io/SSSD/sssd/issue/4074

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 contrib/ci/deps.sh | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/contrib/ci/deps.sh b/contrib/ci/deps.sh
index 73471aeae4..d7cb33743b 100644
--- a/contrib/ci/deps.sh
+++ b/contrib/ci/deps.sh
@@ -40,26 +40,35 @@ if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
         nss_wrapper
         openldap-clients
         openldap-servers
-        pytest
-        python-ldap
-        python-psutil
-        pyldb
         rpm-build
         uid_wrapper
         python-requests
         curl-devel
         krb5-server
         krb5-workstation
-        dbus-python
     )
 
-    if [[ "$DISTRO_BRANCH" == -redhat-fedora-3[1-9]* ]]; then
+    if [[ "$DISTRO_BRANCH" == -redhat-fedora-3[1-9]* ||
+          "$DISTRO_BRANCH" == -redhat-redhatenterprise*-8.*- ||
+          "$DISTRO_BRANCH" == -redhat-centos-8.*- ]]; then
         DEPS_LIST+=(
+            python3-dbus
+            python3-ldap
+            python3-ldb
+            python3-psutil
             python3-pycodestyle
+            python3-pytest
+            python3-requests
         )
     else
         DEPS_LIST+=(
+            dbus-python
+            pyldb
+            pytest
+            python-ldap
             python-pep8
+            python-psutil
+            python-requests
         )
     fi
 

From 4569e704e635c76b8aa8713f5ec9ecb876f026ba Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:57:59 +0000
Subject: [PATCH 13/19] pyhbac: Fix warning Wdiscarded-qualifiers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The macro PyDoc_STRVAR changed in python 3.8
and it defined variable with const modifier

src/python/pyhbac.c: In function ‘PyInit_pyhbac’:
src/python/pyhbac.c:1948:25: warning: passing argument 2 of
   ‘sss_exception_with_doc’ discards ‘const’ qualifier from pointer
   target type [-Wdiscarded-qualifiers]
 1948 |                         HbacError__doc__,
      |                         ^~~~~~~~~~~~~~~~
In file included from src/python/pyhbac.c:27:
./src/util/sss_python.h:33:1: note: expected ‘char *’ but argument
    is of type ‘const char *’
 33 | sss_exception_with_doc(char *name, char *doc, PyObject *base, PyObject *dict);
    | ^~~~~~~~~~~~~~~~~~~~~~

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/python/pyhbac.c   |  3 +--
 src/util/sss_python.c | 10 +++++++---
 src/util/sss_python.h |  3 ++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/python/pyhbac.c b/src/python/pyhbac.c
index d78452cf0e..99d9bb0451 100644
--- a/src/python/pyhbac.c
+++ b/src/python/pyhbac.c
@@ -1944,8 +1944,7 @@ initpyhbac(void)
 
     /* The HBAC module exception */
     PyExc_HbacError = sss_exception_with_doc(
-                        discard_const_p(char, "hbac.HbacError"),
-                        HbacError__doc__,
+                        "hbac.HbacError", HbacError__doc__,
                         PyExc_EnvironmentError, NULL);
     Py_INCREF(PyExc_HbacError);
     ret = PyModule_AddObject(m, sss_py_const_p(char, "HbacError"), PyExc_HbacError);
diff --git a/src/util/sss_python.c b/src/util/sss_python.c
index 0e2f971670..2b01c6ef68 100644
--- a/src/util/sss_python.c
+++ b/src/util/sss_python.c
@@ -21,10 +21,14 @@
 #include "src/util/sss_python.h"
 
 PyObject *
-sss_exception_with_doc(char *name, char *doc, PyObject *base, PyObject *dict)
+sss_exception_with_doc(const char *name, const char *doc, PyObject *base,
+                       PyObject *dict)
 {
-#if PY_VERSION_HEX >= 0x02070000
+#if PY_VERSION_HEX >= 0x03080000
     return PyErr_NewExceptionWithDoc(name, doc, base, dict);
+#elif PY_VERSION_HEX >= 0x02070000
+    return PyErr_NewExceptionWithDoc(discard_const_p(char, name),
+                                     discard_const_p(char, doc), base, dict);
 #else
     int result;
     PyObject *ret = NULL;
@@ -48,7 +52,7 @@ sss_exception_with_doc(char *name, char *doc, PyObject *base, PyObject *dict)
             goto failure;
     }
 
-    ret = PyErr_NewException(name, base, dict);
+    ret = PyErr_NewException(discard_const_p(char, name), base, dict);
   failure:
     Py_XDECREF(mydict);
     return ret;
diff --git a/src/util/sss_python.h b/src/util/sss_python.h
index 26ecd71bd1..327a4c36a1 100644
--- a/src/util/sss_python.h
+++ b/src/util/sss_python.h
@@ -30,7 +30,8 @@
 
 /* Exceptions compatibility */
 PyObject *
-sss_exception_with_doc(char *name, char *doc, PyObject *base, PyObject *dict);
+sss_exception_with_doc(const char *name, const char *doc, PyObject *base,
+                       PyObject *dict);
 
 /* Convenience macros */
 #define TYPE_READY(module, type, name) do {         \

From 1cc8cfab69767c71ecc7d00b2dc937db23edfbc3 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:58:08 +0000
Subject: [PATCH 14/19] SSSDConfig: Add minimal test for parse method
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 Makefile.am                                 |  1 +
 src/config/SSSDConfigTest.py                | 27 +++++++++++++++++++++
 src/config/testconfigs/sssd-test-parse.conf | 12 +++++++++
 3 files changed, 40 insertions(+)
 create mode 100644 src/config/testconfigs/sssd-test-parse.conf

diff --git a/Makefile.am b/Makefile.am
index 0c24ae6649..c2ca2a436e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -475,6 +475,7 @@ dist_noinst_DATA = \
     src/config/testconfigs/sssd-invalid.conf \
     src/config/testconfigs/sssd-invalid-badbool.conf \
     src/config/testconfigs/sssd-nonexisting-services-domains.conf \
+    src/config/testconfigs/sssd-test-parse.conf \
     src/config/etc/sssd.api.d/crash_test_dummy \
     contrib/ci/README.md \
     contrib/ci/configure.sh \
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index 8262e822a2..8c6533358f 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -2087,6 +2087,33 @@ def testDeactivateDomain(self):
         self.assertRaises(SSSDConfig.NoDomainError,
                           sssdconfig.activate_domain, self)
 
+    def testParse(self):
+        sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
+                                           srcdir + "/etc/sssd.api.d")
+
+        with open(srcdir + "/testconfigs/sssd-test-parse.conf", "r") as f:
+            data = sssdconfig.parse(f)
+
+        self.assertEqual(len(data), 4)
+        self.assertEqual(data[-1], {'type': "section",
+                                    'name': "nss",
+                                    'value': [{'type': 'option',
+                                               'name': 'debug_level',
+                                               'value': '1'},
+                                              {'type': 'empty',
+                                               'name': 'empty'}]})
+
+        with open(srcdir + "/testconfigs/sssd-valid.conf", "r") as f:
+            data = sssdconfig.parse(f)
+
+        self.assertEqual(len(data), 10)
+        self.assertEqual(data[-1], {'name': "sudo",
+                                    'type': "section",
+                                    'value': [{'type': 'option',
+                                               'name': 'debug_level',
+                                               'value': '0xfC10'}]})
+
+
 if __name__ == "__main__":
     error = 0
 
diff --git a/src/config/testconfigs/sssd-test-parse.conf b/src/config/testconfigs/sssd-test-parse.conf
new file mode 100644
index 0000000000..b48221b86a
--- /dev/null
+++ b/src/config/testconfigs/sssd-test-parse.conf
@@ -0,0 +1,12 @@
+[domain/active]
+
+[domain/inactive]
+
+[sssd]
+domains = active
+services = nss
+
+[nss]
+debug_level = 1
+
+[pam]

From dd98f543e2eba3538c0c79c6609209273a9b23b9 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 22:58:21 +0000
Subject: [PATCH 15/19] SSSDConfig: Fix SyntaxWarning "is not" with a literal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There is a warning with python 3.8

/usr/lib/python3.8/site-packages/SSSDConfig/ipachangeconf.py:399:
 SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(sectopts) is not 0:

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/config/SSSDConfig/ipachangeconf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/config/SSSDConfig/ipachangeconf.py b/src/config/SSSDConfig/ipachangeconf.py
index eff12d4fc5..737ed7a4a8 100644
--- a/src/config/SSSDConfig/ipachangeconf.py
+++ b/src/config/SSSDConfig/ipachangeconf.py
@@ -396,7 +396,7 @@ def parse(self, f):
             curopts.append(self.parseLine(line))
 
         #Add last section if any
-        if len(sectopts) is not 0:
+        if sectopts:
             opts.append({'name':section, 'type':'section', 'value':sectopts})
 
         return opts

From 4e39e3205a41031fb62608a06c56fa7f93675f1e Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 23:15:24 +0000
Subject: [PATCH 16/19] TESTS: Add minimal test for pysss encrypt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 Makefile.am                 |  5 ++
 src/tests/pysss-test.py     | 99 +++++++++++++++++++++++++++++++++++++
 src/tests/pysss-test.py2.sh |  5 ++
 src/tests/pysss-test.py3.sh |  5 ++
 4 files changed, 114 insertions(+)
 create mode 100755 src/tests/pysss-test.py
 create mode 100755 src/tests/pysss-test.py2.sh
 create mode 100755 src/tests/pysss-test.py3.sh

diff --git a/Makefile.am b/Makefile.am
index c2ca2a436e..10398c212c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -348,12 +348,14 @@ PYTHON_TESTS =
 if BUILD_PYTHON2_BINDINGS
 PYTHON_TESTS += src/config/SSSDConfigTest.py2.sh \
                 src/tests/pyhbac-test.py2.sh \
+                src/tests/pysss-test.py2.sh \
                 src/tests/pysss_murmur-test.py2.sh \
                 $(NULL)
 endif
 if BUILD_PYTHON3_BINDINGS
 PYTHON_TESTS += src/config/SSSDConfigTest.py3.sh \
                 src/tests/pyhbac-test.py3.sh \
+                src/tests/pysss-test.py3.sh \
                 src/tests/pysss_murmur-test.py3.sh \
                 $(NULL)
 endif
@@ -458,6 +460,9 @@ dist_noinst_SCRIPTS = \
     src/tests/pyhbac-test.py \
     src/tests/pyhbac-test.py2.sh \
     src/tests/pyhbac-test.py3.sh \
+    src/tests/pysss-test.py \
+    src/tests/pysss-test.py2.sh \
+    src/tests/pysss-test.py3.sh \
     src/tests/pysss_murmur-test.py \
     src/tests/pysss_murmur-test.py2.sh \
     src/tests/pysss_murmur-test.py3.sh \
diff --git a/src/tests/pysss-test.py b/src/tests/pysss-test.py
new file mode 100755
index 0000000000..30bc074abd
--- /dev/null
+++ b/src/tests/pysss-test.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#  SSSD
+#
+#  SSSD python SSS API tests
+#
+#  Copyright (C) Red Hat
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import print_function
+
+import unittest
+import sys
+import os
+import tempfile
+
+BUILD_DIR = os.getenv('builddir') or "."
+TEST_DIR = os.getenv('SSS_TEST_DIR') or "."
+MODPATH = tempfile.mkdtemp(prefix="tp_pysss_", dir=TEST_DIR)
+
+
+class PysssImport(unittest.TestCase):
+    def setUp(self):
+        " Make sure we load the in-tree module "
+        self.system_path = sys.path[:]
+        sys.path = [MODPATH]
+
+    def tearDown(self):
+        " Restore the system path "
+        sys.path = self.system_path
+
+    def test_import(self):
+        " Import the module and assert it comes from tree "
+        try:
+            dest_module_path = MODPATH + "/pysss.so"
+
+            if sys.version_info[0] > 2:
+                src_module_path = BUILD_DIR + "/.libs/_py3sss.so"
+            else:
+                src_module_path = BUILD_DIR + "/.libs/_py2sss.so"
+
+            src_module_path = os.path.abspath(src_module_path)
+            os.symlink(src_module_path, dest_module_path)
+
+            import pysss
+        except ImportError as ex:
+            print("Could not load the pysss module. Please check if it is "
+                  "compiled", file=sys.stderr)
+            raise ex
+        self.assertEqual(pysss.__file__, MODPATH + "/pysss.so")
+
+
+class PysssEncryptTest(unittest.TestCase):
+    def test_encrypt(self):
+        obfuscator = pysss.password()
+
+        val1 = obfuscator.encrypt("123", obfuscator.AES_256)
+        self.assertEqual(len(val1), 96)
+
+        val2 = obfuscator.encrypt("123", obfuscator.AES_256)
+        self.assertEqual(len(val2), 96)
+
+        self.assertNotEqual(val1, val2)
+
+
+if __name__ == "__main__":
+    error = 0
+
+    suite = unittest.TestLoader().loadTestsFromTestCase(PysssImport)
+    res = unittest.TextTestRunner().run(suite)
+    if not res.wasSuccessful():
+        error |= 0x1
+        # need to bail out here because pysss could not be imported
+        sys.exit(error)
+
+    # import the pysss module into the global namespace, but make sure it's
+    # the one in tree
+    sys.path.insert(0, MODPATH)
+    import pysss
+
+    loadTestsFromTestCase = unittest.TestLoader().loadTestsFromTestCase
+
+    suite = loadTestsFromTestCase(PysssEncryptTest)
+    res = unittest.TextTestRunner().run(suite)
+    if not res.wasSuccessful():
+        error |= 0x2
+
+    sys.exit(error)
diff --git a/src/tests/pysss-test.py2.sh b/src/tests/pysss-test.py2.sh
new file mode 100755
index 0000000000..59073617a6
--- /dev/null
+++ b/src/tests/pysss-test.py2.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+SCRIPT=$(readlink -f "$0")
+SCRIPT_PATH=$(dirname "$SCRIPT")
+exec python2 $SCRIPT_PATH/pysss-test.py
diff --git a/src/tests/pysss-test.py3.sh b/src/tests/pysss-test.py3.sh
new file mode 100755
index 0000000000..db9160fb78
--- /dev/null
+++ b/src/tests/pysss-test.py3.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+SCRIPT=$(readlink -f "$0")
+SCRIPT_PATH=$(dirname "$SCRIPT")
+exec python3 $SCRIPT_PATH/pysss-test.py

From 69c23f2bcb67c83dc8054d9893eaa4971e0c1be2 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 23:15:24 +0000
Subject: [PATCH 17/19] pysss: Fix DeprecationWarning PY_SSIZE_T_CLEAN
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

src/tests/pysss-test.py:73: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  val1 = obfuscator.encrypt("123", obfuscator.AES_256)

These were introduced by https://bugs.python.org/issue36381 to warn about
an upcoming Python C API change. The meaning of PY_SSIZE_T_CLEAN is described
in https://python.readthedocs.io/en/stable/c-api/arg.html#strings-and-buffers.

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/python/pysss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/python/pysss.c b/src/python/pysss.c
index cdabe9c852..b339ac5df9 100644
--- a/src/python/pysss.c
+++ b/src/python/pysss.c
@@ -20,6 +20,7 @@
 
 #include "config.h"
 
+#define PY_SSIZE_T_CLEAN 1
 #include <Python.h>
 #include <structmember.h>
 #include <talloc.h>
@@ -966,7 +967,7 @@ static PyObject *py_sss_encrypt(PySssPasswordObject *self,
                                 PyObject *args)
 {
     char *password = NULL;
-    int plen; /* may contain NULL bytes */
+    Py_ssize_t plen; /* may contain NULL bytes */
     char *obfpwd = NULL;
     TALLOC_CTX *tctx = NULL;
     int ret;
@@ -985,7 +986,7 @@ static PyObject *py_sss_encrypt(PySssPasswordObject *self,
         return NULL;
     }
 
-    ret = sss_password_encrypt(tctx, password, plen+1,
+    ret = sss_password_encrypt(tctx, password, (int)(plen + 1),
                                mode, &obfpwd);
     if (ret != EOK) {
         PyErr_SetSssError(ret);

From 2b212f4237504d51d92bb12c5664b9e1d75317a5 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 2 Sep 2019 23:15:24 +0000
Subject: [PATCH 18/19] pysss_murmur: Fix DeprecationWarning PY_SSIZE_T_CLEAN
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

src/tests/pysss_murmur-test.py:93: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  hash_val = pysss_murmur.murmurhash3(sid_str, 0, seed)
src/tests/pysss_murmur-test.py:96: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  hash_val = pysss_murmur.murmurhash3(sid_str, len(sid_str), seed)

These were introduced by https://bugs.python.org/issue36381 to warn about
an upcoming Python C API change. The meaning of PY_SSIZE_T_CLEAN is described
in https://python.readthedocs.io/en/stable/c-api/arg.html#strings-and-buffers.

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/python/pysss_murmur.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/python/pysss_murmur.c b/src/python/pysss_murmur.c
index bcb2b81519..4db773c84a 100644
--- a/src/python/pysss_murmur.c
+++ b/src/python/pysss_murmur.c
@@ -20,6 +20,7 @@
 
 #include "config.h"
 
+#define PY_SSIZE_T_CLEAN 1
 #include <Python.h>
 
 #include "util/sss_python.h"
@@ -38,7 +39,7 @@ static PyObject * py_murmurhash3(PyObject *module, PyObject *args)
     long key_len;
     long long seed;
     uint32_t hash;
-    int input_len;
+    Py_ssize_t input_len;
 
     if (!PyArg_ParseTuple(args, sss_py_const_p(char, "z#lL"),
                           &key, &input_len, &key_len, &seed)) {

From f86c30f8d738d2652243d0b22f02ca53f0cfea19 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Tue, 3 Sep 2019 21:21:35 +0000
Subject: [PATCH 19/19] testlib: Fix SyntaxWarning "is" with a literal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Pavel Březina <pbrezina@redhat.com>\
---
 src/tests/python/sssd/testlib/common/libkrb5.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tests/python/sssd/testlib/common/libkrb5.py b/src/tests/python/sssd/testlib/common/libkrb5.py
index 8df4449773..d7aee2c113 100644
--- a/src/tests/python/sssd/testlib/common/libkrb5.py
+++ b/src/tests/python/sssd/testlib/common/libkrb5.py
@@ -165,13 +165,13 @@ def add_principal(self, principal=None,
         if service is None:
             service = 'host'
 
-        if p_type is 'user':
+        if p_type == 'user':
             add_principal = "add_principal -clearpolicy"\
                             " -pw %s %s@%s" % (password, principal,
                                                self.krb_realm)
             kadmin_local_cmd = ['kadmin.local', '-r',
                                 self.krb_realm, '-q', add_principal]
-        elif p_type is 'admin':
+        elif p_type == 'admin':
             add_principal = "add_principal -clearpolicy"\
                             " -pw %s %s/%s" % (password, service, 'admin')
             kadmin_local_cmd = ['kadmin.local', '-r', self.krb_realm,
