From 75cef8a29218ec6f55a979ce9e30535249d1dd3d Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Jan 12 2017 16:52:20 +0000 Subject: Split out each test into its own file Some naming and scoping issues are also fixed here in order for the result to run. Signed-off-by: Robbie Harwood Reviewed-by: Simo Sorce --- diff --git a/proxy/tests/runtests.py b/proxy/tests/runtests.py index 8eacde2..ac1ff2e 100755 --- a/proxy/tests/runtests.py +++ b/proxy/tests/runtests.py @@ -2,7 +2,9 @@ # Copyright (C) 2014,2015,2016 - GSS-Proxy contributors; see COPYING for the license. import argparse +import importlib import signal +import traceback from testlib import * @@ -13,165 +15,6 @@ def parse_args(): return vars(parser.parse_args()) -def run_interposetest(testdir, env): - testlog = os.path.join(testdir, 'interposetest.log') - - ienv = {"KRB5CCNAME": os.path.join(testdir, 'interpose_ccache'), - "KRB5_KTNAME": os.path.join(testdir, SVC_KTNAME)} - ienv.update(env) - usr_keytab = os.path.join(testdir, USR_KTNAME) - with (open(testlog, 'a')) as logfile: - ksetup = subprocess.Popen(["kinit", "-kt", usr_keytab, USR_NAME], - stdout=logfile, stderr=logfile, - env=ienv, preexec_fn=os.setsid) - ksetup.wait() - if ksetup.returncode != 0: - raise ValueError('Kinit %s failed' % USR_NAME) - - with (open(testlog, 'a')) as logfile: - itest = subprocess.Popen(["./interposetest", "-t", - "host@%s" % WRAP_HOSTNAME], - stdout=logfile, stderr=logfile, - env=ienv) - itest.wait() - if itest.returncode != 0: - raise ValueError('Interposetest failed') - -def run_basic_test(testdir, env, conf, expected_failure=False): - - logfile = conf['logfile'] - - svcenv = {'KRB5_KTNAME': conf['keytab'], - 'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + - '_accept.ccache'), - 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + - '_accept.trace')} - svcenv.update(env) - - client_name = conf.get('client_name', None) - if client_name is not None: - init_cmd = ["./tests/t_init", conf['svc_name'], client_name] - else: - init_cmd = ["./tests/t_init", conf['svc_name']] - - clienv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + - '_init.ccache'), - 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + - '_init.trace'), - 'GSS_USE_PROXY': 'yes', - 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} - clienv.update(env) - - print("[SVCENV]\n%s\n[CLIENV]\n%s\nCLI NAME: %s\n" % ( - svcenv, clienv, client_name), file=logfile) - - pipe0 = os.pipe() - pipe1 = os.pipe() - - p1 = subprocess.Popen(init_cmd, - stdin=pipe0[0], stdout=pipe1[1], - stderr=logfile, env=clienv, preexec_fn=os.setsid) - p2 = subprocess.Popen(["./tests/t_accept"], - stdin=pipe1[0], stdout=pipe0[1], - stderr=logfile, env=svcenv, preexec_fn=os.setsid) - - try: - p1.wait(30) - except subprocess.TimeoutExpired: - # p1.returncode is set to None here - pass - if p1.returncode != 0 and not expected_failure: - print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", - "Init test returned %s" % str(p1.returncode)) - try: - os.killpg(p2.pid, signal.SIGTERM) - except OSError: - pass - else: - print_success("SUCCESS" if p1.returncode == 0 else "FAILED", - "Init test returned %s" % str(p1.returncode)) - try: - p2.wait(30) - except subprocess.TimeoutExpired: - # p2.returncode is set to None here - pass - if p2.returncode != 0 and not expected_failure: - print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", - "Accept test returned %s" % str(p2.returncode)) - try: - os.killpg(p1.pid, signal.SIGTERM) - except OSError: - pass - else: - print_success("SUCCESS" if p1.returncode == 0 else "FAILED", - "Accept test returned %s" % str(p2.returncode)) - - -def run_acquire_test(testdir, env, conf, expected_failure=False): - - logfile = conf['logfile'] - - svc_keytab = os.path.join(testdir, SVC_KTNAME) - testenv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + - '_acquire.ccache'), - 'KRB5_KTNAME': conf['keytab'], - 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + - '_acquire.trace'), - 'GSS_USE_PROXY': 'yes', - 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} - testenv.update(env) - - cmd = ["./tests/t_acquire", conf['svc_name']] - print("[COMMAND]\n%s\n[ENVIRONMENT]\n%s\n" % (cmd, env), file=logfile) - logfile.flush() - - p1 = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=logfile, - env=testenv, preexec_fn=os.setsid) - try: - p1.wait(30) - except subprocess.TimeoutExpired: - # p1.returncode is set to None here - pass - if p1.returncode != 0 and not expected_failure: - print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", - "Acquire test returned %s" % str(p1.returncode)) - else: - print_success("SUCCESS" if p1.returncode == 0 else "FAILED", - "Acquire test returned %s" % str(p1.returncode)) - - -def run_impersonate_test(testdir, env, conf, expected_failure=False): - - logfile = conf['logfile'] - - testenv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + - '_impersonate.ccache'), - 'KRB5_KTNAME': conf['keytab'], - 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + - '_impersonate.trace'), - 'GSS_USE_PROXY': 'yes', - 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} - testenv.update(env) - - cmd = ["./tests/t_impersonate", USR_NAME, conf['svc_name']] - print("[COMMAND]\n%s\n[ENVIRONMENT]\n%s\n" % (cmd, env), file=logfile) - logfile.flush() - - p1 = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=logfile, - env=testenv, preexec_fn=os.setsid) - try: - p1.wait(30) - except subprocess.TimeoutExpired: - # p1.returncode is set to None here - pass - if p1.returncode != 0 and not expected_failure: - print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", - "Impersonate test returned %s" % str(p1.returncode)) - else: - print_success("SUCCESS" if p1.returncode == 0 else "FAILED", - "Impersonate test returned %s" % str(p1.returncode)) - - if __name__ == '__main__': args = parse_args() @@ -196,126 +39,37 @@ if __name__ == '__main__': gssapienv = setup_gssapi_env(testdir, kdcenv) - run_interposetest(testdir, gssapienv) - gssproxylog = os.path.join(testdir, 'gssproxy.log') - with (open(gssproxylog, 'a')) as logfile: - gproc, gpsocket = setup_gssproxy(testdir, logfile, keysenv) - time.sleep(5) #Give time to gssproxy to fully start up - processes['GSS-Proxy(%d)' % gproc.pid] = gproc - gssapienv['GSSPROXY_SOCKET'] = gpsocket - - basicconf = {'svc_name': "host@%s" % WRAP_HOSTNAME, - 'keytab': os.path.join(testdir, SVC_KTNAME)} - - # Test 01 - testnum = 1 - print("Testing basic acquire creds", file=sys.stderr) - basicconf['logfile'] = \ - open(os.path.join(testdir, - '%02d_basic_acquire.log' % testnum), 'a') - basicconf['prefix'] = '%02d' % testnum - run_acquire_test(testdir, gssapienv, basicconf) - # Test 02 - testnum += 1 - print("Testing impersonate creds", file=sys.stderr) - basicconf['logfile'] = \ - open(os.path.join(testdir, '02_impersonate.log'), 'a') - basicconf['prefix'] = '%02d' % testnum - run_impersonate_test(testdir, gssapienv, basicconf) - - # Test 03 - testnum += 1 - print("Testing basic init/accept context", file=sys.stderr) - basicconf['logfile'] = \ - open(os.path.join(testdir, '03_basic_exchange.log'), 'a') - basicconf['prefix'] = '%02d' % testnum - run_basic_test(testdir, gssapienv, basicconf) + logfile = open(gssproxylog, "a") - # Test 04 (part 1) - testnum += 1 - basicconf['logfile'] = \ - open(os.path.join(testdir, '04_sighups.log'), 'a') + gproc, gpsocket = setup_gssproxy(testdir, logfile, keysenv) + time.sleep(5) #Give time to gssproxy to fully start up + processes['GSS-Proxy(%d)' % gproc.pid] = gproc + gssapienv['GSSPROXY_SOCKET'] = gpsocket - print("Testing basic SIGHUP with no change", file=sys.stderr) - basicconf['prefix'] = '%02d_1' % testnum - os.kill(gproc.pid, signal.SIGHUP) - time.sleep(1) #Let gssproxy reload everything - run_basic_test(testdir, gssapienv, basicconf) + basicconf = {'svc_name': "host@%s" % WRAP_HOSTNAME, + 'keytab': os.path.join(testdir, SVC_KTNAME)} + basicconf["gpid"] = gproc.pid + basicconf["keysenv"] = keysenv - # Test 04 (part 2) - print("Testing SIGHUP with dropped service", file=sys.stderr) - basicconf['prefix'] = '%02d_2' % testnum - update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_MINIMAL_TEMPLATE) - os.kill(gproc.pid, signal.SIGHUP) - time.sleep(1) #Let gssproxy reload everything - run_basic_test(testdir, gssapienv, basicconf, True) + testnum = 0 + testfiles = [f for f in os.listdir("tests") \ + if f.endswith(".py") and f.startswith("t_")] + testfiles.sort() + print("Tests to be run: " + ", ".join(testfiles)) + for f in testfiles: + fmod = f[:-len(".py")] + t = importlib.__import__(fmod) - # Test 04 (part 3) - print("Testing SIGHUP with new service", file=sys.stderr) - basicconf['prefix'] = '%02d_3' % testnum - update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_TEMPLATE) - os.kill(gproc.pid, signal.SIGHUP) - time.sleep(1) #Let gssproxy reload everything - run_basic_test(testdir, gssapienv, basicconf) - - # Test 04 (part 4) - print("Testing SIGHUP with change of socket", file=sys.stderr) - basicconf['prefix'] = '%02d_4' % testnum - update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_SOCKET_TEMPLATE) - gssapienv['GSSPROXY_SOCKET'] += "2" - os.kill(gproc.pid, signal.SIGHUP) - time.sleep(1) #Let gssproxy reload everything - run_basic_test(testdir, gssapienv, basicconf) - - # Test 05 (part 1) + basicconf['prefix'] = '%02d' % testnum + logfile = os.path.join(testdir, "%02d_%s.log" % (testnum, fmod)) + basicconf['logfile'] = open(logfile, 'a') + t.run(testdir, gssapienv, basicconf) testnum += 1 - basicconf['logfile'] = \ - open(os.path.join(testdir, '05_multiple-keys.log'), 'a') - setup_multi_keys(testdir, gssapienv) - gssapienv['GSSPROXY_SOCKET'] = gpsocket - - # Q: What are we testing here ? - # A: A client calling gss_init_sec_context() w/o explicitly - # acquiring credentials before hand. [Note: in this case - # gssproxy uses the 'keytab' specified in the store and ignores - # the 'client_keytab' one]. - # A gssproxy configruation where the keytab containes multiple - # keys, and a krb5_principal option that sepcify what name we - # want to use. - # We try both names to make sure we target a specific key and not - # just pick up the first in the keytab (which is the normal - # behavior). - - print("Testing multiple keys Keytab with first principal", - file=sys.stderr) - if os.path.exists(os.path.join(testdir, 'gssproxy', 'gpccache')): - os.unlink(os.path.join(testdir, 'gssproxy', 'gpccache')) - basicconf['prefix'] = '%02d_1' % testnum - p1env = {} - p1env.update(keysenv) - p1env['client_name'] = MULTI_UPN - p1env['KRB5_KTNAME'] = os.path.join(testdir, MULTI_KTNAME) - update_gssproxy_conf(testdir, p1env, GSSPROXY_MULTI_TEMPLATE) - os.kill(gproc.pid, signal.SIGHUP) - time.sleep(1) #Let gssproxy reload everything - run_basic_test(testdir, gssapienv, basicconf) - # Test 04 (part 2) - print("Testing multiple keys Keytab with second principal", - file=sys.stderr) - if os.path.exists(os.path.join(testdir, 'gssproxy', 'gpccache')): - os.unlink(os.path.join(testdir, 'gssproxy', 'gpccache')) - basicconf['prefix'] = '%02d_2' % testnum - p2env = {} - p2env.update(keysenv) - p2env['client_name'] = MULTI_SVC - p2env['KRB5_KTNAME'] = os.path.join(testdir, MULTI_KTNAME) - update_gssproxy_conf(testdir, p2env, GSSPROXY_MULTI_TEMPLATE) - os.kill(gproc.pid, signal.SIGHUP) - time.sleep(1) #Let gssproxy reload everything - run_basic_test(testdir, gssapienv, basicconf) + except Exception: + traceback.print_exc() finally: for name in processes: print("Killing %s" % name) diff --git a/proxy/tests/t_acquire.py b/proxy/tests/t_acquire.py new file mode 100644 index 0000000..a4c7498 --- /dev/null +++ b/proxy/tests/t_acquire.py @@ -0,0 +1,36 @@ +#!/usr/bin/python3 +# Copyright (C) 2015,2016 - GSS-Proxy contributors; see COPYING for the license. + +from testlib import * + +def run(testdir, env, conf, expected_failure=False): + print("Testing basic acquire creds...", file=sys.stderr) + logfile = conf['logfile'] + + svc_keytab = os.path.join(testdir, SVC_KTNAME) + testenv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + + '_acquire.ccache'), + 'KRB5_KTNAME': conf['keytab'], + 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + + '_acquire.trace'), + 'GSS_USE_PROXY': 'yes', + 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} + testenv.update(env) + + cmd = ["./tests/t_acquire", conf['svc_name']] + print("[COMMAND]\n%s\n[ENVIRONMENT]\n%s\n" % (cmd, env), file=logfile) + logfile.flush() + + p1 = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=logfile, + env=testenv, preexec_fn=os.setsid) + try: + p1.wait(30) + except subprocess.TimeoutExpired: + # p1.returncode is set to None here + pass + if p1.returncode != 0 and not expected_failure: + print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", + "Acquire test returned %s" % str(p1.returncode)) + else: + print_success("SUCCESS" if p1.returncode == 0 else "FAILED", + "Acquire test returned %s" % str(p1.returncode)) diff --git a/proxy/tests/t_basic.py b/proxy/tests/t_basic.py new file mode 100755 index 0000000..5ab2477 --- /dev/null +++ b/proxy/tests/t_basic.py @@ -0,0 +1,73 @@ +#!/usr/bin/python3 +# Copyright (C) 2014,2015,2016 - GSS-Proxy contributors; see COPYING for the license + +from testlib import * + +def run(testdir, env, conf, expected_failure=False): + print("Testing basic init/accept context", file=sys.stderr) + logfile = conf['logfile'] + + svcenv = {'KRB5_KTNAME': conf['keytab'], + 'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + + '_accept.ccache'), + 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + + '_accept.trace')} + svcenv.update(env) + + client_name = conf.get('client_name', None) + if client_name is not None: + init_cmd = ["./tests/t_init", conf['svc_name'], client_name] + else: + init_cmd = ["./tests/t_init", conf['svc_name']] + + clienv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + + '_init.ccache'), + 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + + '_init.trace'), + 'GSS_USE_PROXY': 'yes', + 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} + clienv.update(env) + + print("[SVCENV]\n%s\n[CLIENV]\n%s\nCLI NAME: %s\n" % ( + svcenv, clienv, client_name), file=logfile) + + pipe0 = os.pipe() + pipe1 = os.pipe() + + p1 = subprocess.Popen(init_cmd, + stdin=pipe0[0], stdout=pipe1[1], + stderr=logfile, env=clienv, preexec_fn=os.setsid) + p2 = subprocess.Popen(["./tests/t_accept"], + stdin=pipe1[0], stdout=pipe0[1], + stderr=logfile, env=svcenv, preexec_fn=os.setsid) + + try: + p1.wait(30) + except subprocess.TimeoutExpired: + # p1.returncode is set to None here + pass + if p1.returncode != 0 and not expected_failure: + print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", + "Init test returned %s" % str(p1.returncode)) + try: + os.killpg(p2.pid, signal.SIGTERM) + except OSError: + pass + else: + print_success("SUCCESS" if p1.returncode == 0 else "FAILED", + "Init test returned %s" % str(p1.returncode)) + try: + p2.wait(30) + except subprocess.TimeoutExpired: + # p2.returncode is set to None here + pass + if p2.returncode != 0 and not expected_failure: + print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", + "Accept test returned %s" % str(p2.returncode)) + try: + os.killpg(p1.pid, signal.SIGTERM) + except OSError: + pass + else: + print_success("SUCCESS" if p1.returncode == 0 else "FAILED", + "Accept test returned %s" % str(p2.returncode)) diff --git a/proxy/tests/t_impersonate.py b/proxy/tests/t_impersonate.py new file mode 100644 index 0000000..ea7c462 --- /dev/null +++ b/proxy/tests/t_impersonate.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 +# Copyright (C) 2015,2016 - GSS-Proxy contributors; see COPYING for the license + +from testlib import * + +def run(testdir, env, conf, expected_failure=False): + print("Testing impersonate creds...", file=sys.stderr) + logfile = conf['logfile'] + + testenv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + + '_impersonate.ccache'), + 'KRB5_KTNAME': conf['keytab'], + 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + + '_impersonate.trace'), + 'GSS_USE_PROXY': 'yes', + 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} + testenv.update(env) + + cmd = ["./tests/t_impersonate", USR_NAME, conf['svc_name']] + print("[COMMAND]\n%s\n[ENVIRONMENT]\n%s\n" % (cmd, env), file=logfile) + logfile.flush() + + p1 = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=logfile, + env=testenv, preexec_fn=os.setsid) + try: + p1.wait(30) + except subprocess.TimeoutExpired: + # p1.returncode is set to None here + pass + if p1.returncode != 0 and not expected_failure: + print_failure("SUCCESS" if p1.returncode == 0 else "FAILED", + "Impersonate test returned %s" % str(p1.returncode)) + else: + print_success("SUCCESS" if p1.returncode == 0 else "FAILED", + "Impersonate test returned %s" % str(p1.returncode)) diff --git a/proxy/tests/t_interpose.py b/proxy/tests/t_interpose.py new file mode 100644 index 0000000..82557c0 --- /dev/null +++ b/proxy/tests/t_interpose.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +# Copyright (C) 2014,2015,2016 - GSS-Proxy contributors; see COPYING for the license + +from testlib import * + +def run(testdir, env, conf): + print("Testing interposer...", file=sys.stderr) + logfile = conf['logfile'] + + ienv = {"KRB5CCNAME": os.path.join(testdir, 'interpose_ccache'), + "KRB5_KTNAME": os.path.join(testdir, SVC_KTNAME)} + ienv.update(env) + usr_keytab = os.path.join(testdir, USR_KTNAME) + + ksetup = subprocess.Popen(["kinit", "-kt", usr_keytab, USR_NAME], + stdout=logfile, stderr=logfile, + env=ienv, preexec_fn=os.setsid) + ksetup.wait() + if ksetup.returncode != 0: + raise ValueError('Kinit %s failed' % USR_NAME) + + itest = subprocess.Popen(["./interposetest", "-t", + "host@%s" % WRAP_HOSTNAME], + stdout=logfile, stderr=logfile, + env=ienv) + itest.wait() + print_success("SUCCESS" if itest.returncode == 0 else "FAILED", + "Interpose test returned %s" % str(itest.returncode)) diff --git a/proxy/tests/t_multi_key.py b/proxy/tests/t_multi_key.py new file mode 100644 index 0000000..3211c9a --- /dev/null +++ b/proxy/tests/t_multi_key.py @@ -0,0 +1,50 @@ +#!/usr/bin/python3 +# Copyright (C) 2014,2015,2016 - GSS-Proxy contributors; see COPYING for the license + +from t_basic import run as run_basic_test + +from testlib import * + +# Q: What are we testing here ? +# +# A: A client calling gss_init_sec_context() w/o explicitly acquiring +# credentials before hand. [Note: in this case gssproxy uses the 'keytab' +# specified in the store and ignores the 'client_keytab' one]. +# +# A gssproxy configruation where the keytab containes multiple keys, and a +# krb5_principal option that sepcify what name we want to use. +# +# We try both names to make sure we target a specific key and not just pick up +# the first in the keytab (which is the normal behavior). + +def run(testdir, env, conf): + setup_multi_keys(testdir, env) + prefix = conf["prefix"] + + print("Testing multiple keys Keytab with first principal", + file=sys.stderr) + conf["prefix"] = prefix + "_1" + if os.path.exists(os.path.join(testdir, 'gssproxy', 'gpccache')): + os.unlink(os.path.join(testdir, 'gssproxy', 'gpccache')) + p1env = {} + p1env.update(conf["keysenv"]) + p1env['client_name'] = MULTI_UPN + p1env['KRB5_KTNAME'] = os.path.join(testdir, MULTI_KTNAME) + update_gssproxy_conf(testdir, p1env, GSSPROXY_MULTI_TEMPLATE) + os.kill(conf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything + run_basic_test(testdir, env, conf) + + print("Testing multiple keys Keytab with second principal", + file=sys.stderr) + if os.path.exists(os.path.join(testdir, 'gssproxy', 'gpccache')): + os.unlink(os.path.join(testdir, 'gssproxy', 'gpccache')) + conf['prefix'] = prefix + "_2" + p2env = {} + p2env.update(conf["keysenv"]) + p2env['client_name'] = MULTI_SVC + p2env['KRB5_KTNAME'] = os.path.join(testdir, MULTI_KTNAME) + update_gssproxy_conf(testdir, p2env, GSSPROXY_MULTI_TEMPLATE) + os.kill(conf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything + run_basic_test(testdir, env, conf) diff --git a/proxy/tests/t_reloading.py b/proxy/tests/t_reloading.py new file mode 100755 index 0000000..46a262e --- /dev/null +++ b/proxy/tests/t_reloading.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +# Copyright (C) 2014,2015,2016 - GSS-Proxy contributors; see COPYING for the license + +from testlib import * +from t_basic import run as run_basic_test + +def run(testdir, env, basicconf): + prefix = basicconf['prefix'] + keysenv = basicconf["keysenv"] + + print("Testing basic SIGHUP with no change", file=sys.stderr) + basicconf['prefix'] += prefix + "_1" + os.kill(basicconf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything + run_basic_test(testdir, env, basicconf) + + print("Testing SIGHUP with dropped service", file=sys.stderr) + basicconf['prefix'] = prefix + "_2" + update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_MINIMAL_TEMPLATE) + os.kill(basicconf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything + run_basic_test(testdir, env, basicconf, True) + + print("Testing SIGHUP with new service", file=sys.stderr) + basicconf['prefix'] = prefix + "_3" + update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_TEMPLATE) + os.kill(basicconf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything + run_basic_test(testdir, env, basicconf) + + print("Testing SIGHUP with change of socket", file=sys.stderr) + basicconf['prefix'] = prefix + "_4" + update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_SOCKET_TEMPLATE) + env['GSSPROXY_SOCKET'] += "2" + os.kill(basicconf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything + run_basic_test(testdir, env, basicconf) + + # restore old configuration + env['GSSPROXY_SOCKET'] = env['GSSPROXY_SOCKET'][:-1] + update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_TEMPLATE) + os.kill(basicconf["gpid"], signal.SIGHUP) + time.sleep(1) #Let gssproxy reload everything