Просмотр исходного кода

Should be returning status code 400 for ACME Account Not Found.

Issue #173
max furman 6 лет назад
Родитель
Сommit
c255274572

+ 1 - 1
acme/api/account.go

@@ -96,7 +96,7 @@ func (h *Handler) NewAccount(w http.ResponseWriter, r *http.Request) {
 	acc, err := accountFromContext(r)
 	if err != nil {
 		acmeErr, ok := err.(*acme.Error)
-		if !ok || acmeErr.Status != http.StatusNotFound {
+		if !ok || acmeErr.Status != http.StatusBadRequest {
 			// Something went wrong ...
 			api.WriteError(w, err)
 			return

+ 5 - 5
acme/api/account_test.go

@@ -202,7 +202,7 @@ func TestHandlerGetOrdersByAccount(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -212,7 +212,7 @@ func TestHandlerGetOrdersByAccount(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -378,7 +378,7 @@ func TestHandlerNewAccount(t *testing.T) {
 			ctx = context.WithValue(ctx, payloadContextKey, &payloadInfo{value: b})
 			return test{
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -569,7 +569,7 @@ func TestHandlerGetUpdateAccount(t *testing.T) {
 		"fail/no-account": func(t *testing.T) test {
 			return test{
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -578,7 +578,7 @@ func TestHandlerGetUpdateAccount(t *testing.T) {
 			ctx = context.WithValue(ctx, accContextKey, nil)
 			return test{
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},

+ 6 - 6
acme/api/handler_test.go

@@ -372,7 +372,7 @@ func TestHandlerGetAuthz(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -382,7 +382,7 @@ func TestHandlerGetAuthz(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -504,7 +504,7 @@ func TestHandlerGetCertificate(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -513,7 +513,7 @@ func TestHandlerGetCertificate(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -623,7 +623,7 @@ func TestHandlerGetChallenge(t *testing.T) {
 		"fail/no-account": func(t *testing.T) test {
 			return test{
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -632,7 +632,7 @@ func TestHandlerGetChallenge(t *testing.T) {
 			ctx = context.WithValue(ctx, accContextKey, nil)
 			return test{
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},

+ 1 - 1
acme/api/middleware_test.go

@@ -842,7 +842,7 @@ func TestHandlerLookupJWK(t *testing.T) {
 					},
 				},
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},

+ 6 - 6
acme/api/order_test.go

@@ -205,7 +205,7 @@ func TestHandlerGetOrder(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -215,7 +215,7 @@ func TestHandlerGetOrder(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -343,7 +343,7 @@ func TestHandlerNewOrder(t *testing.T) {
 		"fail/no-account": func(t *testing.T) test {
 			return test{
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -352,7 +352,7 @@ func TestHandlerNewOrder(t *testing.T) {
 			ctx = context.WithValue(ctx, accContextKey, nil)
 			return test{
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -597,7 +597,7 @@ func TestHandlerFinalizeOrder(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        context.WithValue(context.Background(), provisionerContextKey, prov),
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},
@@ -607,7 +607,7 @@ func TestHandlerFinalizeOrder(t *testing.T) {
 			return test{
 				auth:       &mockAcmeAuthority{},
 				ctx:        ctx,
-				statusCode: 404,
+				statusCode: 400,
 				problem:    acme.AccountDoesNotExistErr(nil),
 			}
 		},

+ 1 - 1
acme/errors.go

@@ -9,7 +9,7 @@ func AccountDoesNotExistErr(err error) *Error {
 	return &Error{
 		Type:   accountDoesNotExistErr,
 		Detail: "Account does not exist",
-		Status: 404,
+		Status: 400,
 		Err:    err,
 	}
 }