summaryrefslogtreecommitdiffstats
path: root/katzenpost/dispatcher/envelope_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'katzenpost/dispatcher/envelope_test.go')
-rw-r--r--katzenpost/dispatcher/envelope_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/katzenpost/dispatcher/envelope_test.go b/katzenpost/dispatcher/envelope_test.go
new file mode 100644
index 0000000..712071c
--- /dev/null
+++ b/katzenpost/dispatcher/envelope_test.go
@@ -0,0 +1,21 @@
+package dispatcher
+
+import "testing"
+
+func TestEnvelopeValidate(t *testing.T) {
+ allowed := map[string]struct{}{"remailer.example": {}}
+ valid := Envelope{
+ EntryAddress: "entry@remailer.example",
+ Message: []byte("To: entry@remailer.example\nFrom: mix@nowhere.invalid\n\n-----BEGIN REMAILER MESSAGE-----\nabc\n"),
+ }
+ if err := valid.Validate(allowed); err != nil {
+ t.Fatalf("expected valid envelope: %v", err)
+ }
+
+ invalidDomain := valid
+ invalidDomain.EntryAddress = "entry@other.example"
+ invalidDomain.Message = []byte("To: entry@other.example\n-----BEGIN REMAILER MESSAGE-----\n")
+ if err := invalidDomain.Validate(allowed); err == nil {
+ t.Fatal("expected unknown domain rejection")
+ }
+}