From d559a64e1987bc0f45958aa3d155ec6e1612c26d Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Fri, 27 Apr 2018 16:49:50 +0200
Subject: [PATCH 1/2] authselect test: skip test if authselect is not available

Currently, the test is skipped if the platform is fedora-like. The
decision to skip should rather be based on authselect command
availability (i.e. when ipaplatform.paths.paths.AUTHSELECT is None).

Related to
https://pagure.io/freeipa/issue/7377
---
 ipatests/test_integration/test_authselect.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipatests/test_integration/test_authselect.py b/ipatests/test_integration/test_authselect.py
index e713f87282..7d096027d9 100644
--- a/ipatests/test_integration/test_authselect.py
+++ b/ipatests/test_integration/test_authselect.py
@@ -172,7 +172,7 @@ def uninstall(cls, mh):
 
 
 @pytest.mark.skipif(
-    ipaplatform.NAME not in ['fedora', 'rhel', 'centos'],
+    ipaplatform.paths.paths.AUTHSELECT is None,
     reason="Authselect is only available in fedora-like distributions")
 class TestServerInstallation(IntegrationTest):
     """

From c2dbf5dafc038354aacca536ddd10a0903eb20a5 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Wed, 2 May 2018 14:04:42 +0200
Subject: [PATCH 2/2] authselect migration: use stable interface to query
 current config

The code currently parses the output of "authselect current" in order
to extract the current profile and options. Example:
$ authselect current
Profile ID: sssd
Enabled features:
- with-mkhomedir

It is easier to use the output of "authselect current --raw". Example:
$ authselect current --raw
sssd with-mkhomedir

Related to
https://pagure.io/freeipa/issue/7377
---
 ipaplatform/redhat/authconfig.py | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py
index 2c7bd0a12b..e9e4a9acb7 100644
--- a/ipaplatform/redhat/authconfig.py
+++ b/ipaplatform/redhat/authconfig.py
@@ -22,7 +22,6 @@
 import logging
 import six
 import abc
-import re
 
 from ipaplatform.paths import paths
 from ipapython import ipautil
@@ -77,7 +76,7 @@ class RedHatAuthSelect(RedHatAuthToolBase):
     def _get_authselect_current_output(self):
         try:
             current = ipautil.run(
-                [paths.AUTHSELECT, "current"], env={"LC_ALL": "C.UTF8"})
+                [paths.AUTHSELECT, "current", "--raw"])
         except ipautil.CalledProcessError:
             logger.debug("Current configuration not managed by authselect")
             return None
@@ -95,18 +94,13 @@ def _parse_authselect_output(self, output_text=None):
             if output_text is None:
                 return None
 
-        cfg_params = re.findall(
-            r"\s*Profile ID:\s*(\S+)\s*\n\s*Enabled features:\s*(.*)",
-            output_text,
-            re.DOTALL
-        )
-
-        profile = cfg_params[0][0]
+        output_items = output_text.split(' ')
+        profile = output_items[0]
 
         if not profile:
             return None
 
-        features = re.findall(r"-\s*(\S+)", cfg_params[0][1], re.DOTALL)
+        features = output_items[1:]
 
         return profile, features
 
