Rename PmCrypto to GopenPGP

This commit is contained in:
Daniel Huigens 2019-05-14 18:05:01 +02:00
parent 37cbb276fd
commit bb1be4a43b
19 changed files with 125 additions and 126 deletions

View file

@ -7,20 +7,20 @@ import (
)
func TestMessageEncryptionWithPassword(t *testing.T) {
var pmCrypto = PmCrypto{}
var pgp = GopenPGP{}
const password = "my secret password"
// Encrypt data with password
armor, err := pmCrypto.EncryptMessageWithPassword("my message", password)
armor, err := pgp.EncryptMessageWithPassword("my message", password)
if err != nil {
t.Fatal("Expected no error when encrypting, got:", err)
}
// Decrypt data with wrong password
_, err = pmCrypto.DecryptMessageWithPassword(armor, "wrong password")
_, err = pgp.DecryptMessageWithPassword(armor, "wrong password")
assert.NotNil(t, err)
// Decrypt data with the good password
text, err := pmCrypto.DecryptMessageWithPassword(armor, password)
text, err := pgp.DecryptMessageWithPassword(armor, password)
if err != nil {
t.Fatal("Expected no error when decrypting, got:", err)
}
@ -28,7 +28,7 @@ func TestMessageEncryptionWithPassword(t *testing.T) {
}
func TestMessageEncryption(t *testing.T) {
var pmCrypto = PmCrypto{}
var pgp = GopenPGP{}
var (
message = "plain text"
)
@ -37,11 +37,11 @@ func TestMessageEncryption(t *testing.T) {
_ = testPrivateKeyRing.Unlock([]byte(testMailboxPassword))
testPublicKeyRing, _ = ReadArmoredKeyRing(strings.NewReader(readTestFile("keyring_publicKey", false)))
armor, err := pmCrypto.EncryptMessage(message, testPublicKeyRing, testPrivateKeyRing, testMailboxPassword, false)
armor, err := pgp.EncryptMessage(message, testPublicKeyRing, testPrivateKeyRing, testMailboxPassword, false)
if err != nil {
t.Fatal("Expected no error when encrypting, got:", err)
}
plainText, err := pmCrypto.DecryptMessage(armor, testPrivateKeyRing, testMailboxPassword)
plainText, err := pgp.DecryptMessage(armor, testPrivateKeyRing, testMailboxPassword)
if err != nil {
t.Fatal("Expected no error when decrypting, got:", err)
}