InvalidEmailProblem should return 400 httpcode.
This commit is contained in:
parent
66c90b6ea4
commit
d2ee8d5754
|
|
@ -47,7 +47,7 @@ func ProblemDetailsToStatusCode(prob *ProblemDetails) int {
|
|||
return prob.HTTPStatus
|
||||
}
|
||||
switch prob.Type {
|
||||
case ConnectionProblem, MalformedProblem, TLSProblem, UnknownHostProblem, BadNonceProblem:
|
||||
case ConnectionProblem, MalformedProblem, TLSProblem, UnknownHostProblem, BadNonceProblem, InvalidEmailProblem:
|
||||
return http.StatusBadRequest
|
||||
case ServerInternalProblem:
|
||||
return http.StatusInternalServerError
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func TestProblemDetails(t *testing.T) {
|
||||
|
|
@ -14,3 +15,30 @@ func TestProblemDetails(t *testing.T) {
|
|||
}
|
||||
test.AssertEquals(t, pd.Error(), "urn:acme:error:malformed :: Wat? o.O")
|
||||
}
|
||||
|
||||
func TestProblemDetailsToStatusCode(t *testing.T) {
|
||||
testCases := []struct {
|
||||
pb *ProblemDetails
|
||||
statusCode int
|
||||
}{
|
||||
{&ProblemDetails{Type: ConnectionProblem}, http.StatusBadRequest},
|
||||
{&ProblemDetails{Type: MalformedProblem}, http.StatusBadRequest},
|
||||
{&ProblemDetails{Type: ServerInternalProblem}, http.StatusInternalServerError},
|
||||
{&ProblemDetails{Type: TLSProblem}, http.StatusBadRequest},
|
||||
{&ProblemDetails{Type: UnauthorizedProblem}, http.StatusForbidden},
|
||||
{&ProblemDetails{Type: UnknownHostProblem}, http.StatusBadRequest},
|
||||
{&ProblemDetails{Type: RateLimitedProblem}, statusTooManyRequests},
|
||||
{&ProblemDetails{Type: BadNonceProblem}, http.StatusBadRequest},
|
||||
{&ProblemDetails{Type: InvalidEmailProblem}, http.StatusBadRequest},
|
||||
{&ProblemDetails{Type: "foo"}, http.StatusInternalServerError},
|
||||
{&ProblemDetails{Type: "foo", HTTPStatus: 200}, 200},
|
||||
{&ProblemDetails{Type: ConnectionProblem, HTTPStatus: 200}, 200},
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
p := ProblemDetailsToStatusCode(c.pb)
|
||||
if c.statusCode != p {
|
||||
t.Errorf("Incorrect status code for %s. Expected %d, got %d", c.pb.Type, c.statusCode, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue