File: t_program.py

package info (click to toggle)
gssproxy 0.9.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,516 kB
  • sloc: ansic: 19,391; python: 1,196; xml: 611; makefile: 458; sh: 200
file content (55 lines) | stat: -rwxr-xr-x 1,679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python3
# Copyright (C) 2017 - GSS-Proxy contributors; see COPYING for the license.

from testlib import *

from t_acquire import run as run_acquire_test

import os
import testlib

GSSPROXY_PROGRAM = '''
[gssproxy]
  debug_level = 3

[service/t_acquire]
  mechs = krb5
  cred_store = keytab:${GSSPROXY_KEYTAB}
  cred_store = client_keytab:${GSSPROXY_CLIENT_KEYTAB}
  trusted = yes
  euid = ${UIDNUMBER}
  allow_client_ccache_sync = yes
  program = ${PROGDIR}/t_acquire
'''

def run(testdir, env, conf):
    conf['prefix'] = str(testlib.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, "(%d) Program" % testlib.cmd_index, False)
    testlib.cmd_index += 1
    return retval

if __name__ == "__main__":
    from runtests import runtests_main
    runtests_main(["t_program.py"])