From 109e7e2122bc11ef404d7eea1a9ceb576cc54bae Mon Sep 17 00:00:00 2001 From: MalinAhlberg Date: Mon, 2 Dec 2024 14:20:40 +0100 Subject: [PATCH] Apply suggestions from code review --- .github/integration/tests/sda/60_api_admin_test.sh | 10 ++++++++++ sda/cmd/api/api.go | 4 ++-- sda/cmd/api/api.md | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/integration/tests/sda/60_api_admin_test.sh b/.github/integration/tests/sda/60_api_admin_test.sh index 30af0219c..577595320 100644 --- a/.github/integration/tests/sda/60_api_admin_test.sh +++ b/.github/integration/tests/sda/60_api_admin_test.sh @@ -34,6 +34,11 @@ done # get the fileId of the new file fileid="$(curl -k -L -H "Authorization: Bearer $token" -H "Content-Type: application/json" "http://api:8080/users/test@dummy.org/files" | jq -r '.[] | select(.inboxPath == "test_dummy.org/NC12878.bam.c4gh") | .fileID')" +output=$(s3cmd -c s3cfg ls s3://test_dummy.org/NC12878.bam.c4gh 2>/dev/null) +if [ -n "$output" ] ; then + echo "Uploaded file not in inbox" + exit 1 +fi # delete it resp="$(curl -s -k -L -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X DELETE "http://api:8080/file/test@dummy.org/$fileid")" if [ "$resp" != "200" ]; then @@ -47,6 +52,11 @@ if [ "$last_event" != "disabled" ]; then echo "The file $fileid does not have the expected las event 'disabled', but $last_event." fi +output=$(s3cmd -c s3cfg ls s3://test_dummy.org/NC12878.bam.c4gh 2>/dev/null) +if [ -z "$output" ] ; then + echo "Deleted file is still in inbox" + exit 1 +fi # Try to delete an unknown file resp="$(curl -s -k -L -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X DELETE "http://api:8080/file/test@dummy.org/badfileid")" diff --git a/sda/cmd/api/api.go b/sda/cmd/api/api.go index 87c3cce4f..023cde71e 100644 --- a/sda/cmd/api/api.go +++ b/sda/cmd/api/api.go @@ -300,11 +300,11 @@ func deleteFile(c *gin.Context) { } submissionUser := c.Param("username") - log.Warn("submission user:", submissionUser) + log.Debug("submission user:", submissionUser) fileID := c.Param("file") fileID = strings.TrimPrefix(fileID, "/") - log.Warn("submission file:", fileID) + log.Debug("submission file:", fileID) if fileID == "" { c.AbortWithStatusJSON(http.StatusBadRequest, "file ID is required") } diff --git a/sda/cmd/api/api.md b/sda/cmd/api/api.md index 61d2417c6..d8f9ace15 100644 --- a/sda/cmd/api/api.md +++ b/sda/cmd/api/api.md @@ -77,7 +77,7 @@ Admin endpoints are only available to a set of whitelisted users specified in th - `/file/:username/*fileid` - accepts `DELETE` requests - marks the file as `disabled` in the database, and deletes it from the inbox. - - The file is identfied by its id, returned by `users/:username/:files` + - The file is identified by its id, returned by `users/:username/:files` - Response codes - `200` Query execute ok.