@@ -125,8 +125,11 @@ func TestNewAlertmanager(t *testing.T) {
125125}
126126
127127func TestApplyConfig (t * testing.T ) {
128+ const tenantID = "test"
128129 // errorHandler returns an error response for the readiness check and state sync.
129130 errorHandler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
131+ require .Equal (t , tenantID , r .Header .Get (client .MimirTenantHeader ))
132+ require .Equal (t , "true" , r .Header .Get (client .RemoteAlertmanagerHeader ))
130133 w .Header ().Add ("content-type" , "application/json" )
131134 w .WriteHeader (http .StatusInternalServerError )
132135 require .NoError (t , json .NewEncoder (w ).Encode (map [string ]string {"status" : "error" }))
@@ -135,6 +138,8 @@ func TestApplyConfig(t *testing.T) {
135138 var configSent client.UserGrafanaConfig
136139 var lastConfigSync , lastStateSync time.Time
137140 okHandler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
141+ require .Equal (t , tenantID , r .Header .Get (client .MimirTenantHeader ))
142+ require .Equal (t , "true" , r .Header .Get (client .RemoteAlertmanagerHeader ))
138143 if r .Method == http .MethodPost {
139144 if strings .Contains (r .URL .Path , "/config" ) {
140145 require .NoError (t , json .NewDecoder (r .Body ).Decode (& configSent ))
@@ -166,7 +171,7 @@ func TestApplyConfig(t *testing.T) {
166171 server := httptest .NewServer (errorHandler )
167172 cfg := AlertmanagerConfig {
168173 OrgID : 1 ,
169- TenantID : "test" ,
174+ TenantID : tenantID ,
170175 URL : server .URL ,
171176 DefaultConfig : defaultGrafanaConfig ,
172177 PromoteConfig : true ,
@@ -228,6 +233,7 @@ func TestApplyConfig(t *testing.T) {
228233}
229234
230235func TestCompareAndSendConfiguration (t * testing.T ) {
236+ const tenantID = "test"
231237 cfgWithSecret , err := notifier .Load ([]byte (testGrafanaConfigWithSecret ))
232238 require .NoError (t , err )
233239 testValue := []byte ("test" )
@@ -240,6 +246,8 @@ func TestCompareAndSendConfiguration(t *testing.T) {
240246
241247 var got string
242248 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
249+ require .Equal (t , tenantID , r .Header .Get (client .MimirTenantHeader ))
250+ require .Equal (t , "true" , r .Header .Get (client .RemoteAlertmanagerHeader ))
243251 w .Header ().Add ("content-type" , "application/json" )
244252
245253 b , err := io .ReadAll (r .Body )
@@ -255,7 +263,7 @@ func TestCompareAndSendConfiguration(t *testing.T) {
255263 m := metrics .NewRemoteAlertmanagerMetrics (prometheus .NewRegistry ())
256264 cfg := AlertmanagerConfig {
257265 OrgID : 1 ,
258- TenantID : "test" ,
266+ TenantID : tenantID ,
259267 URL : server .URL ,
260268 DefaultConfig : defaultGrafanaConfig ,
261269 }
@@ -336,6 +344,7 @@ func TestCompareAndSendConfiguration(t *testing.T) {
336344}
337345
338346func Test_TestReceiversDecryptsSecureSettings (t * testing.T ) {
347+ const tenantID = "test"
339348 const testKey = "test-key"
340349 const testValue = "test-value"
341350 decryptFn := func (_ context.Context , payload []byte ) ([]byte , error ) {
@@ -347,6 +356,8 @@ func Test_TestReceiversDecryptsSecureSettings(t *testing.T) {
347356
348357 var got apimodels.TestReceiversConfigBodyParams
349358 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
359+ require .Equal (t , tenantID , r .Header .Get (client .MimirTenantHeader ))
360+ require .Equal (t , "true" , r .Header .Get (client .RemoteAlertmanagerHeader ))
350361 w .Header ().Add ("Content-Type" , "application/json" )
351362 require .NoError (t , json .NewDecoder (r .Body ).Decode (& got ))
352363 require .NoError (t , r .Body .Close ())
@@ -358,7 +369,7 @@ func Test_TestReceiversDecryptsSecureSettings(t *testing.T) {
358369 m := metrics .NewRemoteAlertmanagerMetrics (prometheus .NewRegistry ())
359370 cfg := AlertmanagerConfig {
360371 OrgID : 1 ,
361- TenantID : "test" ,
372+ TenantID : tenantID ,
362373 URL : server .URL ,
363374 DefaultConfig : defaultGrafanaConfig ,
364375 }
0 commit comments