-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
214: Refactor key book-keeping r=mkmik a=mkmik Prepares the ground for addressing #185 and #199 without adding any feature. The only small side effect is that now private keys are attempted in random order (Go map iteration order). This could only affect users who have turned on the key rotation feature which, as mentioned in #137, is not yet ready for prime time in the first place. Also improves on #190. Co-authored-by: Marko Mikulicic <[email protected]>
- Loading branch information
Showing
88 changed files
with
21,184 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestRegisterNewKey(t *testing.T) { | ||
const keySize = 2048 | ||
kr := NewKeyRegistry(nil, "namespace", "prefix", "label", keySize) | ||
|
||
if kr.mostRecentKey != nil { | ||
t.Fatal("this test assumes a new key registry has no keys") | ||
} | ||
|
||
key1, cert1, err := generatePrivateKeyAndCert(keySize) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
t1 := time.Now() | ||
|
||
key2, cert2, err := generatePrivateKeyAndCert(keySize) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
t2 := time.Now() | ||
|
||
if err := kr.registerNewKey("k2", key2, cert2, t2); err != nil { | ||
t.Fatal(err) | ||
} | ||
if got, want := kr.mostRecentKey.private, key2; got != want { | ||
t.Errorf("got: %v, want: %v", got, want) | ||
} | ||
|
||
// key1 is older, so it shouldn't replace key2 as the mostRecentKey | ||
if err := kr.registerNewKey("k1", key1, cert1, t1); err != nil { | ||
t.Fatal(err) | ||
} | ||
if got, want := kr.mostRecentKey.private, key2; got != want { | ||
t.Errorf("got: %v, want: %v", got, want) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.