diff --git a/ekms/internal/akmsCkmsServer/akmsCkmsServer.go b/ekms/internal/akmsCkmsServer/akmsCkmsServer.go index 4dc129edf1b0c51fcb432892b7bad287a2c55174..89849402fb00e7437ad3be4e814a07701d7f4020 100644 --- a/ekms/internal/akmsCkmsServer/akmsCkmsServer.go +++ b/ekms/internal/akmsCkmsServer/akmsCkmsServer.go @@ -77,17 +77,13 @@ func ksaReqHandler(ekms *kms.EKMS) http.HandlerFunc { return } - go func() { - select { - case <-receiverChan: - err = ekms.GenerateAndSendKSAKey(kmsKeyRequest.ReceivingCKMSID, pathId, kmsKeyRequest.RequestID, kmsKeyRequest.KeyProperties.Number) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - logrus.Errorf("error generating and sending KSA key: %s", err) - return - } - } - }() + <-receiverChan + err = ekms.GenerateAndSendKSAKey(kmsKeyRequest.ReceivingCKMSID, pathId, kmsKeyRequest.RequestID, kmsKeyRequest.KeyProperties.Number) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + logrus.Errorf("error generating and sending KSA key: %s", err) + return + } logrus.Info("requested all keys") w.WriteHeader(http.StatusNoContent) diff --git a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go index 2f6f6dec26dd706c35134fab026159a1d43fc0c3..c179683a8577cfa54fc19820467162a52f4b18f1 100644 --- a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go +++ b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go @@ -97,16 +97,18 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo return } - resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData)) - if err != nil { - t.Errorf("Error making HTTP request: %s", err) - return - } - defer resp.Body.Close() //nolint:errcheck + go func() { + resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData)) + if err != nil { + t.Errorf("Error making HTTP request: %s", err) + return + } + defer resp.Body.Close() //nolint:errcheck - if resp.StatusCode != http.StatusNoContent { - t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode) - } + if resp.StatusCode != http.StatusNoContent { + t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode) + } + }() time.Sleep(time.Duration(2) * time.Second) @@ -205,7 +207,7 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo time.Sleep(time.Duration(2) * time.Second) // Get logfile of akms - resp, err = http.Get("http://" + logFileURL + "/debug/get_log_file") + resp, err := http.Get("http://" + logFileURL + "/debug/get_log_file") if err != nil { t.Errorf("Error making HTTP request: %s", err) return