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
|
package submit
import (
"strings"
"testing"
)
func TestBuildMessagePublishesProfileIdentityAndTransportSender(t *testing.T) {
sub := Submission{
From: "Alice <alice@example.invalid>",
Newsgroups: []string{"misc.test"},
Subject: "Test",
Message: "hello",
PublicKeyB64: "unused-without-face",
SignatureB64: "unused-without-face",
}
raw, _, err := BuildMessage(
sub,
"mail2news@mail2news.tcpreset.net",
"n2usenet@virebent.art",
"n2usenet.virebent.art",
"/missing/identicons-cli",
false,
)
if err != nil {
t.Fatalf("BuildMessage returned error: %v", err)
}
if !strings.Contains(raw, "From: \"Alice\" <alice@example.invalid>\r\n") {
t.Fatalf("profile identity is not used as the public From:\n%s", raw)
}
if !strings.Contains(raw, "Sender: <n2usenet@virebent.art>\r\n") {
t.Fatalf("transport Sender is missing:\n%s", raw)
}
if strings.Contains(raw, "From: \"Alice\" <n2usenet@virebent.art>\r\n") {
t.Fatalf("transport account replaced the public profile identity:\n%s", raw)
}
if strings.Contains(raw, "X-N2Usenet-Identity:") {
t.Fatalf("redundant private identity header is present:\n%s", raw)
}
}
|