Skip to content

Commit

Permalink
openpgp: check errors from ReadKeyRing during test
Browse files Browse the repository at this point in the history
Otherwise if ReadKeyRing is buggy the errors point elsewhere.

Change-Id: Id2df4b6763ddf93fad5a9824f94af426bf0b7700
Reviewed-on: https://go-review.googlesource.com/62153
Reviewed-by: Adam Langley <agl@golang.org>
  • Loading branch information
rsc authored and agl committed Sep 9, 2017
1 parent 81e9090 commit 8f297cd
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions openpgp/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import (
)

func TestKeyExpiry(t *testing.T) {
kring, _ := ReadKeyRing(readerFromHex(expiringKeyHex))
kring, err := ReadKeyRing(readerFromHex(expiringKeyHex))
if err != nil {
t.Fatal(err)
}
entity := kring[0]

const timeFormat = "2006-01-02"
Expand Down Expand Up @@ -104,7 +107,10 @@ func TestGoodCrossSignature(t *testing.T) {

// TestExternallyRevokableKey attempts to load and parse a key with a third party revocation permission.
func TestExternallyRevocableKey(t *testing.T) {
kring, _ := ReadKeyRing(readerFromHex(subkeyUsageHex))
kring, err := ReadKeyRing(readerFromHex(subkeyUsageHex))
if err != nil {
t.Fatal(err)
}

// The 0xA42704B92866382A key can be revoked by 0xBE3893CB843D0FE70C
// according to this signature that appears within the key:
Expand All @@ -125,7 +131,10 @@ func TestExternallyRevocableKey(t *testing.T) {
}

func TestKeyRevocation(t *testing.T) {
kring, _ := ReadKeyRing(readerFromHex(revokedKeyHex))
kring, err := ReadKeyRing(readerFromHex(revokedKeyHex))
if err != nil {
t.Fatal(err)
}

// revokedKeyHex contains these keys:
// pub 1024R/9A34F7C0 2014-03-25 [revoked: 2014-03-25]
Expand All @@ -145,7 +154,10 @@ func TestKeyRevocation(t *testing.T) {
}

func TestSubkeyRevocation(t *testing.T) {
kring, _ := ReadKeyRing(readerFromHex(revokedSubkeyHex))
kring, err := ReadKeyRing(readerFromHex(revokedSubkeyHex))
if err != nil {
t.Fatal(err)
}

// revokedSubkeyHex contains these keys:
// pub 1024R/4EF7E4BECCDE97F0 2014-03-25
Expand Down Expand Up @@ -178,7 +190,10 @@ func TestSubkeyRevocation(t *testing.T) {
}

func TestKeyUsage(t *testing.T) {
kring, _ := ReadKeyRing(readerFromHex(subkeyUsageHex))
kring, err := ReadKeyRing(readerFromHex(subkeyUsageHex))
if err != nil {
t.Fatal(err)
}

// subkeyUsageHex contains these keys:
// pub 1024R/2866382A created: 2014-04-01 expires: never usage: SC
Expand Down

0 comments on commit 8f297cd

Please sign in to comment.