Send correct NuGet status codes (#20647) (#20677)

* Fixed status codes.

* Fixed status codes.
This commit is contained in:
KN4CK3R 2022-08-05 03:38:04 +02:00 committed by GitHub
parent aac905dcfb
commit 65176fdaf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -122,7 +122,7 @@ func TestPackageNuGet(t *testing.T) {
req = NewRequestWithBody(t, "PUT", url, bytes.NewReader(content))
req = AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusBadRequest)
MakeRequest(t, req, http.StatusConflict)
})
t.Run("SymbolPackage", func(t *testing.T) {
@ -208,7 +208,7 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
req = NewRequestWithBody(t, "PUT", fmt.Sprintf("%s/symbolpackage", url), createPackage(packageName, "SymbolsPackage"))
req = AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusBadRequest)
MakeRequest(t, req, http.StatusConflict)
})
})
@ -352,7 +352,7 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
req := NewRequest(t, "DELETE", fmt.Sprintf("%s/%s/%s", url, packageName, packageVersion))
req = AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusOK)
MakeRequest(t, req, http.StatusNoContent)
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeNuGet)
assert.NoError(t, err)

View File

@ -215,7 +215,7 @@ func UploadPackage(ctx *context.Context) {
)
if err != nil {
if err == packages_model.ErrDuplicatePackageVersion {
apiError(ctx, http.StatusBadRequest, err)
apiError(ctx, http.StatusConflict, err)
return
}
apiError(ctx, http.StatusInternalServerError, err)
@ -272,7 +272,7 @@ func UploadSymbolPackage(ctx *context.Context) {
case packages_model.ErrPackageNotExist:
apiError(ctx, http.StatusNotFound, err)
case packages_model.ErrDuplicatePackageFile:
apiError(ctx, http.StatusBadRequest, err)
apiError(ctx, http.StatusConflict, err)
default:
apiError(ctx, http.StatusInternalServerError, err)
}
@ -297,7 +297,7 @@ func UploadSymbolPackage(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageFile:
apiError(ctx, http.StatusBadRequest, err)
apiError(ctx, http.StatusConflict, err)
default:
apiError(ctx, http.StatusInternalServerError, err)
}
@ -412,4 +412,6 @@ func DeletePackage(ctx *context.Context) {
}
apiError(ctx, http.StatusInternalServerError, err)
}
ctx.Status(http.StatusNoContent)
}