Skip to content

Commit

Permalink
removed /v3 validation mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc committed Jan 3, 2025
1 parent e6977cd commit 41173d3
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions mock_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
)

func (ms *mockServer) addValidationRoutes(r chi.Router) {
r.Get("/v3/address/validate", ms.validateEmail)
r.Get("/v3/address/parse", ms.parseEmail)
r.Get("/v3/address/private/validate", ms.validateEmail)
r.Get("/v3/address/private/parse", ms.parseEmail)
r.Get("/v4/address/validate", ms.validateEmailV4)
}

Expand Down Expand Up @@ -41,44 +37,3 @@ func (ms *mockServer) validateEmailV4(w http.ResponseWriter, r *http.Request) {
}
toJSON(w, results)
}

func (ms *mockServer) validateEmail(w http.ResponseWriter, r *http.Request) {
if r.FormValue("address") == "" {
w.WriteHeader(http.StatusBadRequest)
toJSON(w, okResp{Message: "'address' parameter is required"})
return
}

var results EmailVerification
parts, err := mail.ParseAddress(r.FormValue("address"))
if err == nil {
results.IsValid = true
results.Parts.Domain = strings.Split(parts.Address, "@")[1]
results.Parts.LocalPart = strings.Split(parts.Address, "@")[0]
results.Parts.DisplayName = parts.Name
}
results.Reason = "no-reason"
results.Risk = "unknown"
toJSON(w, results)
}

func (ms *mockServer) parseEmail(w http.ResponseWriter, r *http.Request) {
if r.FormValue("addresses") == "" {
w.WriteHeader(http.StatusBadRequest)
toJSON(w, okResp{Message: "'addresses' parameter is required"})
return
}

addresses := strings.Split(r.FormValue("addresses"), ",")

var results addressParseResult
for _, address := range addresses {
_, err := mail.ParseAddress(address)
if err != nil {
results.Unparseable = append(results.Unparseable, address)
} else {
results.Parsed = append(results.Parsed, address)
}
}
toJSON(w, results)
}

0 comments on commit 41173d3

Please sign in to comment.