-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
53 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,75 +4,10 @@ import ( | |
"bytes" | ||
"fmt" | ||
"github.com/emersion/go-message" | ||
log "github.com/sirupsen/logrus" | ||
"io" | ||
"os" | ||
"pmail/config" | ||
"pmail/db" | ||
"pmail/session" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func testInit() { | ||
// 设置日志格式为json格式 | ||
//log.SetFormatter(&log.JSONFormatter{}) | ||
|
||
log.SetReportCaller(true) | ||
log.SetFormatter(&log.TextFormatter{ | ||
//以下设置只是为了使输出更美观 | ||
DisableColors: true, | ||
TimestampFormat: "2006-01-02 15:03:04", | ||
}) | ||
|
||
// 设置将日志输出到标准输出(默认的输出为stderr,标准错误) | ||
// 日志消息输出可以是任意的io.writer类型 | ||
log.SetOutput(os.Stdout) | ||
|
||
// 设置日志级别为warn以上 | ||
log.SetLevel(log.TraceLevel) | ||
|
||
var cst, _ = time.LoadLocation("Asia/Shanghai") | ||
time.Local = cst | ||
|
||
config.Init() | ||
config.Instance.DkimPrivateKeyPath = "../../config/dkim/dkim.priv" | ||
config.Instance.DbType = config.DBTypeSQLite | ||
config.Instance.DbDSN = "../../config/pmail_temp.db" | ||
|
||
Init() | ||
db.Init() | ||
session.Init() | ||
|
||
} | ||
func TestEmail_domainMatch(t *testing.T) { | ||
//e := &Email{} | ||
//dnsNames := []string{ | ||
// "*.mail.qq.com", | ||
// "993.dav.qq.com", | ||
// "993.eas.qq.com", | ||
// "993.imap.qq.com", | ||
// "993.pop.qq.com", | ||
// "993.smtp.qq.com", | ||
// "imap.qq.com", | ||
// "mx1.qq.com", | ||
// "mx2.qq.com", | ||
// "mx3.qq.com", | ||
// "pop.qq.com", | ||
// "smtp.qq.com", | ||
// "mail.qq.com", | ||
//} | ||
// | ||
//fmt.Println(e.domainMatch("", dnsNames)) | ||
//fmt.Println(e.domainMatch("xjiangwei.cn", dnsNames)) | ||
//fmt.Println(e.domainMatch("qq.com", dnsNames)) | ||
//fmt.Println(e.domainMatch("test.aaa.mail.qq.com", dnsNames)) | ||
//fmt.Println(e.domainMatch("smtp.qq.com", dnsNames)) | ||
//fmt.Println(e.domainMatch("pop.qq.com", dnsNames)) | ||
//fmt.Println(e.domainMatch("test.mail.qq.com", dnsNames)) | ||
|
||
} | ||
|
||
func Test_buildUser(t *testing.T) { | ||
u := buildUser("Jinnrry N <[email protected]>") | ||
if u.EmailAddress != "[email protected]" { | ||
|
@@ -130,8 +65,6 @@ func TestEmailBuidlers(t *testing.T) { | |
} | ||
|
||
func TestEmail_builder(t *testing.T) { | ||
testInit() | ||
|
||
e := Email{ | ||
From: buildUser("[email protected]"), | ||
To: buildUsers([]string{"[email protected]"}), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1 @@ | ||
package models | ||
|
||
import "pmail/db" | ||
|
||
func SyncTables() { | ||
err := db.Instance.Sync2(&User{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = db.Instance.Sync2(&Email{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = db.Instance.Sync2(&Group{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = db.Instance.Sync2(&Rule{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = db.Instance.Sync2(&UserAuth{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = db.Instance.Sync2(&Sessions{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters