Skip to content

Commit 0a030a3

Browse files
committed
refactor: Remove depricated tests
1 parent ae457d1 commit 0a030a3

File tree

3 files changed

+0
-292
lines changed

3 files changed

+0
-292
lines changed

openpgp/keys_v5_test.go

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -20,89 +20,6 @@ func TestReadPrivateForeignV5Key(t *testing.T) {
2020
}
2121
}
2222

23-
// Deprecated
24-
/*
25-
// TODO: Replace message with a correctly generated one.
26-
func testV5ForeignSignedMessage(t *testing.T) {
27-
kring, err := ReadArmoredKeyRing(strings.NewReader(v5PrivKey))
28-
if err != nil {
29-
t.Fatal(err)
30-
}
31-
msg := strings.NewReader(v5PrivKeyMsg)
32-
// Unarmor
33-
block, err := armor.Decode(msg)
34-
if err != nil {
35-
return
36-
}
37-
md, err := ReadMessage(block.Body, kring, nil, nil)
38-
if md.SignedBy == nil {
39-
t.Fatal("incorrect signer")
40-
}
41-
if err != nil {
42-
t.Fatal(err)
43-
}
44-
// Consume UnverifiedBody
45-
body, err := ioutil.ReadAll(md.UnverifiedBody)
46-
if err != nil {
47-
t.Fatal(err)
48-
}
49-
if !bytes.Equal(body, []byte("test")) {
50-
t.Fatal("bad body")
51-
}
52-
if md.SignatureError != nil {
53-
t.Fatal(md.SignatureError)
54-
}
55-
if err != nil {
56-
t.Fatal(err)
57-
}
58-
}
59-
60-
func TestReadPrivateEncryptedV5Key(t *testing.T) {
61-
c := &packet.Config{V5Keys: true}
62-
e, err := NewEntity("V5 Key Owner", "V5 Key", "[email protected]", c)
63-
if err != nil {
64-
t.Fatal(err)
65-
}
66-
password := []byte("test v5 key # password")
67-
// Encrypt private key
68-
if err = e.PrivateKey.Encrypt(password); err != nil {
69-
t.Fatal(err)
70-
}
71-
// Encrypt subkeys
72-
for _, sub := range e.Subkeys {
73-
if err = sub.PrivateKey.Encrypt(password); err != nil {
74-
t.Fatal(err)
75-
}
76-
}
77-
// Serialize, Read
78-
serializedEntity := bytes.NewBuffer(nil)
79-
err = e.SerializePrivateWithoutSigning(serializedEntity, nil)
80-
if err != nil {
81-
t.Fatal(err)
82-
}
83-
el, err := ReadKeyRing(serializedEntity)
84-
if err != nil {
85-
t.Fatal(err)
86-
}
87-
88-
// Decrypt
89-
if el[0].PrivateKey == nil {
90-
t.Fatal("No private key found")
91-
}
92-
if err = el[0].PrivateKey.Decrypt(password); err != nil {
93-
t.Error(err)
94-
}
95-
96-
// Decrypt subkeys
97-
for _, sub := range e.Subkeys {
98-
if err = sub.PrivateKey.Decrypt(password); err != nil {
99-
t.Error(err)
100-
}
101-
}
102-
103-
checkV5Key(t, el[0])
104-
}*/
105-
10623
func TestReadPrivateSerializeForeignV5Key(t *testing.T) {
10724
for _, str := range foreignKeys {
10825
el, err := ReadArmoredKeyRing(strings.NewReader(str))
@@ -113,28 +30,6 @@ func TestReadPrivateSerializeForeignV5Key(t *testing.T) {
11330
}
11431
}
11532

116-
// Deprecated
117-
/*
118-
func TestNewEntitySerializeV5Key(t *testing.T) {
119-
c := &packet.Config{V5Keys: true}
120-
e, err := NewEntity("V5 Key Owner", "V5 Key", "[email protected]", c)
121-
if err != nil {
122-
t.Fatal(err)
123-
}
124-
checkSerializeRead(t, e)
125-
}
126-
127-
func TestNewEntityV5Key(t *testing.T) {
128-
c := &packet.Config{
129-
V5Keys: true,
130-
}
131-
e, err := NewEntity("V5 Key Owner", "V5 Key", "[email protected]", c)
132-
if err != nil {
133-
t.Fatal(err)
134-
}
135-
checkV5Key(t, e)
136-
}*/
137-
13833
func checkV5Key(t *testing.T, ent *Entity) {
13934
key := ent.PrimaryKey
14035
if key.Version != 5 {

openpgp/v2/keys_test.go

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -685,67 +685,6 @@ func TestKeyWithSubKeyAndBadSelfSigOrder(t *testing.T) {
685685

686686
}
687687

688-
/*func TestKeyUsage(t *testing.T) {
689-
kring, err := ReadKeyRing(readerFromHex(subkeyUsageHex))
690-
if err != nil {
691-
t.Fatal(err)
692-
}
693-
694-
// subkeyUsageHex contains these keys:
695-
// pub 1024R/2866382A created: 2014-04-01 expires: never usage: SC
696-
// sub 1024R/936C9153 created: 2014-04-01 expires: never usage: E
697-
// sub 1024R/64D5F5BB created: 2014-04-02 expires: never usage: E
698-
// sub 1024D/BC0BA992 created: 2014-04-02 expires: never usage: S
699-
certifiers := []uint64{0xA42704B92866382A}
700-
signers := []uint64{0xA42704B92866382A, 0x42CE2C64BC0BA992}
701-
encrypters := []uint64{0x09C0C7D9936C9153, 0xC104E98664D5F5BB}
702-
703-
for _, id := range certifiers {
704-
keys := kring.KeysByIdUsage(id, packet.KeyFlagCertify)
705-
if len(keys) == 1 {
706-
if keys[0].PublicKey.KeyId != id {
707-
t.Errorf("Expected to find certifier key id %X, but got %X", id, keys[0].PublicKey.KeyId)
708-
}
709-
} else {
710-
t.Errorf("Expected one match for certifier key id %X, but got %d matches", id, len(keys))
711-
}
712-
}
713-
714-
for _, id := range signers {
715-
keys := kring.KeysByIdUsage(id, packet.KeyFlagSign)
716-
if len(keys) == 1 {
717-
if keys[0].PublicKey.KeyId != id {
718-
t.Errorf("Expected to find signing key id %X, but got %X", id, keys[0].PublicKey.KeyId)
719-
}
720-
} else {
721-
t.Errorf("Expected one match for signing key id %X, but got %d matches", id, len(keys))
722-
}
723-
724-
// This keyring contains no encryption keys that are also good for signing.
725-
keys = kring.KeysByIdUsage(id, packet.KeyFlagEncryptStorage|packet.KeyFlagEncryptCommunications)
726-
if len(keys) != 0 {
727-
t.Errorf("Unexpected match for encryption key id %X", id)
728-
}
729-
}
730-
731-
for _, id := range encrypters {
732-
keys := kring.KeysByIdUsage(id, packet.KeyFlagEncryptStorage|packet.KeyFlagEncryptCommunications)
733-
if len(keys) == 1 {
734-
if keys[0].PublicKey.KeyId != id {
735-
t.Errorf("Expected to find encryption key id %X, but got %X", id, keys[0].PublicKey.KeyId)
736-
}
737-
} else {
738-
t.Errorf("Expected one match for encryption key id %X, but got %d matches", id, len(keys))
739-
}
740-
741-
// This keyring contains no encryption keys that are also good for signing.
742-
keys = kring.KeysByIdUsage(id, packet.KeyFlagSign)
743-
if len(keys) != 0 {
744-
t.Errorf("Unexpected match for signing key id %X", id)
745-
}
746-
}
747-
}*/
748-
749688
func TestIdVerification(t *testing.T) {
750689
kring, err := ReadKeyRing(readerFromHex(testKeys1And2PrivateHex))
751690
if err != nil {
@@ -1464,25 +1403,6 @@ func TestRevokeSubkey(t *testing.T) {
14641403
}
14651404
}
14661405

1467-
/*func TestRevokeSubkeyWithAnotherEntity(t *testing.T) {
1468-
entity, err := NewEntity("Golang Gopher", "Test Key", "[email protected]", nil)
1469-
if err != nil {
1470-
t.Fatal(err)
1471-
}
1472-
1473-
sk := entity.Subkeys[0]
1474-
1475-
newEntity, err := NewEntity("Golang Gopher", "Test Key", "[email protected]", nil)
1476-
if err != nil {
1477-
t.Fatal(err)
1478-
}
1479-
1480-
err = newEntity.RevokeSubkey(&sk, packet.NoReason, "Key revocation", nil)
1481-
if err == nil {
1482-
t.Fatal("Entity was able to revoke a subkey owned by a different entity")
1483-
}
1484-
}*/
1485-
14861406
func TestRevokeSubkeyWithInvalidSignature(t *testing.T) {
14871407
entity, err := NewEntity("Golang Gopher", "Test Key", "[email protected]", nil)
14881408
if err != nil {

openpgp/v2/keys_v5_test.go

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -20,91 +20,6 @@ func TestReadPrivateForeignV5Key(t *testing.T) {
2020
}
2121
}
2222

23-
// Deprecated
24-
/*
25-
func testV5ForeignSignedMessage(t *testing.T) {
26-
kring, err := ReadArmoredKeyRing(strings.NewReader(v5PrivKey))
27-
if err != nil {
28-
t.Fatal(err)
29-
}
30-
msg := strings.NewReader(v5PrivKeyMsg)
31-
// Unarmor
32-
block, err := armor.Decode(msg)
33-
if err != nil {
34-
return
35-
}
36-
md, err := ReadMessage(block.Body, kring, nil, nil)
37-
if len(md.SignatureCandidates) < 1 {
38-
t.Fatal("no signature found")
39-
}
40-
if md.SignatureCandidates[0].SignedBy == nil {
41-
t.Fatal("incorrect signer")
42-
}
43-
if err != nil {
44-
t.Fatal(err)
45-
}
46-
// Consume UnverifiedBody
47-
body, err := ioutil.ReadAll(md.UnverifiedBody)
48-
if err != nil {
49-
t.Fatal(err)
50-
}
51-
if !bytes.Equal(body, []byte("test")) {
52-
t.Fatal("bad body")
53-
}
54-
if md.SignatureError != nil {
55-
t.Fatal(md.SignatureError)
56-
}
57-
if err != nil {
58-
t.Fatal(err)
59-
}
60-
}
61-
62-
func TestReadPrivateEncryptedV5Key(t *testing.T) {
63-
c := &packet.Config{V5Keys: true}
64-
e, err := NewEntity("V5 Key Owner", "V5 Key", "[email protected]", c)
65-
if err != nil {
66-
t.Fatal(err)
67-
}
68-
password := []byte("test v5 key # password")
69-
// Encrypt private key
70-
if err = e.PrivateKey.Encrypt(password); err != nil {
71-
t.Fatal(err)
72-
}
73-
// Encrypt subkeys
74-
for _, sub := range e.Subkeys {
75-
if err = sub.PrivateKey.Encrypt(password); err != nil {
76-
t.Fatal(err)
77-
}
78-
}
79-
// Serialize, Read
80-
serializedEntity := bytes.NewBuffer(nil)
81-
err = e.SerializePrivateWithoutSigning(serializedEntity, nil)
82-
if err != nil {
83-
t.Fatal(err)
84-
}
85-
el, err := ReadKeyRing(serializedEntity)
86-
if err != nil {
87-
t.Fatal(err)
88-
}
89-
90-
// Decrypt
91-
if el[0].PrivateKey == nil {
92-
t.Fatal("No private key found")
93-
}
94-
if err = el[0].PrivateKey.Decrypt(password); err != nil {
95-
t.Error(err)
96-
}
97-
98-
// Decrypt subkeys
99-
for _, sub := range e.Subkeys {
100-
if err = sub.PrivateKey.Decrypt(password); err != nil {
101-
t.Error(err)
102-
}
103-
}
104-
105-
checkV5Key(t, el[0])
106-
}*/
107-
10823
func TestReadPrivateSerializeForeignV5Key(t *testing.T) {
10924
for _, str := range foreignKeys {
11025
el, err := ReadArmoredKeyRing(strings.NewReader(str))
@@ -115,28 +30,6 @@ func TestReadPrivateSerializeForeignV5Key(t *testing.T) {
11530
}
11631
}
11732

118-
// Deprecated
119-
/*
120-
func TestNewEntitySerializeV5Key(t *testing.T) {
121-
c := &packet.Config{V5Keys: true}
122-
e, err := NewEntity("V5 Key Owner", "V5 Key", "[email protected]", c)
123-
if err != nil {
124-
t.Fatal(err)
125-
}
126-
checkSerializeRead(t, e)
127-
}
128-
129-
func TestNewEntityV5Key(t *testing.T) {
130-
c := &packet.Config{
131-
V5Keys: true,
132-
}
133-
e, err := NewEntity("V5 Key Owner", "V5 Key", "[email protected]", c)
134-
if err != nil {
135-
t.Fatal(err)
136-
}
137-
checkV5Key(t, e)
138-
}*/
139-
14033
func checkV5Key(t *testing.T, ent *Entity) {
14134
key := ent.PrimaryKey
14235
if key.Version != 5 {

0 commit comments

Comments
 (0)