-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpg_test.go
61 lines (47 loc) · 1 KB
/
gpg_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package MIMEMail
import (
"bytes"
"testing"
)
func TestPGPRead(t *testing.T) {
cnf := getTestConfig(t)
out := bytes.NewBuffer(nil)
plain, err := Encrypt(out, cnf.receiver, nil)
if err != nil {
t.Fatal(err)
}
if _, err := plain.Write([]byte("foo bar baz, es pgp'ed so schön!")); err != nil {
t.Fatal(err)
}
plain.Close()
t.Logf("encrypted:\n%s\n", out.Bytes())
}
func TestPGPSend(t *testing.T) {
cnf := getTestConfig(t)
m := getTestMail(t, cnf)
c, err := TLSClient(cnf.sender)
if err != nil {
t.Fatal(err)
}
defer c.Quit()
from, err := m.EffectiveSender()
if err != nil {
t.Fatal(err)
}
out, err := c.W(from, m.Recipients())
if err != nil {
t.Fatal(err)
}
if err := m.WriteEncrypted(out, cnf.receiver, cnf.sender); err != nil {
t.Fatal(err)
}
}
func TestPGPEncrypt(t *testing.T) {
cnf := getTestConfig(t)
m := getTestMail(t, cnf)
out := bytes.NewBuffer(nil)
if err := m.WriteEncrypted(out, cnf.receiver, cnf.sender); err != nil {
t.Fatal(err)
}
t.Log(out.String())
}