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 {
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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment