diff options
author | Nils Gillmann <ng0@n0.is> | 2018-05-23 07:29:10 +0000 |
---|---|---|
committer | Nils Gillmann <ng0@n0.is> | 2018-05-23 07:29:10 +0000 |
commit | e955fc4920bb3ab49307485e8bd5fe6c89438cc5 (patch) | |
tree | c0133bc12e6a9cb6d4d0820b387960a577540287 /src/revocation/test_local_revocation.py.in | |
parent | e4e8919f890be7ecd8b397de23b19ad82151f956 (diff) | |
download | gnunet-e955fc4920bb3ab49307485e8bd5fe6c89438cc5.tar.gz gnunet-e955fc4920bb3ab49307485e8bd5fe6c89438cc5.zip |
revocation: test_local_revocation: Adjust to flake8
Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'src/revocation/test_local_revocation.py.in')
-rw-r--r-- | src/revocation/test_local_revocation.py.in | 139 |
1 files changed, 69 insertions, 70 deletions
diff --git a/src/revocation/test_local_revocation.py.in b/src/revocation/test_local_revocation.py.in index 28257715f..067091b58 100644 --- a/src/revocation/test_local_revocation.py.in +++ b/src/revocation/test_local_revocation.py.in | |||
@@ -1,6 +1,6 @@ | |||
1 | #!@PYTHON@ | 1 | #!@PYTHON@ |
2 | # This file is part of GNUnet. | 2 | # This file is part of GNUnet. |
3 | # (C) 2010 Christian Grothoff (and other contributing authors) | 3 | # (C) 2010, 2018 Christian Grothoff (and other contributing authors) |
4 | # | 4 | # |
5 | # GNUnet is free software; you can redistribute it and/or modify | 5 | # GNUnet is free software; you can redistribute it and/or modify |
6 | # it under the terms of the GNU General Public License as published | 6 | # it under the terms of the GNU General Public License as published |
@@ -26,90 +26,89 @@ import re | |||
26 | import shutil | 26 | import shutil |
27 | 27 | ||
28 | if os.name == 'posix': | 28 | if os.name == 'posix': |
29 | config = 'gnunet-config' | 29 | config = 'gnunet-config' |
30 | gnunetarm = 'gnunet-arm' | 30 | gnunetarm = 'gnunet-arm' |
31 | ident = 'gnunet-identity' | 31 | ident = 'gnunet-identity' |
32 | revoc = './gnunet-revocation' | 32 | revoc = './gnunet-revocation' |
33 | elif os.name == 'nt': | 33 | elif os.name == 'nt': |
34 | config = 'gnunet-config.exe' | 34 | config = 'gnunet-config.exe' |
35 | gnunetarm = 'gnunet-arm.exe' | 35 | gnunetarm = 'gnunet-arm.exe' |
36 | ident = 'gnunet-identity.exe' | 36 | ident = 'gnunet-identity.exe' |
37 | revoc = './gnunet-revocation.exe' | 37 | revoc = './gnunet-revocation.exe' |
38 | 38 | ||
39 | TEST_CONFIGURATION = "test_revocation.conf" | 39 | TEST_CONFIGURATION = "test_revocation.conf" |
40 | TEST_REVOCATION_EGO = "revoc_test" | 40 | TEST_REVOCATION_EGO = "revoc_test" |
41 | 41 | ||
42 | 42 | get_clean = subprocess.Popen([config, '-c', TEST_CONFIGURATION, '-s', 'PATHS', '-o', 'GNUNET_HOME', '-f'], stdout=subprocess.PIPE) | |
43 | get_clean = subprocess.Popen ([config, '-c', TEST_CONFIGURATION, '-s', 'PATHS', '-o', 'GNUNET_HOME', '-f'], stdout=subprocess.PIPE) | 43 | cleandir, x = get_clean.communicate() |
44 | cleandir, x = get_clean.communicate () | ||
45 | cleandir = cleandir.decode("utf-8") | 44 | cleandir = cleandir.decode("utf-8") |
46 | cleandir = cleandir.rstrip ('\n').rstrip ('\r') | 45 | cleandir = cleandir.rstrip('\n').rstrip('\r') |
47 | 46 | ||
48 | if os.path.isdir (cleandir): | 47 | if os.path.isdir(cleandir): |
49 | shutil.rmtree (cleandir, True) | 48 | shutil.rmtree(cleandir, True) |
50 | 49 | ||
51 | res = 0 | 50 | res = 0 |
52 | arm = subprocess.Popen ([gnunetarm, '-s', '-c', TEST_CONFIGURATION]) | 51 | arm = subprocess.Popen([gnunetarm, '-s', '-c', TEST_CONFIGURATION]) |
53 | arm.communicate () | 52 | arm.communicate() |
54 | 53 | ||
55 | try: | 54 | try: |
56 | print ("Creating an ego " + TEST_REVOCATION_EGO) | 55 | print("Creating an ego " + TEST_REVOCATION_EGO) |
57 | sys.stdout.flush () | 56 | sys.stdout.flush() |
58 | sys.stderr.flush () | 57 | sys.stderr.flush() |
59 | idc = subprocess.Popen ([ident, '-C', TEST_REVOCATION_EGO, '-c', TEST_CONFIGURATION]) | 58 | idc = subprocess.Popen([ident, '-C', TEST_REVOCATION_EGO, '-c', TEST_CONFIGURATION]) |
60 | idc.communicate () | 59 | idc.communicate() |
61 | if idc.returncode != 0: | 60 | if idc.returncode != 0: |
62 | raise Exception ("gnunet-identity failed to create an ego `" + TEST_REVOCATION_EGO + "'") | 61 | raise Exception("gnunet-identity failed to create an ego `" + TEST_REVOCATION_EGO + "'") |
63 | 62 | ||
64 | sys.stdout.flush () | 63 | sys.stdout.flush() |
65 | sys.stderr.flush () | 64 | sys.stderr.flush() |
66 | idd = subprocess.Popen ([ident, '-d'], stdout=subprocess.PIPE) | 65 | idd = subprocess.Popen([ident, '-d'], stdout=subprocess.PIPE) |
67 | rev_key, x = idd.communicate () | 66 | rev_key, x = idd.communicate() |
68 | rev_key = rev_key.decode("utf-8") | 67 | rev_key = rev_key.decode("utf-8") |
69 | if len (rev_key.split ()) < 3: | 68 | if len(rev_key.split()) < 3: |
70 | raise Exception ("can't get revocation key out of `" + rev_key + "'") | 69 | raise Exception("can't get revocation key out of `" + rev_key + "'") |
71 | rev_key = rev_key.split ()[2] | 70 | rev_key = rev_key.split()[2] |
72 | 71 | ||
73 | print ("Testing key " + rev_key) | 72 | print("Testing key " + rev_key) |
74 | sys.stdout.flush () | 73 | sys.stdout.flush() |
75 | sys.stderr.flush () | 74 | sys.stderr.flush() |
76 | tst = subprocess.Popen ([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], stdout=subprocess.PIPE) | 75 | tst = subprocess.Popen([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], stdout=subprocess.PIPE) |
77 | output_not_revoked, x = tst.communicate () | 76 | output_not_revoked, x = tst.communicate() |
78 | output_not_revoked = output_not_revoked.decode("utf-8") | 77 | output_not_revoked = output_not_revoked.decode("utf-8") |
79 | if tst.returncode != 0: | 78 | if tst.returncode != 0: |
80 | raise Exception ("gnunet-revocation failed to test a key - " + str (tst.returncode) + ": " + output_not_revoked) | 79 | raise Exception("gnunet-revocation failed to test a key - " + str(tst.returncode) + ": " + output_not_revoked) |
81 | if 'valid' not in output_not_revoked: | 80 | if 'valid' not in output_not_revoked: |
82 | res = 1 | 81 | res = 1 |
83 | print ("Key was not valid") | 82 | print("Key was not valid") |
84 | else: | 83 | else: |
85 | print ("Key was valid") | 84 | print("Key was valid") |
86 | 85 | ||
87 | print ("Revoking key " + rev_key) | 86 | print("Revoking key " + rev_key) |
88 | sys.stdout.flush () | 87 | sys.stdout.flush() |
89 | sys.stderr.flush () | 88 | sys.stderr.flush() |
90 | rev = subprocess.Popen ([revoc, '-R', TEST_REVOCATION_EGO, '-p', '-c', TEST_CONFIGURATION]) | 89 | rev = subprocess.Popen([revoc, '-R', TEST_REVOCATION_EGO, '-p', '-c', TEST_CONFIGURATION]) |
91 | rev.communicate () | 90 | rev.communicate() |
92 | if rev.returncode != 0: | 91 | if rev.returncode != 0: |
93 | raise Exception ("gnunet-revocation failed to revoke a key") | 92 | raise Exception("gnunet-revocation failed to revoke a key") |
94 | 93 | ||
95 | print ("Testing revoked key " + rev_key) | 94 | print("Testing revoked key " + rev_key) |
96 | sys.stdout.flush () | 95 | sys.stdout.flush() |
97 | sys.stderr.flush () | 96 | sys.stderr.flush() |
98 | tst = subprocess.Popen ([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], stdout=subprocess.PIPE) | 97 | tst = subprocess.Popen([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], stdout=subprocess.PIPE) |
99 | output_revoked, x = tst.communicate () | 98 | output_revoked, x = tst.communicate() |
100 | output_revoked = output_revoked.decode("utf-8") | 99 | output_revoked = output_revoked.decode("utf-8") |
101 | if tst.returncode != 0: | 100 | if tst.returncode != 0: |
102 | raise Exception ("gnunet-revocation failed to test a revoked key") | 101 | raise Exception("gnunet-revocation failed to test a revoked key") |
103 | if 'revoked' not in output_revoked: | 102 | if 'revoked' not in output_revoked: |
104 | res = 1 | 103 | res = 1 |
105 | print ("Key was not revoked") | 104 | print("Key was not revoked") |
106 | else: | 105 | else: |
107 | print ("Key was revoked") | 106 | print("Key was revoked") |
108 | 107 | ||
109 | finally: | 108 | finally: |
110 | arm = subprocess.Popen ([gnunetarm, '-e', '-c', TEST_CONFIGURATION]) | 109 | arm = subprocess.Popen([gnunetarm, '-e', '-c', TEST_CONFIGURATION]) |
111 | arm.communicate () | 110 | arm.communicate() |
112 | if os.path.isdir (cleandir): | 111 | if os.path.isdir(cleandir): |
113 | shutil.rmtree (cleandir, True) | 112 | shutil.rmtree(cleandir, True) |
114 | 113 | ||
115 | sys.exit (res) | 114 | sys.exit(res) |