Blame SOURCES/tests-Fixup-virtualenv-handling.patch

8f2224
From f106e3afa21cdbc098d3c82698585744e3325621 Mon Sep 17 00:00:00 2001
8f2224
From: Robbie Harwood <rharwood@redhat.com>
8f2224
Date: Fri, 15 May 2020 15:56:50 -0400
8f2224
Subject: [PATCH] [tests] Fixup virtualenv handling
8f2224
8f2224
Fixes an issue where virtualenv's PATH would get lost
8f2224
8f2224
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
8f2224
(cherry picked from commit e60384c0d4d4b4c213ec728ec3d444f998625941)
8f2224
---
8f2224
 tests/magtests.py | 21 ++++++++++-----------
8f2224
 1 file changed, 10 insertions(+), 11 deletions(-)
8f2224
8f2224
diff --git a/tests/magtests.py b/tests/magtests.py
8f2224
index 6c38a8f..1c0b26a 100755
8f2224
--- a/tests/magtests.py
8f2224
+++ b/tests/magtests.py
8f2224
@@ -67,6 +67,12 @@ def setup_wrappers(base):
8f2224
     return wenv
8f2224
 
8f2224
 
8f2224
+def apply_venv(env):
8f2224
+    env['PATH'] = os.environ.get('PATH', '')
8f2224
+    env['VIRTUAL_ENV'] = os.environ.get('VIRTUAL_ENV', '')
8f2224
+    return env
8f2224
+
8f2224
+
8f2224
 TESTREALM = "MAG.DEV"
8f2224
 KDC_DBNAME = 'db.file'
8f2224
 KDC_STASH = 'stash.file'
8f2224
@@ -304,7 +310,7 @@ def setup_kdc(testdir, wrapenv):
8f2224
     with open(kdcconf, 'w+') as f:
8f2224
         f.write(text)
8f2224
 
8f2224
-    kdcenv = {'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
8f2224
+    kdcenv = {'PATH': f'/sbin:/bin:/usr/sbin:/usr/bin:{wrapenv["PATH"]}',
8f2224
               'KRB5_CONFIG': krb5conf,
8f2224
               'KRB5_KDC_PROFILE': kdcconf,
8f2224
               'KRB5_TRACE': os.path.join(testdir, 'krbtrace.log')}
8f2224
@@ -415,7 +421,7 @@ def setup_http(testdir, so_dir, wrapenv):
8f2224
 
8f2224
     shutil.copy('tests/401.html', os.path.join(httpdir, 'html'))
8f2224
 
8f2224
-    httpenv = {'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
8f2224
+    httpenv = {'PATH': f'/sbin:/bin:/usr/sbin:/usr/bin:{wrapenv["PATH"]}',
8f2224
                'MALLOC_CHECK_': '3',
8f2224
                'MALLOC_PERTURB_': str(random.randint(0, 32767) % 255 + 1)}
8f2224
     httpenv.update(wrapenv)
8f2224
@@ -712,8 +718,7 @@ def faketime_setup(testenv):
8f2224
 
8f2224
 
8f2224
 def http_restart(testdir, so_dir, testenv):
8f2224
-
8f2224
-    httpenv = {'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
8f2224
+    httpenv = {'PATH': f'/sbin:/bin:/usr/sbin:/usr/bin:{testenv["PATH"]}',
8f2224
                'MALLOC_CHECK_': '3',
8f2224
                'MALLOC_PERTURB_': str(random.randint(0, 32767) % 255 + 1)}
8f2224
     httpenv.update(testenv)
8f2224
@@ -738,7 +743,7 @@ if __name__ == '__main__':
8f2224
     logfile = open(os.path.join(testdir, 'tests.log'), 'w')
8f2224
     errs = 0
8f2224
     try:
8f2224
-        wrapenv = setup_wrappers(testdir)
8f2224
+        wrapenv = apply_venv(setup_wrappers(testdir))
8f2224
 
8f2224
         kdcproc, kdcenv = setup_kdc(testdir, wrapenv)
8f2224
         processes['KDC(%d)' % kdcproc.pid] = kdcproc
8f2224
@@ -749,10 +754,6 @@ if __name__ == '__main__':
8f2224
         keysenv = setup_keys(testdir, kdcenv)
8f2224
         testenv = kinit_user(testdir, kdcenv)
8f2224
 
8f2224
-        # support virtualenv
8f2224
-        testenv['PATH'] = os.environ.get('PATH', '')
8f2224
-        testenv['VIRTUAL_ENV'] = os.environ.get('VIRTUAL_ENV', '')
8f2224
-
8f2224
         testenv['DELEGCCACHE'] = os.path.join(testdir, 'httpd',
8f2224
                                               USR_NAME + '@' + TESTREALM)
8f2224
         errs += test_spnego_auth(testdir, testenv, logfile)
8f2224
@@ -780,8 +781,6 @@ if __name__ == '__main__':
8f2224
                    'MAG_USER_NAME_2': USR_NAME_2,
8f2224
                    'MAG_USER_PASSWORD_2': USR_PWD_2}
8f2224
         testenv.update(kdcenv)
8f2224
-        testenv['PATH'] = os.environ.get('PATH', '')
8f2224
-        testenv['VIRTUAL_ENV'] = os.environ.get('VIRTUAL_ENV', '')
8f2224
 
8f2224
         errs += test_basic_auth_krb5(testdir, testenv, logfile)
8f2224