From 941dffe2c7de4a35f23da87ba798e1c4af425ef4 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Wed, 18 Mar 2020 15:50:40 -0700 Subject: [PATCH] conformance: fix http status codes for MANIFEST DELETE failures. Previously returning 404s as failure code, dist-spec says 400s. --- pkg/api/routes.go | 4 ++-- pkg/compliance/v1_0_0/check.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 068140a4..25b23588 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -416,10 +416,10 @@ func (rh *RouteHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) { if err != nil { switch err { case errors.ErrRepoNotFound: - WriteJSON(w, http.StatusNotFound, + WriteJSON(w, http.StatusBadRequest, NewErrorList(NewError(NAME_UNKNOWN, map[string]string{"name": name}))) case errors.ErrManifestNotFound: - WriteJSON(w, http.StatusNotFound, + WriteJSON(w, http.StatusBadRequest, NewErrorList(NewError(MANIFEST_UNKNOWN, map[string]string{"reference": reference}))) default: rh.c.Log.Error().Err(err).Msg("unexpected error") diff --git a/pkg/compliance/v1_0_0/check.go b/pkg/compliance/v1_0_0/check.go index 6749cd07..71a49b1f 100644 --- a/pkg/compliance/v1_0_0/check.go +++ b/pkg/compliance/v1_0_0/check.go @@ -531,7 +531,7 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) { // delete manifest by tag should fail resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/test:1.0") So(err, ShouldBeNil) - So(resp.StatusCode(), ShouldEqual, 404) + So(resp.StatusCode(), ShouldEqual, 400) // delete manifest by digest resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String()) So(err, ShouldBeNil) @@ -543,7 +543,7 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) { // delete again should fail resp, err = resty.R().Delete(baseURL + "/v2/repo7/manifests/" + digest.String()) So(err, ShouldBeNil) - So(resp.StatusCode(), ShouldEqual, 404) + So(resp.StatusCode(), ShouldEqual, 400) // check/get by tag resp, err = resty.R().Head(baseURL + "/v2/repo7/manifests/test:1.0")