fix
This commit is contained in:
4 files changed
+141
-1
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestQuoteTXTAndPayloadRoundTrip(t *testing.T) {
|
||||
long := "v=DKIM1; p=" + strings.Repeat("A", 400)
|
||||
for _, v := range []string{"v=spf1 ~all", long, `a"b\c`} {
|
||||
q := QuoteTXT(v)
|
||||
if !strings.HasPrefix(q, `"`) {
|
||||
t.Fatalf("not quoted: %q", q)
|
||||
}
|
||||
if got := TXTPayload(q); got != v {
|
||||
t.Fatalf("roundtrip: got %q want %q", got, v)
|
||||
}
|
||||
if TXTPayload(v) != v && !strings.HasPrefix(v, `"`) {
|
||||
t.Fatalf("unquoted payload changed")
|
||||
}
|
||||
}
|
||||
if QuoteTXT(`"x"`) != `"x"` {
|
||||
t.Fatal("quoted must pass through")
|
||||
}
|
||||
a := Record{Type: TXT, Values: []string{"v=DKIM1; k=rsa"}}
|
||||
b := Record{Type: TXT, Values: []string{`"v=DKIM1; k=rsa"`}}
|
||||
if !a.Equal(b) {
|
||||
t.Fatal("quoted and unquoted must compare equal")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user