Merge lp:~gz/juju-core/generatekey_testoverride_1312850 into lp:~go-bot/juju-core/trunk
Proposed by
Martin Packman
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Martin Packman | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2685 | ||||
Proposed branch: | lp:~gz/juju-core/generatekey_testoverride_1312850 | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
115 lines (+36/-1) 6 files modified
utils/ssh/clientkeys_test.go (+2/-0) utils/ssh/export_test.go (+1/-0) utils/ssh/generate.go (+4/-1) utils/ssh/generate_test.go (+26/-0) utils/ssh/ssh_gocrypto_test.go (+2/-0) utils/ssh/ssh_test.go (+1/-0) |
||||
To merge this branch: | bzr merge lp:~gz/juju-core/generatekey_testoverride_1312850 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+217314@code.launchpad.net |
Commit message
utils/ssh: Override rsa.GenerateKey in tests
Make ssh tests faster by generating one, smaller,
RSA key and reusing it for all tests. This is
particularly helpful on arm where the math prime
functions are very slow.
https:/
R=jameinel
Description of the change
utils/ssh: Override rsa.GenerateKey in tests
Make ssh tests faster by generating one, smaller,
RSA key and reusing it for all tests. This is
particularly helpful on arm where the math prime
functions are very slow.
To post a comment you must log in.
Reviewers: mp+217314_ code.launchpad. net,
Message:
Please take a look.
Description:
utils/ssh: Override rsa.GenerateKey in tests
Make ssh tests faster by generating one, smaller,
RSA key and reusing it for all tests. This is
particularly helpful on arm where the math prime
functions are very slow.
https:/ /code.launchpad .net/~gz/ juju-core/ generatekey_ testoverride_ 1312850/ +merge/ 217314
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/95780044/
Affected files (+31, -1 lines): clientkeys_ test.go export_ test.go generate. go generate_ test.go ssh_gocrypto_ test.go ssh_test. go
A [revision details]
M utils/ssh/
M utils/ssh/
M utils/ssh/
M utils/ssh/
M utils/ssh/
M utils/ssh/
Index: [revision details] 20140423115706- 1c02li5w6rmcg53 3
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: utils/ssh/ clientkeys_ test.go ssh/clientkeys_ test.go' clientkeys_ test.go 2014-03-13 07:54:56 +0000 clientkeys_ test.go 2014-04-25 23:47:12 +0000 MakeEmptyFakeHo me(c) (func(* gc.C) { fakeHome.Restore() }) (func(* gc.C) { ssh.ClearClient Keys() }) eKey(c) func(*gc. C) { generateKeyRest orer.Restore( ) })
=== modified file 'utils/
--- utils/ssh/
+++ utils/ssh/
@@ -27,6 +27,8 @@
fakeHome := testing.
s.AddCleanup
s.AddCleanup
+ generateKeyRestorer := overrideGenerat
+ s.AddCleanup(
}
func checkFiles(c *gc.C, obtained, expected []string) {
Index: utils/ssh/ export_ test.go ssh/export_ test.go' export_ test.go 2014-02-14 04:58:10 +0000 export_ test.go 2014-04-25 23:47:12 +0000 lient = initDefaultClient ities = &defaultIdentities
=== modified file 'utils/
--- utils/ssh/
+++ utils/ssh/
@@ -9,4 +9,5 @@
InitDefaultC
DefaultIdent
SSHDial = &sshDial
+ RSAGenerateKey = &rsaGenerateKey
)
Index: utils/ssh/ generate. go ssh/generate. go' generate. go 2013-12-19 20:55:25 +0000 generate. go 2014-04-25 23:47:12 +0000 google. com/p/go. crypto/ ssh"
=== modified file 'utils/
--- utils/ssh/
+++ utils/ssh/
@@ -14,6 +14,8 @@
"code.
)
+var rsaGenerateKey = rsa.GenerateKey (rand.Reader, KeyBits) rand.Reader, KeyBits)
+
// KeyBits is used to determine the number of bits to use for the RSA keys
// created using the GenerateKey function.
var KeyBits = 2048
@@ -24,7 +26,7 @@
// be added into an authorized_keys file, and has the comment passed in as
the
// comment part of the key.
func GenerateKey(comment string) (private, public string, err error) {
- key, err := rsa.GenerateKey
+ key, err := rsaGenerateKey(
if err != nil {
return "", "", err
}
Index: utils/ssh/ generate_ test.go ssh/generate_ test.go' generate_ test.go 2014-03-13 07:54:56 +0000 generate_ test.go 2014-04-25 23:47:12 +0000
=== modified file 'utils/
--- utils/ssh/
+++ utils/ssh/
@@ -4,6 +4,10 @@
package ssh_test
import ( com/juju/ testing" com/juju/ testing/ checkers" net/gocheck"
+ "crypto/rsa"
+ "io"
+
+ "github.
jc "github.
gc "launchpad.
@@ -17,7 +21,23 @@
var _ = gc.Suite( &GenerateSuite{ })
+var pregeneratedKey *rsa.Pr...