Skip to content

Commit

Permalink
Added dkim selector mock endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Jan 19, 2021
1 parent 9c39a97 commit 820b804
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
16 changes: 16 additions & 0 deletions mock_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (ms *MockServer) addDomainRoutes(r chi.Router) {
r.Put("/domains/{domain}/tracking/open", ms.updateOpenTracking)
r.Put("/domains/{domain}/tracking/unsubscribe", ms.updateUnsubTracking)
r.Get("/domains/{domain}/limits/tag", ms.getTagLimits)
r.Put("/domains/{domain}/dkim_selector", ms.updateDKIMSelector)
}

func (ms *MockServer) listDomains(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -281,3 +282,18 @@ func (ms *MockServer) getTagLimits(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
toJSON(w, okResp{Message: "domain not found"})
}

func (ms *MockServer) updateDKIMSelector(w http.ResponseWriter, r *http.Request) {
for _, d := range ms.domainList {
if d.Domain.Name == chi.URLParam(r, "domain") {
if r.FormValue("dkim_selector") == "" {
toJSON(w, okResp{Message: "dkim_selector param required"})
return
}
toJSON(w, okResp{Message: "updated dkim selector"})
return
}
}
w.WriteHeader(http.StatusNotFound)
toJSON(w, okResp{Message: "domain not found"})
}

0 comments on commit 820b804

Please sign in to comment.