统一 frontend、backend、test、test-log 和 out 目录,更新构建、部署及测试入口;纳入配置管理兼容与首次安全引导修复;排除本机配置、密钥和测试产物。
This commit is contained in:
1 parent
28cd9d3406
commit
f60d3b0880
603 files changed
+2351
-660
No files matched your search
@@ -0,0 +1,69 @@
|
||||
package parsemail
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.pcux.cn/xuans/Smail/models"
|
||||
)
|
||||
|
||||
func TestNewEmailAuthentication(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
spfPassed bool
|
||||
dkimPassed bool
|
||||
dangerous bool
|
||||
}{
|
||||
{name: "SPF和DKIM均通过", spfPassed: true, dkimPassed: true},
|
||||
{name: "仅SPF通过", spfPassed: true, dkimPassed: false},
|
||||
{name: "仅DKIM通过", spfPassed: false, dkimPassed: true},
|
||||
{name: "SPF和DKIM均未通过", spfPassed: false, dkimPassed: false, dangerous: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
authentication := NewEmailAuthentication(tt.spfPassed, tt.dkimPassed)
|
||||
if authentication.SPFPassed != tt.spfPassed {
|
||||
t.Fatalf("SPFPassed = %v,期望 %v", authentication.SPFPassed, tt.spfPassed)
|
||||
}
|
||||
if authentication.DKIMPassed != tt.dkimPassed {
|
||||
t.Fatalf("DKIMPassed = %v,期望 %v", authentication.DKIMPassed, tt.dkimPassed)
|
||||
}
|
||||
if authentication.Dangerous != tt.dangerous {
|
||||
t.Fatalf("Dangerous = %v,期望 %v", authentication.Dangerous, tt.dangerous)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewEmailFromModelRestoresAuthenticationForReceivedEmail(t *testing.T) {
|
||||
email, err := NewEmailFromModel(models.Email{
|
||||
Type: 0,
|
||||
SPFCheck: 1,
|
||||
DKIMCheck: 0,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if email.Authentication == nil {
|
||||
t.Fatal("收件邮件缺少认证结果")
|
||||
}
|
||||
if !email.Authentication.SPFPassed || email.Authentication.DKIMPassed || email.Authentication.Dangerous {
|
||||
t.Fatalf("认证结果不正确:%+v", email.Authentication)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewEmailFromModelLeavesAuthenticationNilForSentEmail(t *testing.T) {
|
||||
email, err := NewEmailFromModel(models.Email{
|
||||
Type: 1,
|
||||
SPFCheck: 1,
|
||||
DKIMCheck: 1,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if email.Authentication != nil {
|
||||
t.Fatalf("发件邮件不应包含收信认证结果:%+v", email.Authentication)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user