os.kill(basicconf["gpid"], signal.SIGHUP) time.sleep(1) #Let gssproxy reload everything r = run_basic_test(testdir, env, basicconf) rets.append(r) print("Testing SIGHUP with change of socket", file=sys.stderr) sys.stderr.write(" ") 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 r = run_basic_test(testdir, env, basicconf) rets.append(r) # 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 e = [r for r in rets if r != 0] if len(e) > 0: return e[0] return 0 if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_reloading.py"])
r1 = run_basic_test(testdir, env, conf) print("Testing multiple keys Keytab with second principal", file=sys.stderr) sys.stderr.write(" ") 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) gssproxy_reload(testdir, conf['gpid']) r2 = run_basic_test(testdir, env, conf) # Reset back gssproxy conf update_gssproxy_conf(testdir, conf["keysenv"], GSSPROXY_CONF_TEMPLATE) gssproxy_reload(testdir, conf['gpid']) if r1 != 0: return r1 elif r2 != 0: return r2 return 0 if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_multi_key.py"])
testenv = env.copy() testenv.update({'KRB5CCNAME': init_ccache}) usr_keytab = os.path.join(testdir, USR_KTNAME) ksetup = subprocess.Popen(["kinit", "-kt", usr_keytab, USR_NAME], stdout=logfile, stderr=logfile, env=testenv, preexec_fn=os.setsid) ksetup.wait() if ksetup.returncode != 0: raise ValueError("Kinit %s failed" % USR_NAME) cmd = " ".join(["./tests/t_setcredopt", USR_NAME, HOST_GSS, init_ccache]) testenv.update({ 'KRB5CCNAME': path_prefix + 'sco.ccache', 'KRB5_KTNAME': os.path.join(testdir, PROXY_KTNAME), 'KRB5_TRACE': path_prefix + 'sco.trace', 'GSS_USE_PROXY': 'yes', 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST' }) return run_testcase_cmd(testenv, conf, cmd, "Set cred options") if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_setcredopt.py"])
"./tests/t_impersonate", USR_NAME, HOST_GSS, PROXY_GSS, path_prefix + 'impersonate.cache', 's4u2proxy' ]) r = run_cmd(testdir, env, conf, msg, socket, cmd, PROXY_KTNAME, True) rets.append(r) #Test s4u2proxy half succeed msg = "s4u2proxy" socket = os.path.join(testdir, 'impersonate-proxyonly.socket') cmd = " ".join([ "./tests/t_impersonate", USR_NAME, HOST_GSS, PROXY_GSS, path_prefix + 'impersonate.cache', 's4u2proxy' ]) r = run_cmd(testdir, env, conf, msg, socket, cmd, PROXY_KTNAME, False) rets.append(r) # Reset back gssproxy conf update_gssproxy_conf(testdir, keysenv, GSSPROXY_CONF_TEMPLATE) os.kill(conf["gpid"], signal.SIGHUP) time.sleep(1) #Let gssproxy reload everything e = [r for r in rets if r != 0] if len(e) > 0: return e[0] return 0 if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_impersonate.py"])
def run(testdir, env, conf): print("Testing interposer...", file=sys.stderr) conf['prefix'] = str(cmd_index) logfile = os.path.join(conf['logpath'], "test_%d.log" % cmd_index) logfile = open(logfile, 'a') 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) cmd = " ".join(["./interposetest", "-t", "host@%s" % WRAP_HOSTNAME]) return run_testcase_cmd(ienv, conf, cmd, "Interpose") if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_interpose.py"])
p2.wait(testlib.testcase_wait) except subprocess.TimeoutExpired: # {p1,p2}.returncode are set to None here if not expected_failure: testlib.print_warning("warning", "timeout") init_logfile.close() accept_logfile.close() testlib.print_return(p1.returncode, testlib.cmd_index, "(%d) Init" % testlib.cmd_index, expected_failure) testlib.print_return(p2.returncode, testlib.cmd_index + 1, "(%d) Accept" % (testlib.cmd_index + 1), expected_failure) testlib.cmd_index += 2 try: os.killpg(p1.pid, signal.SIGTERM) os.killpg(p2.pid, signal.SIGTERM) except OSError: pass if p1.returncode != 0: return p1.returncode if not expected_failure else int( not p1.returncode) elif p2.returncode != 0: return p2.returncode if not expected_failure else int( not p2.returncode) return int(expected_failure) if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_basic.py"])
testenv = env.copy() testenv.update({'KRB5CCNAME': init_ccache}) usr_keytab = os.path.join(testdir, USR3_KTNAME) ksetup = subprocess.Popen(["kinit", "-kt", usr_keytab, USR3_NAME], stdout=logfile, stderr=logfile, env=testenv, preexec_fn=os.setsid) ksetup.wait() if ksetup.returncode != 0: raise ValueError("Kinit %s failed" % USR3_NAME) cmd = " ".join(["./tests/t_names", USR3_NAME, HOST_GSS, init_ccache]) testenv.update({ 'KRB5CCNAME': path_prefix + 'names.ccache', 'KRB5_KTNAME': os.path.join(testdir, SVC_KTNAME), 'KRB5_TRACE': path_prefix + 'names.trace', 'GSS_USE_PROXY': 'yes', 'GSSPROXY_BEHAVIOR': 'REMOTE_ONLY' }) return run_testcase_cmd(testenv, conf, cmd, "Check Names") if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_names.py"])
ccache = "FILE:" + os.path.join( testdir, "t" + conf["prefix"] + "_cred_store.ccache") testenv = {"KRB5CCNAME": ccache} testenv.update(env) usr_keytab = os.path.join(testdir, USR_KTNAME) ksetup = subprocess.Popen(["kinit", "-kt", usr_keytab, USR_NAME], stdout=logfile, stderr=logfile, env=testenv, preexec_fn=os.setsid) ksetup.wait() if ksetup.returncode != 0: raise ValueError("Kinit %s failed" % USR_NAME) testenv = { "KRB5_TRACE": os.path.join(testdir, "t" + conf["prefix"] + ".trace"), "GSS_USE_PROXY": "yes", "GSSPROXY_BEHAVIOR": "REMOTE_FIRST" } testenv.update(env) temp_ccache = "FILE:" + os.path.join(testdir, "t" + conf["prefix"] + "_temp.ccache") cmd = " ".join(["./tests/t_cred_store", ccache, temp_ccache]) return run_testcase_cmd(testenv, conf, cmd, "Cred store") if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_cred_store.py"])
def run(testdir, env, conf): conf['prefix'] = str(cmd_index) prefix = conf["prefix"] retval = 0 print("Testing positive program name matching...", file=sys.stderr) sys.stderr.write(" ") conf["prefix"] = prefix + "_1" update_gssproxy_conf(testdir, conf["keysenv"], GSSPROXY_PROGRAM) gssproxy_reload(testdir, conf['gpid']) retval |= run_acquire_test(testdir, env, conf) print("Testing negative program name matching...", file=sys.stderr) sys.stderr.write(" ") conf["prefix"] = prefix + "_2" bad_progdir = GSSPROXY_PROGRAM.replace("${PROGDIR}", "//bad/path") update_gssproxy_conf(testdir, conf["keysenv"], bad_progdir) gssproxy_reload(testdir, conf['gpid']) retval |= run_acquire_test(testdir, env, conf, expected_failure=True) # be a good citizen and clean up after ourselves update_gssproxy_conf(testdir, conf["keysenv"], GSSPROXY_CONF_TEMPLATE) gssproxy_reload(testdir, conf['gpid']) print_return(retval, -1, "Program", False) return retval if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_program.py"])
#!/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) conf['prefix'] = str(cmd_index) 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'] return run_testcase_cmd(testenv, conf, cmd, "Acquire", expected_failure) if __name__ == "__main__": from runtests import runtests_main runtests_main(["t_acquire.py"])