Change verification system, add tests for issue 11 (#13)
This commit is contained in:
parent
781681b548
commit
b30f047e53
5 changed files with 143 additions and 4 deletions
|
|
@ -102,3 +102,35 @@ func TestBinaryMessageEncryption(t *testing.T) {
|
|||
assert.Exactly(t, constants.SIGNATURE_OK, ver.GetVerification())
|
||||
assert.Exactly(t, true, ver.IsValid())
|
||||
}
|
||||
|
||||
func TestIssue11(t *testing.T) {
|
||||
myKeyring, err := pgp.BuildKeyRingArmored(readTestFile("issue11_privatekey", false))
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while bulding private keyring, got:", err)
|
||||
}
|
||||
|
||||
err = myKeyring.UnlockWithPassphrase("1234");
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while unlocking private keyring, got:", err)
|
||||
}
|
||||
|
||||
senderKeyring, err := pgp.BuildKeyRingArmored(readTestFile("issue11_publickey", false))
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while building public keyring, got:", err)
|
||||
}
|
||||
|
||||
assert.Exactly(t, []uint64{0x643b3595e6ee4fdf}, senderKeyring.KeyIds())
|
||||
|
||||
pgpMessage, err := NewPGPMessageFromArmored(readTestFile("issue11_message", false))
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while unlocking private keyring, got:", err)
|
||||
}
|
||||
|
||||
plainMessage, verification, err := myKeyring.Decrypt(pgpMessage, senderKeyring, 0)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while decrypting/verifying, got:", err)
|
||||
}
|
||||
|
||||
assert.Exactly(t, "message from sender", plainMessage.GetString())
|
||||
assert.Exactly(t, true, verification.IsValid())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue