From cda54ef9262e4ccc408aa5758cb091e6f20c5958 Mon Sep 17 00:00:00 2001 From: sanne Date: Thu, 7 Oct 2021 00:51:13 +0200 Subject: [PATCH] cloudapi/v1: Return status created in compose handler --- internal/cloudapi/v1/v1.go | 2 +- test/cases/api.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/cloudapi/v1/v1.go b/internal/cloudapi/v1/v1.go index 5c3c02692..1786e1481 100644 --- a/internal/cloudapi/v1/v1.go +++ b/internal/cloudapi/v1/v1.go @@ -384,7 +384,7 @@ func (h *apiHandlers) Compose(ctx echo.Context) error { var response ComposeResult response.Id = id.String() - return ctx.JSON(http.StatusOK, response) + return ctx.JSON(http.StatusCreated, response) } // ComposeStatus handles a /compose/{id} GET request diff --git a/test/cases/api.sh b/test/cases/api.sh index 1297463b9..0942043be 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -639,7 +639,8 @@ function collectMetrics(){ } function sendCompose() { - OUTPUT=$(curl \ + OUTPUT=$(mktemp) + HTTPSTATUS=$(curl \ --silent \ --show-error \ --cacert /etc/osbuild-composer/ca-crt.pem \ @@ -648,9 +649,12 @@ function sendCompose() { --header 'Content-Type: application/json' \ --request POST \ --data @"$REQUEST_FILE" \ + --write-out '%{http_code}' \ + --output "$OUTPUT" \ https://localhost/api/composer/v1/compose) - COMPOSE_ID=$(echo "$OUTPUT" | jq -r '.id') + test "$HTTPSTATUS" = "201" + COMPOSE_ID=$(jq -r '.id' "$OUTPUT") } function waitForState() {