-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Truncate config.Now to second precision (#168)
* Truncate config.Now to second precision OpenPGP timestamps use seconds and not nanosecond precision. * Fix and rename TestReturnFirstUnexpiredSigningSubkey Fix the test to create subkeys with different creation times, so that the SigningKey function selects the later subkey, and rename the test to TestReturnNewestUnexpiredSigningSubkey. --------- Co-authored-by: Daniel Huigens <[email protected]>
- Loading branch information
Showing
2 changed files
with
9 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,7 @@ func TestExpiringPrimaryUIDKey(t *testing.T) { | |
} | ||
} | ||
|
||
func TestReturnFirstUnexpiredSigningSubkey(t *testing.T) { | ||
func TestReturnNewestUnexpiredSigningSubkey(t *testing.T) { | ||
// Make a master key. | ||
entity, err := NewEntity("Golang Gopher", "Test Key", "[email protected]", nil) | ||
if err != nil { | ||
|
@@ -140,6 +140,9 @@ func TestReturnFirstUnexpiredSigningSubkey(t *testing.T) { | |
|
||
// Second signing subkey expires in a day. | ||
err = entity.AddSigningSubkey(&packet.Config{ | ||
Time: func() time.Time { | ||
return time.Now().Add(1 * time.Second) | ||
}, | ||
KeyLifetimeSecs: 24 * 60 * 60, | ||
}) | ||
if err != nil { | ||
|
@@ -149,7 +152,7 @@ func TestReturnFirstUnexpiredSigningSubkey(t *testing.T) { | |
subkey2 := entity.Subkeys[2] | ||
|
||
// Before second signing subkey has expired, it should be returned. | ||
time1 := time.Now() | ||
time1 := time.Now().Add(2 * time.Second) | ||
expected := subkey2.PublicKey.KeyIdShortString() | ||
subkey, found := entity.SigningKey(time1) | ||
if !found { | ||
|
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