mirror of
https://github.com/grafana/grafana.git
synced 2025-01-19 13:03:32 -06:00
query: handle the x-rule-uid header (#95223)
This commit is contained in:
parent
6f7528f896
commit
1dbbbd9ca7
@ -22,6 +22,7 @@ type UseAlertHeadersMiddleware struct {
|
||||
|
||||
var alertHeaders = []string{
|
||||
"X-Rule-Name",
|
||||
"X-Rule-Uid",
|
||||
"X-Rule-Folder",
|
||||
"X-Rule-Source",
|
||||
"X-Rule-Type",
|
||||
|
@ -39,6 +39,7 @@ func TestUserAlertingHeadersMiddleware(t *testing.T) {
|
||||
|
||||
// the normal http headers
|
||||
require.Equal(t, "", outReq.GetHTTPHeader("X-Rule-Name"))
|
||||
require.Equal(t, "", outReq.GetHTTPHeader("X-Rule-Uid"))
|
||||
require.Equal(t, "", outReq.GetHTTPHeader("X-Rule-Folder"))
|
||||
require.Equal(t, "", outReq.GetHTTPHeader("X-Rule-Source"))
|
||||
require.Equal(t, "", outReq.GetHTTPHeader("X-Rule-Type"))
|
||||
@ -50,6 +51,7 @@ func TestUserAlertingHeadersMiddleware(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("Fromalert", "true")
|
||||
req.Header.Set("X-Rule-Name", "n1")
|
||||
req.Header.Set("X-Rule-Uid", "u1")
|
||||
req.Header.Set("X-Rule-Folder", "f1")
|
||||
req.Header.Set("X-Rule-Source", "s1")
|
||||
req.Header.Set("X-Rule-Type", "t1")
|
||||
@ -62,6 +64,7 @@ func TestUserAlertingHeadersMiddleware(t *testing.T) {
|
||||
|
||||
// normal http headers
|
||||
require.Equal(t, "n1", outReq.GetHTTPHeader("X-Rule-Name"))
|
||||
require.Equal(t, "u1", outReq.GetHTTPHeader("X-Rule-Uid"))
|
||||
require.Equal(t, "f1", outReq.GetHTTPHeader("X-Rule-Folder"))
|
||||
require.Equal(t, "s1", outReq.GetHTTPHeader("X-Rule-Source"))
|
||||
require.Equal(t, "t1", outReq.GetHTTPHeader("X-Rule-Type"))
|
||||
|
@ -97,6 +97,7 @@ func TestIntegrationLoki(t *testing.T) {
|
||||
req.Header.Set("X-Unspported-Header", "uh")
|
||||
req.Header.Set("Fromalert", "true")
|
||||
req.Header.Set("X-Rule-Name", "n1")
|
||||
req.Header.Set("X-Rule-Uid", "u1")
|
||||
req.Header.Set("X-Rule-Folder", "f1")
|
||||
req.Header.Set("X-Rule-Source", "s1")
|
||||
req.Header.Set("X-Rule-Type", "t1")
|
||||
@ -120,6 +121,7 @@ func TestIntegrationLoki(t *testing.T) {
|
||||
require.Equal(t, "", outgoingRequest.Header.Get("X-Unspported-Header"))
|
||||
require.Equal(t, "true", outgoingRequest.Header.Get("Fromalert"))
|
||||
require.Equal(t, "n1", outgoingRequest.Header.Get("X-Rule-Name"))
|
||||
require.Equal(t, "u1", outgoingRequest.Header.Get("X-Rule-Uid"))
|
||||
require.Equal(t, "f1", outgoingRequest.Header.Get("X-Rule-Folder"))
|
||||
require.Equal(t, "s1", outgoingRequest.Header.Get("X-Rule-Source"))
|
||||
require.Equal(t, "t1", outgoingRequest.Header.Get("X-Rule-Type"))
|
||||
|
Loading…
Reference in New Issue
Block a user