Add getEntity and getEcryptionKeyIDs functions to key and message types respectively (#55)
* add getEntity function to key struct * add getEncryptionKeyIDs * add chengelog + bool return in getEncryptionKeyIDs * fix description
This commit is contained in:
parent
d1f6f7d718
commit
8d42a53775
5 changed files with 64 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/crypto/openpgp/packet"
|
||||
|
|
@ -208,6 +209,22 @@ func TestMultipleKeyMessageEncryption(t *testing.T) {
|
|||
assert.Exactly(t, message.GetString(), decrypted.GetString())
|
||||
}
|
||||
|
||||
func TestMessagegetGetEncryptionKeyIDs(t *testing.T) {
|
||||
var message = NewPlainMessageFromString("plain text")
|
||||
assert.Exactly(t, 3, len(keyRingTestMultiple.entities))
|
||||
|
||||
ciphertext, err := keyRingTestMultiple.Encrypt(message, keyRingTestPrivate)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when encrypting, got:", err)
|
||||
}
|
||||
ids, ok := ciphertext.getEncryptionKeyIDs()
|
||||
assert.Exactly(t, 3, len(ids))
|
||||
assert.True(t, ok)
|
||||
encKey, ok := keyRingTestMultiple.entities[0].EncryptionKey(time.Now())
|
||||
assert.True(t, ok)
|
||||
assert.Exactly(t, encKey.PublicKey.KeyId, ids[0])
|
||||
}
|
||||
|
||||
func TestMessageGetArmoredWithCustomHeaders(t *testing.T) {
|
||||
var message = NewPlainMessageFromString("plain text")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue