aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--unit_tests.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/unit_tests.py b/unit_tests.py
index beb819b..a3ad19b 100644
--- a/unit_tests.py
+++ b/unit_tests.py
@@ -23,13 +23,13 @@ def parse_arguments(argv = ()):
parser.add_argument("--quiet", action = "store_true", help = "suppress chatter")
parser.add_argument("--so-pin", default = "fnord", help = "security officer PIN")
parser.add_argument("--user-pin", default = "fnord", help = "user PIN")
- parser.add_argument("--wheel-pin", default = "fnord", help = "wheel PIN")
+ parser.add_argument("--wheel-pin", help = "wheel PIN")
parser.add_argument("--initial-pin", help = "initial PIN",
default = "YouReallyNeedToChangeThisPINRightNowWeAreNotKidding")
parser.add_argument("--slot", default = 0, type = int, help = "slot number")
parser.add_argument("--libpkcs11", default = "./libpkcs11.so", help = "PKCS #11 library")
parser.add_argument("--p11util", default = "./p11util", help = "p11util binary")
- parser.add_argument("--server", default = "../libhal/tests/test-rpc_server", help = "RPC server binary")
+ parser.add_argument("--server", help = "RPC server binary")
parser.add_argument("--all-tests", action = "store_true", help = "enable tests usually skipped")
parser.add_argument("--sql-file", default = "unit_tests.db", help = "SQLite3 database")
parser.add_argument("--ks-client", default = "unit_tests.ks-client", help = "client keystore (ks_mmap only)")
@@ -59,20 +59,27 @@ def setUpModule():
environ["CRYPTECH_KEYSTORE"] = new_file(args.ks_client)
server_keystore = new_file(args.ks_server)
- if isfile(args.server):
+ # The sudo and environment variable here are for the Novena, They
+ # don't make much sense for the Alpha. May want to factor them
+ # out and make them the caller's problem at some point.
+ if args.server and isfile(args.server):
cmd = [args.server]
if geteuid() != 0:
cmd.insert(0, "sudo")
if not args.quiet:
print "Starting RPC server:", " ".join(cmd)
- rpc = Popen(cmd,
- env = dict(environ,
- CRYPTECH_KEYSTORE = server_keystore))
+ rpc = Popen(cmd, env = dict(environ, CRYPTECH_KEYSTORE = server_keystore))
+ # Order of PINs here is significant, see p11util for details.
if not args.quiet:
print "Setting PINs"
- Popen((args.p11util, "-wsup"), stdin = PIPE).communicate("".join(pin + "\n" for pin in (
- args.initial_pin, args.wheel_pin, args.so_pin, args.user_pin)))
+ if args.wheel_pin is None:
+ flags = "-sup"
+ pins = (args.initial_pin, args.so_pin, args.user_pin)
+ else:
+ flags = "-wsup"
+ pins = (args.initial_pin, args.wheel_pin, args.so_pin, args.user_pin)
+ Popen((args.p11util, flags), stdin = PIPE).communicate("".join(pin + "\n" for pin in pins))
if not args.quiet:
print "Loading PKCS #11 library", args.libpkcs11