Remove checks
This commit is contained in:
parent
954a9d705e
commit
0b4d32dada
28 changed files with 1656 additions and 3846 deletions
|
|
@ -22,7 +22,6 @@
|
|||
package analyzer
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.happydns.org/happyDeliver/internal/api"
|
||||
|
|
@ -246,250 +245,6 @@ func TestParseBIMIResult(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGenerateAuthSPFCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
spf *api.AuthResult
|
||||
expectedStatus api.CheckStatus
|
||||
expectedScore int
|
||||
}{
|
||||
{
|
||||
name: "SPF pass",
|
||||
spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusPass,
|
||||
expectedScore: 10,
|
||||
},
|
||||
{
|
||||
name: "SPF fail",
|
||||
spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultFail,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusFail,
|
||||
expectedScore: 0,
|
||||
},
|
||||
{
|
||||
name: "SPF softfail",
|
||||
spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultSoftfail,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusWarn,
|
||||
expectedScore: 5,
|
||||
},
|
||||
{
|
||||
name: "SPF neutral",
|
||||
spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultNeutral,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusWarn,
|
||||
expectedScore: 5,
|
||||
},
|
||||
}
|
||||
|
||||
analyzer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
check := analyzer.generateSPFCheck(tt.spf)
|
||||
|
||||
if check.Status != tt.expectedStatus {
|
||||
t.Errorf("Status = %v, want %v", check.Status, tt.expectedStatus)
|
||||
}
|
||||
if check.Score != tt.expectedScore {
|
||||
t.Errorf("Score = %v, want %v", check.Score, tt.expectedScore)
|
||||
}
|
||||
if check.Category != api.Authentication {
|
||||
t.Errorf("Category = %v, want %v", check.Category, api.Authentication)
|
||||
}
|
||||
if check.Name != "SPF Record" {
|
||||
t.Errorf("Name = %q, want %q", check.Name, "SPF Record")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateAuthDKIMCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
dkim *api.AuthResult
|
||||
index int
|
||||
expectedStatus api.CheckStatus
|
||||
expectedScore int
|
||||
}{
|
||||
{
|
||||
name: "DKIM pass",
|
||||
dkim: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
Selector: api.PtrTo("default"),
|
||||
},
|
||||
index: 0,
|
||||
expectedStatus: api.CheckStatusPass,
|
||||
expectedScore: 10,
|
||||
},
|
||||
{
|
||||
name: "DKIM fail",
|
||||
dkim: &api.AuthResult{
|
||||
Result: api.AuthResultResultFail,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
Selector: api.PtrTo("default"),
|
||||
},
|
||||
index: 0,
|
||||
expectedStatus: api.CheckStatusFail,
|
||||
expectedScore: 0,
|
||||
},
|
||||
{
|
||||
name: "DKIM none",
|
||||
dkim: &api.AuthResult{
|
||||
Result: api.AuthResultResultNone,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
Selector: api.PtrTo("default"),
|
||||
},
|
||||
index: 0,
|
||||
expectedStatus: api.CheckStatusWarn,
|
||||
expectedScore: 0,
|
||||
},
|
||||
}
|
||||
|
||||
analyzer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
check := analyzer.generateDKIMCheck(tt.dkim, tt.index)
|
||||
|
||||
if check.Status != tt.expectedStatus {
|
||||
t.Errorf("Status = %v, want %v", check.Status, tt.expectedStatus)
|
||||
}
|
||||
if check.Score != tt.expectedScore {
|
||||
t.Errorf("Score = %v, want %v", check.Score, tt.expectedScore)
|
||||
}
|
||||
if check.Category != api.Authentication {
|
||||
t.Errorf("Category = %v, want %v", check.Category, api.Authentication)
|
||||
}
|
||||
if !strings.Contains(check.Name, "DKIM Signature") {
|
||||
t.Errorf("Name should contain 'DKIM Signature', got %q", check.Name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateAuthDMARCCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
dmarc *api.AuthResult
|
||||
expectedStatus api.CheckStatus
|
||||
expectedScore int
|
||||
}{
|
||||
{
|
||||
name: "DMARC pass",
|
||||
dmarc: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusPass,
|
||||
expectedScore: 10,
|
||||
},
|
||||
{
|
||||
name: "DMARC fail",
|
||||
dmarc: &api.AuthResult{
|
||||
Result: api.AuthResultResultFail,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusFail,
|
||||
expectedScore: 0,
|
||||
},
|
||||
}
|
||||
|
||||
analyzer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
check := analyzer.generateDMARCCheck(tt.dmarc)
|
||||
|
||||
if check.Status != tt.expectedStatus {
|
||||
t.Errorf("Status = %v, want %v", check.Status, tt.expectedStatus)
|
||||
}
|
||||
if check.Score != tt.expectedScore {
|
||||
t.Errorf("Score = %v, want %v", check.Score, tt.expectedScore)
|
||||
}
|
||||
if check.Category != api.Authentication {
|
||||
t.Errorf("Category = %v, want %v", check.Category, api.Authentication)
|
||||
}
|
||||
if check.Name != "DMARC Policy" {
|
||||
t.Errorf("Name = %q, want %q", check.Name, "DMARC Policy")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateAuthBIMICheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
bimi *api.AuthResult
|
||||
expectedStatus api.CheckStatus
|
||||
expectedScore int
|
||||
}{
|
||||
{
|
||||
name: "BIMI pass",
|
||||
bimi: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusPass,
|
||||
expectedScore: 0, // BIMI doesn't contribute to score
|
||||
},
|
||||
{
|
||||
name: "BIMI fail",
|
||||
bimi: &api.AuthResult{
|
||||
Result: api.AuthResultResultFail,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusInfo,
|
||||
expectedScore: 0,
|
||||
},
|
||||
{
|
||||
name: "BIMI none",
|
||||
bimi: &api.AuthResult{
|
||||
Result: api.AuthResultResultNone,
|
||||
Domain: api.PtrTo("example.com"),
|
||||
},
|
||||
expectedStatus: api.CheckStatusInfo,
|
||||
expectedScore: 0,
|
||||
},
|
||||
}
|
||||
|
||||
analyzer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
check := analyzer.generateBIMICheck(tt.bimi)
|
||||
|
||||
if check.Status != tt.expectedStatus {
|
||||
t.Errorf("Status = %v, want %v", check.Status, tt.expectedStatus)
|
||||
}
|
||||
if check.Score != tt.expectedScore {
|
||||
t.Errorf("Score = %v, want %v", check.Score, tt.expectedScore)
|
||||
}
|
||||
if check.Category != api.Authentication {
|
||||
t.Errorf("Category = %v, want %v", check.Category, api.Authentication)
|
||||
}
|
||||
if check.Name != "BIMI (Brand Indicators)" {
|
||||
t.Errorf("Name = %q, want %q", check.Name, "BIMI (Brand Indicators)")
|
||||
}
|
||||
|
||||
// BIMI should always have score of 0.0 (branding feature)
|
||||
if check.Score != 0.0 {
|
||||
t.Error("BIMI should not contribute to deliverability score")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAuthenticationScore(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -563,11 +318,11 @@ func TestGetAuthenticationScore(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
scorer := NewDeliverabilityScorer()
|
||||
scorer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
score := scorer.GetAuthenticationScore(tt.results)
|
||||
score := scorer.CalculateAuthenticationScore(tt.results)
|
||||
|
||||
if score != tt.expectedScore {
|
||||
t.Errorf("Score = %v, want %v", score, tt.expectedScore)
|
||||
|
|
@ -576,92 +331,6 @@ func TestGetAuthenticationScore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGenerateAuthenticationChecks(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
results *api.AuthenticationResults
|
||||
expectedChecks int
|
||||
}{
|
||||
{
|
||||
name: "All authentication methods present",
|
||||
results: &api.AuthenticationResults{
|
||||
Spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
Dkim: &[]api.AuthResult{
|
||||
{Result: api.AuthResultResultPass},
|
||||
},
|
||||
Dmarc: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
Bimi: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
},
|
||||
expectedChecks: 4, // SPF, DKIM, DMARC, BIMI
|
||||
},
|
||||
{
|
||||
name: "Without BIMI",
|
||||
results: &api.AuthenticationResults{
|
||||
Spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
Dkim: &[]api.AuthResult{
|
||||
{Result: api.AuthResultResultPass},
|
||||
},
|
||||
Dmarc: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
},
|
||||
expectedChecks: 3, // SPF, DKIM, DMARC
|
||||
},
|
||||
{
|
||||
name: "No authentication results",
|
||||
results: &api.AuthenticationResults{},
|
||||
expectedChecks: 3, // SPF, DKIM, DMARC warnings for missing
|
||||
},
|
||||
{
|
||||
name: "With ARC",
|
||||
results: &api.AuthenticationResults{
|
||||
Spf: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
Dkim: &[]api.AuthResult{
|
||||
{Result: api.AuthResultResultPass},
|
||||
},
|
||||
Dmarc: &api.AuthResult{
|
||||
Result: api.AuthResultResultPass,
|
||||
},
|
||||
Arc: &api.ARCResult{
|
||||
Result: api.ARCResultResultPass,
|
||||
ChainLength: api.PtrTo(2),
|
||||
ChainValid: api.PtrTo(true),
|
||||
},
|
||||
},
|
||||
expectedChecks: 4, // SPF, DKIM, DMARC, ARC
|
||||
},
|
||||
}
|
||||
|
||||
analyzer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
checks := analyzer.GenerateAuthenticationChecks(tt.results)
|
||||
|
||||
if len(checks) != tt.expectedChecks {
|
||||
t.Errorf("Got %d checks, want %d", len(checks), tt.expectedChecks)
|
||||
}
|
||||
|
||||
// Verify all checks have the Authentication category
|
||||
for _, check := range checks {
|
||||
if check.Category != api.Authentication {
|
||||
t.Errorf("Check %s has category %v, want %v", check.Name, check.Category, api.Authentication)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseARCResult(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -783,64 +452,3 @@ func TestValidateARCChain(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateARCCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
arc *api.ARCResult
|
||||
expectedStatus api.CheckStatus
|
||||
expectedScore int
|
||||
}{
|
||||
{
|
||||
name: "ARC pass",
|
||||
arc: &api.ARCResult{
|
||||
Result: api.ARCResultResultPass,
|
||||
ChainLength: api.PtrTo(2),
|
||||
ChainValid: api.PtrTo(true),
|
||||
},
|
||||
expectedStatus: api.CheckStatusPass,
|
||||
expectedScore: 0, // ARC doesn't contribute to score
|
||||
},
|
||||
{
|
||||
name: "ARC fail",
|
||||
arc: &api.ARCResult{
|
||||
Result: api.ARCResultResultFail,
|
||||
ChainLength: api.PtrTo(1),
|
||||
ChainValid: api.PtrTo(false),
|
||||
},
|
||||
expectedStatus: api.CheckStatusWarn,
|
||||
expectedScore: 0,
|
||||
},
|
||||
{
|
||||
name: "ARC none",
|
||||
arc: &api.ARCResult{
|
||||
Result: api.ARCResultResultNone,
|
||||
ChainLength: api.PtrTo(0),
|
||||
ChainValid: api.PtrTo(true),
|
||||
},
|
||||
expectedStatus: api.CheckStatusInfo,
|
||||
expectedScore: 0,
|
||||
},
|
||||
}
|
||||
|
||||
analyzer := NewAuthenticationAnalyzer()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
check := analyzer.generateARCCheck(tt.arc)
|
||||
|
||||
if check.Status != tt.expectedStatus {
|
||||
t.Errorf("Status = %v, want %v", check.Status, tt.expectedStatus)
|
||||
}
|
||||
if check.Score != tt.expectedScore {
|
||||
t.Errorf("Score = %v, want %v", check.Score, tt.expectedScore)
|
||||
}
|
||||
if check.Category != api.Authentication {
|
||||
t.Errorf("Category = %v, want %v", check.Category, api.Authentication)
|
||||
}
|
||||
if !strings.Contains(check.Name, "ARC") {
|
||||
t.Errorf("Name should contain 'ARC', got %q", check.Name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue