Skip to content
Snippets Groups Projects
Commit afcd9544 authored by Malte Bauch's avatar Malte Bauch Committed by Fabian Seidl
Browse files

Remove go routine within akms-ckms server

See merge request !89
parent c28368af
Branches
No related tags found
1 merge request!89Remove go routine within akms-ckms server
Pipeline #188808 passed
...@@ -77,17 +77,13 @@ func ksaReqHandler(ekms *kms.EKMS) http.HandlerFunc { ...@@ -77,17 +77,13 @@ func ksaReqHandler(ekms *kms.EKMS) http.HandlerFunc {
return return
} }
go func() { <-receiverChan
select { err = ekms.GenerateAndSendKSAKey(kmsKeyRequest.ReceivingCKMSID, pathId, kmsKeyRequest.RequestID, kmsKeyRequest.KeyProperties.Number)
case <-receiverChan: if err != nil {
err = ekms.GenerateAndSendKSAKey(kmsKeyRequest.ReceivingCKMSID, pathId, kmsKeyRequest.RequestID, kmsKeyRequest.KeyProperties.Number) http.Error(w, err.Error(), http.StatusInternalServerError)
if err != nil { logrus.Errorf("error generating and sending KSA key: %s", err)
http.Error(w, err.Error(), http.StatusInternalServerError) return
logrus.Errorf("error generating and sending KSA key: %s", err) }
return
}
}
}()
logrus.Info("requested all keys") logrus.Info("requested all keys")
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
......
...@@ -97,16 +97,18 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo ...@@ -97,16 +97,18 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo
return return
} }
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData)) go func() {
if err != nil { resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
t.Errorf("Error making HTTP request: %s", err) if err != nil {
return t.Errorf("Error making HTTP request: %s", err)
} return
defer resp.Body.Close() //nolint:errcheck }
defer resp.Body.Close() //nolint:errcheck
if resp.StatusCode != http.StatusNoContent { if resp.StatusCode != http.StatusNoContent {
t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode) t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode)
} }
}()
time.Sleep(time.Duration(2) * time.Second) time.Sleep(time.Duration(2) * time.Second)
...@@ -205,7 +207,7 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo ...@@ -205,7 +207,7 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo
time.Sleep(time.Duration(2) * time.Second) time.Sleep(time.Duration(2) * time.Second)
// Get logfile of akms // 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 { if err != nil {
t.Errorf("Error making HTTP request: %s", err) t.Errorf("Error making HTTP request: %s", err)
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment