@@ -321,6 +321,25 @@ func TestOpsGenieWithUpdate(t *testing.T) {
321
321
` , body2 )
322
322
}
323
323
324
+ func TestOpsGenieApiKeyFile (t * testing.T ) {
325
+ u , err := url .Parse ("https://test-opsgenie-url" )
326
+ require .NoError (t , err )
327
+ tmpl := test .CreateTmpl (t )
328
+ ctx := context .Background ()
329
+ ctx = notify .WithGroupKey (ctx , "1" )
330
+ opsGenieConfigWithUpdate := config.OpsGenieConfig {
331
+ APIKeyFile : `./api_key_file` ,
332
+ APIURL : & config.URL {URL : u },
333
+ HTTPConfig : & commoncfg.HTTPClientConfig {},
334
+ }
335
+ notifierWithUpdate , err := New (& opsGenieConfigWithUpdate , tmpl , promslog .NewNopLogger ())
336
+
337
+ require .NoError (t , err )
338
+ requests , _ , err := notifierWithUpdate .createRequests (ctx )
339
+ require .NoError (t , err )
340
+ require .Equal (t , "GenieKey my_secret_api_key" , requests [0 ].Header .Get ("Authorization" ))
341
+ }
342
+
324
343
func readBody (t * testing.T , r * http.Request ) string {
325
344
t .Helper ()
326
345
body , err := io .ReadAll (r .Body )
0 commit comments