diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2014-05-17 10:18:17 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2014-05-17 10:18:17 +0100 |
commit | 5f1429e7747cb62ecdd30297d489fba52a1cdfa0 (patch) | |
tree | bdd6fe67270b75ff84b584af2f98d9769d6f9813 /testing/gitano-test-tool.in | |
parent | a5f2e7debbbf35ceeeca33bc35db0596c8ed814f (diff) | |
download | gitano-5f1429e7747cb62ecdd30297d489fba52a1cdfa0.tar.gz |
Add support for cached ssh keys for testing. Shaves 20% off test runtime
Diffstat (limited to 'testing/gitano-test-tool.in')
-rw-r--r-- | testing/gitano-test-tool.in | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/testing/gitano-test-tool.in b/testing/gitano-test-tool.in index 1a04b31..e892474 100644 --- a/testing/gitano-test-tool.in +++ b/testing/gitano-test-tool.in @@ -109,12 +109,28 @@ end function cmd_createsshkey(username, keyname, optionaltype) optionaltype = optionaltype or "rsa" - run_program { - "ssh-keygen", "-q", - "-t", optionaltype, - "-C", username .. "-" .. optionaltype .. "@" .. keyname, - "-f", ssh_key_file(username, keyname), - "-N", "" } + local targetkey = ssh_key_file(username, keyname) + local sourcekey = table.concat { + "testing/keys/", username, "@", keyname, "_", optionaltype } + local fh = io.open(sourcekey, "r") + if not fh then + run_program { + "ssh-keygen", "-q", + "-t", optionaltype, + "-C", username .. "-" .. optionaltype .. "@" .. keyname, + "-f", sourcekey, + "-N", "" } + fh = assert(io.open(sourcekey, "r")) + end + local ofh = assert(io.open(targetkey, "w")) + ofh:write(fh:read("*a")) + fh:close() + ofh:close() + fh = assert(io.open(sourcekey .. ".pub", "r")) + ofh = assert(io.open(targetkey .. ".pub", "w")) + ofh:write(fh:read("*a")) + fh:close() + ofh:close() end function cmd_setupstandard(owning_user, master_key) |