Add signature tests, fix tests

This commit is contained in:
Aron Wussler 2019-05-14 16:08:25 +00:00 committed by Daniel Huigens
parent 4081e693fc
commit b42e382224
8 changed files with 121 additions and 27 deletions

View file

@ -17,10 +17,10 @@ func TestMessageEncryptionWithPassword(t *testing.T) {
t.Fatal("Expected no error when encrypting, got:", err)
}
// Decrypt data with wrong password
text, err := pmCrypto.DecryptMessageWithPassword(armor, "wrong password")
_, err = pmCrypto.DecryptMessageWithPassword(armor, "wrong password")
assert.NotNil(t, err)
// Decrypt data with the good password
text, err = pmCrypto.DecryptMessageWithPassword(armor, password)
text, err := pmCrypto.DecryptMessageWithPassword(armor, password)
if err != nil {
t.Fatal("Expected no error when decrypting, got:", err)
}
@ -33,9 +33,9 @@ func TestMessageEncryption(t *testing.T) {
message = "plain text"
)
testPrivateKeyRing, err = ReadArmoredKeyRing(strings.NewReader(readTestFile("keyring_privateKey")))
testPrivateKeyRing.Unlock([]byte(testMailboxPassword))
testPublicKeyRing, err = ReadArmoredKeyRing(strings.NewReader(readTestFile("keyring_publicKey")))
testPrivateKeyRing, err = ReadArmoredKeyRing(strings.NewReader(readTestFile("keyring_privateKey", false)))
_ = testPrivateKeyRing.Unlock([]byte(testMailboxPassword))
testPublicKeyRing, _ = ReadArmoredKeyRing(strings.NewReader(readTestFile("keyring_publicKey", false)))
armor, err := pmCrypto.EncryptMessage(message, testPublicKeyRing, testPrivateKeyRing, testMailboxPassword, false)
if err != nil {