Skip to content

Commit

Permalink
Use mock MTA-STS check
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrown608 committed Mar 6, 2019
1 parent 43b7061 commit 78a45a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Checker struct {
checkHostnameOverride func(string, string) HostnameResult

// checkMTASTSOverride is used to mock MTA-STS checks.
checkMTASTSOverride func(string, map[string]HostnameResult) Result
checkMTASTSOverride func(string, map[string]HostnameResult) *MTASTSResult
}

func (c *Checker) timeout() time.Duration {
Expand Down
6 changes: 4 additions & 2 deletions checker/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ var hostnameResults = map[string]Result{
},
}

func mockCheckMTASTS(domain string, hostnameResults map[string]HostnameResult) Result {
return Result{Status: Success}
func mockCheckMTASTS(domain string, hostnameResults map[string]HostnameResult) *MTASTSResult {
r := MakeMTASTSResult()
r.Mode = "testing"
return r
}

func mockLookupMX(domain string) ([]*net.MX, error) {
Expand Down
4 changes: 4 additions & 0 deletions checker/mta_sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ func validateMTASTSMXs(policyFileMXs []string, dnsMXs map[string]HostnameResult,
}

func (c Checker) checkMTASTS(domain string, hostnameResults map[string]HostnameResult) *MTASTSResult {
if c.checkMTASTSOverride != nil {
// Allow the Checker to mock this function.
return c.checkMTASTSOverride(domain, hostnameResults)
}
result := MakeMTASTSResult()
result.addCheck(checkMTASTSRecord(domain))
policyResult, policy, policyMap := checkMTASTSPolicyFile(domain, hostnameResults)
Expand Down

0 comments on commit 78a45a9

Please sign in to comment.