-
Notifications
You must be signed in to change notification settings - Fork 4
/
smtp_test.go
45 lines (38 loc) · 1.85 KB
/
smtp_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestLoop(t *testing.T) {
LOOP_DETECTION_COUNT = 5
email := makeEmail(`Received: from localhost (localhost [127.0.0.1]) by test1.smtp-in.mailway.app (mailout) with SMTP for <[email protected]>; Fri,
5 Feb 2021 19:01:27 +0000 (UTC)
Received: from mail.yahoo.com (mail.yahoo.com. [77.238.177.146]) by test1.smtp-in.mailway.app (fwdr) with SMTP for <[email protected]>; Fri,
5 Feb 2021 19:01:27 +0000 (UTC)
Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 5 Feb 2021 19:01:27 +0000
Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 5 Feb 2021 19:01:27 +0000
Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 5 Feb 2021 19:01:27 +0000
Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 5 Feb 2021 19:01:27 +0000
Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 5 Feb 2021 19:01:27 +0000
From: [email protected]
Subject: test
Date: Sun, 8 Jan 2017 20:37:44 +0200
Hello world!
`)
assert.True(t, hasLoop(&email))
}
func TestNoLoop(t *testing.T) {
email := makeEmail(`Received: from localhost (localhost [127.0.0.1]) by test1.smtp-in.mailway.app (mailout) with SMTP for <[email protected]>; Fri,
5 Feb 2021 19:01:27 +0000 (UTC)
Received: from mail.yahoo.com (mail.yahoo.com. [77.238.177.146]) by test1.smtp-in.mailway.app (fwdr) with SMTP for <[email protected]>; Fri,
5 Feb 2021 19:01:27 +0000 (UTC)
Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Fri, 5 Feb 2021 19:01:27 +0000
From: [email protected]
Subject: test
Date: Sun, 8 Jan 2017 20:37:44 +0200
Hello world!
`)
assert.False(t, hasLoop(&email))
}