parent
9e896325f7
commit
c7debd51b9
|
@ -49,7 +49,12 @@ func SendError(
|
|||
}
|
||||
}
|
||||
|
||||
// Set the proper namespace for the problem and any
|
||||
// sub-problems
|
||||
prob.Type = probs.ProblemType(namespace) + prob.Type
|
||||
for i := range prob.SubProblems {
|
||||
prob.SubProblems[i].Type = probs.ProblemType(namespace) + prob.Type
|
||||
}
|
||||
problemDoc, err := json.MarshalIndent(prob, "", " ")
|
||||
if err != nil {
|
||||
log.AuditErrf("Could not marshal error message: %s - %+v", err, prob)
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
berrors "github.com/letsencrypt/boulder/errors"
|
||||
"github.com/letsencrypt/boulder/identifier"
|
||||
"github.com/letsencrypt/boulder/log"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
)
|
||||
|
||||
func TestSendErrorSubProblemNamespace(t *testing.T) {
|
||||
rw := httptest.NewRecorder()
|
||||
prob := ProblemDetailsForError((&berrors.BoulderError{
|
||||
Type: berrors.Malformed,
|
||||
Detail: "bad",
|
||||
}).WithSubErrors(
|
||||
[]berrors.SubBoulderError{
|
||||
berrors.SubBoulderError{
|
||||
Identifier: identifier.DNSIdentifier("example.com"),
|
||||
BoulderError: &berrors.BoulderError{
|
||||
Type: berrors.Malformed,
|
||||
Detail: "nop",
|
||||
},
|
||||
},
|
||||
berrors.SubBoulderError{
|
||||
Identifier: identifier.DNSIdentifier("what about example.com"),
|
||||
BoulderError: &berrors.BoulderError{
|
||||
Type: berrors.Malformed,
|
||||
Detail: "nah",
|
||||
},
|
||||
},
|
||||
}),
|
||||
"dfoop",
|
||||
)
|
||||
SendError(log.NewMock(), "namespace:test:", rw, &RequestEvent{}, prob, errors.New("it bad"))
|
||||
|
||||
body := rw.Body.String()
|
||||
test.AssertUnmarshaledEquals(t, body, `{
|
||||
"type": "namespace:test:malformed",
|
||||
"detail": "dfoop :: bad",
|
||||
"status": 400,
|
||||
"subproblems": [
|
||||
{
|
||||
"type": "namespace:test:namespace:test:malformed",
|
||||
"detail": "dfoop :: nop",
|
||||
"status": 400,
|
||||
"Identifier": {
|
||||
"type": "dns",
|
||||
"value": "example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "namespace:test:namespace:test:malformed",
|
||||
"detail": "dfoop :: nah",
|
||||
"status": 400,
|
||||
"Identifier": {
|
||||
"type": "dns",
|
||||
"value": "what about example.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
}`)
|
||||
}
|
Loading…
Reference in New Issue