1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

api: use response code 200 (#604)

This commit is contained in:
Anthony Lapenna 2025-04-03 11:12:24 +13:00 committed by GitHub
parent a5d857d5e7
commit 3800249921
2 changed files with 3 additions and 3 deletions

View file

@ -50,7 +50,7 @@ type accessTokenResponse struct {
// @produce json // @produce json
// @param id path int true "User identifier" // @param id path int true "User identifier"
// @param body body userAccessTokenCreatePayload true "details" // @param body body userAccessTokenCreatePayload true "details"
// @success 200 {object} accessTokenResponse "Created" // @success 200 {object} accessTokenResponse "Success"
// @failure 400 "Invalid request" // @failure 400 "Invalid request"
// @failure 401 "Unauthorized" // @failure 401 "Unauthorized"
// @failure 403 "Permission denied" // @failure 403 "Permission denied"
@ -115,7 +115,7 @@ func (handler *Handler) userCreateAccessToken(w http.ResponseWriter, r *http.Req
return httperror.InternalServerError("Internal Server Error", err) return httperror.InternalServerError("Internal Server Error", err)
} }
return response.JSONWithStatus(w, accessTokenResponse{rawAPIKey, *apiKey}, http.StatusCreated) return response.JSONWithStatus(w, accessTokenResponse{rawAPIKey, *apiKey}, http.StatusOK)
} }
func (handler *Handler) usesInternalAuthentication(userid portainer.UserID) (bool, error) { func (handler *Handler) usesInternalAuthentication(userid portainer.UserID) (bool, error) {

View file

@ -60,7 +60,7 @@ func Test_userCreateAccessToken(t *testing.T) {
rr := httptest.NewRecorder() rr := httptest.NewRecorder()
h.ServeHTTP(rr, req) h.ServeHTTP(rr, req)
is.Equal(http.StatusCreated, rr.Code) is.Equal(http.StatusOK, rr.Code)
body, err := io.ReadAll(rr.Body) body, err := io.ReadAll(rr.Body)
is.NoError(err, "ReadAll should not return error") is.NoError(err, "ReadAll should not return error")