Skip to content

Commit e0192ef

Browse files
frozencemeterysimo5
authored andcommitted
Various Python whitespace cleanups
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
1 parent ca69110 commit e0192ef

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

contrib/sweeper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
print("Your GSSAPI does not provide cred store extension; exiting!")
2424
exit(1)
2525

26+
2627
# process file as a ccache and indicate whether it is expired
2728
def should_delete(fname, t):
2829
try:
@@ -45,6 +46,7 @@ def should_delete(fname, t):
4546

4647
return creds.lifetime == 0
4748

49+
4850
if __name__ == "__main__":
4951
dirs = sys.argv[1:]
5052
if len(dirs) < 1:

tests/magtests.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
del requests
1717
del requests_kerberos
1818

19+
1920
def parse_args():
2021
parser = argparse.ArgumentParser(
2122
description='Mod Auth GSSAPI Tests Environment')
2223
parser.add_argument('--path', default='%s/scratchdir' % os.getcwd(),
2324
help="Directory in which tests are run")
2425
parser.add_argument('--so-dir', default='%s/src/.libs' % os.getcwd(),
2526
help="mod_auth_gssapi shared object dirpath")
26-
2727
return vars(parser.parse_args())
2828

2929

@@ -34,8 +34,8 @@ def parse_args():
3434
WRAP_HTTP_PORT = '80'
3535
WRAP_PROXY_PORT = '8080'
3636

37-
def setup_wrappers(base):
3837

38+
def setup_wrappers(base):
3939
pkgcfg = subprocess.Popen(['pkg-config', '--exists', 'socket_wrapper'])
4040
pkgcfg.wait()
4141
if pkgcfg.returncode != 0:
@@ -62,7 +62,6 @@ def setup_wrappers(base):
6262
'WRAP_PROXY_PORT': WRAP_PROXY_PORT,
6363
'NSS_WRAPPER_HOSTNAME': WRAP_HOSTNAME,
6464
'NSS_WRAPPER_HOSTS': hosts_file}
65-
6665
return wenv
6766

6867

@@ -195,8 +194,8 @@ def setup_wrappers(base):
195194
extendedKeyUsage = 1.3.6.1.5.2.3.4
196195
''' # noqa
197196

198-
def setup_test_certs(testdir, testenv, logfile):
199197

198+
def setup_test_certs(testdir, testenv, logfile):
200199
opensslcnf = os.path.join(testdir, 'openssl.cnf')
201200
pkinit_key = os.path.join(testdir, PKINIT_KEY)
202201
pkinit_ca = os.path.join(testdir, PKINIT_CA)
@@ -349,14 +348,14 @@ def kadmin_local(cmd, env, logfile):
349348

350349

351350
def setup_keys(tesdir, env):
352-
353351
testlog = os.path.join(testdir, 'kerb.log')
354352
logfile = open(testlog, 'a')
355353

356354
svc_name = "HTTP/%s" % WRAP_HOSTNAME
357-
svc_keytab = os.path.join(testdir, SVC_KTNAME)
358355
cmd = "addprinc -randkey -e %s %s" % (KEY_TYPE, svc_name)
359356
kadmin_local(cmd, env, logfile)
357+
358+
svc_keytab = os.path.join(testdir, SVC_KTNAME)
360359
cmd = "ktadd -k %s -e %s %s" % (svc_keytab, KEY_TYPE, svc_name)
361360
kadmin_local(cmd, env, logfile)
362361

@@ -376,9 +375,8 @@ def setup_keys(tesdir, env):
376375
cmd = "addprinc -nokey -e %s %s" % (KEY_TYPE, USR_NAME_3)
377376
kadmin_local(cmd, env, logfile)
378377

379-
keys_env = { "KRB5_KTNAME": svc_keytab }
378+
keys_env = {"KRB5_KTNAME": svc_keytab, }
380379
keys_env.update(env)
381-
382380
return keys_env
383381

384382

@@ -423,7 +421,6 @@ def setup_http(testdir, so_dir, wrapenv):
423421
httpd = "httpd" if distro == "Fedora" else "apache2"
424422
httpproc = subprocess.Popen([httpd, '-DFOREGROUND', '-f', config],
425423
env=httpenv, preexec_fn=os.setsid)
426-
427424
return httpproc
428425

429426

@@ -467,7 +464,6 @@ def kinit_certuser(testdir, kdcenv):
467464

468465

469466
def test_spnego_auth(testdir, testenv, logfile):
470-
471467
spnegodir = os.path.join(testdir, 'httpd', 'html', 'spnego')
472468
os.mkdir(spnegodir)
473469
shutil.copy('tests/index.html', spnegodir)
@@ -505,6 +501,7 @@ def test_spnego_auth(testdir, testenv, logfile):
505501

506502
return error_count
507503

504+
508505
def test_required_name_attr(testdir, testenv, logfile):
509506
for i in range(1, 5):
510507
required_name_attr_dir = os.path.join(testdir, 'httpd', 'html',
@@ -522,6 +519,7 @@ def test_required_name_attr(testdir, testenv, logfile):
522519
sys.stderr.write('Required Name Attr: SUCCESS\n')
523520
return 0
524521

522+
525523
def test_spnego_rewrite(testdir, testenv, logfile):
526524
spnego_rewrite_dir = os.path.join(testdir, 'httpd', 'html',
527525
'spnego_rewrite')
@@ -538,6 +536,7 @@ def test_spnego_rewrite(testdir, testenv, logfile):
538536
sys.stderr.write('SPNEGO Rewrite: SUCCESS\n')
539537
return 0
540538

539+
541540
def test_spnego_negotiate_once(testdir, testenv, logfile):
542541
spnego_negotiate_once_dir = os.path.join(testdir, 'httpd', 'html',
543542
'spnego_negotiate_once')
@@ -554,6 +553,7 @@ def test_spnego_negotiate_once(testdir, testenv, logfile):
554553
sys.stderr.write('SPNEGO Negotiate Once: SUCCESS\n')
555554
return 0
556555

556+
557557
def test_basic_auth_krb5(testdir, testenv, logfile):
558558
basicdir = os.path.join(testdir, 'httpd', 'html', 'basic_auth_krb5')
559559
os.mkdir(basicdir)
@@ -602,6 +602,7 @@ def test_basic_auth_krb5(testdir, testenv, logfile):
602602

603603
return error_count
604604

605+
605606
def test_bad_acceptor_name(testdir, testenv, logfile):
606607
bandir = os.path.join(testdir, 'httpd', 'html', 'bad_acceptor_name')
607608
os.mkdir(bandir)
@@ -617,6 +618,7 @@ def test_bad_acceptor_name(testdir, testenv, logfile):
617618
sys.stderr.write('BAD ACCEPTOR: FAILED\n')
618619
return 1
619620

621+
620622
def test_no_negotiate(testdir, testenv, logfile):
621623
nonego_dir = os.path.join(testdir, 'httpd', 'html', 'nonego')
622624
os.mkdir(nonego_dir)
@@ -632,14 +634,15 @@ def test_no_negotiate(testdir, testenv, logfile):
632634
sys.stderr.write('NO Negotiate: SUCCESS\n')
633635
return 0
634636

637+
635638
def test_hostname_acceptor(testdir, testenv, logfile):
636639
hdir = os.path.join(testdir, 'httpd', 'html', 'hostname_acceptor')
637640
os.mkdir(hdir)
638641
shutil.copy('tests/index.html', hdir)
639642

640643
failed = False
641644
for (name, fail) in [(WRAP_HOSTNAME, False),
642-
(WRAP_ALIASNAME,False),
645+
(WRAP_ALIASNAME, False),
643646
(WRAP_FAILNAME, True)]:
644647
res = subprocess.Popen(["tests/t_hostname_acceptor.py", name],
645648
stdout=logfile, stderr=logfile,
@@ -660,8 +663,8 @@ def test_hostname_acceptor(testdir, testenv, logfile):
660663
sys.stderr.write('HOSTNAME ACCEPTOR: SUCCESS\n')
661664
return 0
662665

663-
if __name__ == '__main__':
664666

667+
if __name__ == '__main__':
665668
args = parse_args()
666669

667670
testdir = args['path']
@@ -671,7 +674,6 @@ def test_hostname_acceptor(testdir, testenv, logfile):
671674
os.makedirs(testdir)
672675

673676
processes = dict()
674-
675677
logfile = open(os.path.join(testdir, 'tests.log'), 'w')
676678
errs = 0
677679
try:
@@ -720,7 +722,6 @@ def test_hostname_acceptor(testdir, testenv, logfile):
720722
errs += test_basic_auth_krb5(testdir, testenv, logfile)
721723

722724
errs += test_no_negotiate(testdir, testenv, logfile)
723-
724725
finally:
725726
for name in processes:
726727
logfile.write("Killing %s\n" % name)

tests/t_basic_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
os.environ['MAG_USER_PASSWORD'],
1212
os.environ['NSS_WRAPPER_HOSTNAME'],
1313
os.environ['WRAP_PROXY_PORT'])
14-
proxies = { "http": proxy, }
14+
proxies = {"http": proxy, }
1515
url = 'http://%s/basic_auth_krb5/' % os.environ['NSS_WRAPPER_HOSTNAME']
1616
r = requests.get(url, proxies=proxies,
1717
auth=HTTPBasicAuth(os.environ['MAG_USER_NAME_2'],

tests/t_spnego_negotiate_once.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@
3434
r = sess.get(url, auth=HTTPKerberosAuth())
3535
if r.status_code != 200:
3636
raise ValueError('Spnego Negotiate Once failed')
37-

tests/t_spnego_no_auth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@
1818
r.headers.get("WWW-Authenticate").startswith("Negotiate")):
1919
raise ValueError('Spnego failed - WWW-Authenticate Negotiate header '
2020
'missing')
21-

tests/t_spnego_proxy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import gssapi
77
from base64 import b64encode
88

9+
10+
911
def getAuthToken(target):
1012
spnego_mech = gssapi.raw.OID.from_int_seq('1.3.6.1.5.5.2')
1113

@@ -25,7 +27,7 @@ def getAuthToken(target):
2527
url = 'http://%s/spnego/' % target
2628

2729
proxy = 'http://%s:%s' % (target, os.environ['WRAP_PROXY_PORT'])
28-
proxies = { "http" : proxy, }
30+
proxies = {"http": proxy, }
2931

3032
s.headers.update({'Proxy-Authorization': getAuthToken(target)})
3133
s.headers.update({'Authorization': getAuthToken(target)})

0 commit comments

Comments
 (0)