This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new a0f6b1f3f9 Separate SSL success and warning alert messages (#7736)
a0f6b1f3f9 is described below

commit a0f6b1f3f94b375f7eb48e7ed63c877e66b4e255
Author: Eric Holguin <[email protected]>
AuthorDate: Wed Aug 23 13:03:34 2023 -0600

    Separate SSL success and warning alert messages (#7736)
    
    * Separated warning and success alert messages
    
    * removed redundant message
---
 .../traffic_ops_golang/deliveryservice/keys.go      | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/keys.go 
b/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
index ad4b8682f9..a0ac2741e7 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/keys.go
@@ -127,16 +127,27 @@ func AddSSLKeys(w http.ResponseWriter, r *http.Request) {
 
        api.CreateChangeLogRawTx(api.ApiChange, "DS: "+*req.DeliveryService+", 
ID: "+strconv.Itoa(dsID)+", ACTION: Added/Updated SSL keys", inf.User, 
inf.Tx.Tx)
 
+       var alerts tc.Alerts
+
        if isUnknownAuth {
-               api.WriteRespAlert(w, r, tc.WarnLevel, "WARNING: SSL keys were 
successfully added for '"+*req.DeliveryService+"', but the input certificate 
may be invalid (certificate is signed by an unknown authority)")
-               return
+               alerts.AddAlert(tc.Alert{
+                       Text:  "The input certificate may be invalid for '" + 
*req.DeliveryService + "' (certificate is signed by an unknown authority)",
+                       Level: tc.WarnLevel.String(),
+               })
        }
        if isVerifiedChainNotEqual {
-               api.WriteRespAlert(w, r, tc.WarnLevel, "WARNING: SSL keys were 
successfully added for '"+*req.DeliveryService+"', but the input certificate 
may be invalid (certificate verification produced a different chain)")
-               return
+               alerts.AddAlert(tc.Alert{
+                       Text:  "The input certificate may be invalid for '" + 
*req.DeliveryService + "' (certificate verification produced a different 
chain)",
+                       Level: tc.WarnLevel.String(),
+               })
        }
 
-       api.WriteRespAlert(w, r, tc.SuccessLevel, "Successfully added ssl keys 
for "+*req.DeliveryService)
+       alerts.AddAlert(tc.Alert{
+               Text:  "Added ssl keys for " + *req.DeliveryService,
+               Level: tc.SuccessLevel.String(),
+       })
+
+       api.WriteAlerts(w, r, http.StatusOK, alerts)
 }
 
 // GetSSlKeyExpirationInformation gets expiration information for all SSL 
certificates.

Reply via email to