@@ -427,17 +427,20 @@ func TestGetNotificationParams(t *testing.T) {
427427 providerSuspended bool
428428 providerServiceAccount string
429429 secretNamespace string
430+ secretData map [string ][]byte
430431 noCrossNSRefs bool
431432 enableObjLevelWI bool
432433 eventMetadata map [string ]string
433434 wantErr bool
434435 wantDroppedCommitStatus bool
436+ wantParams bool
435437 }{
436438 {
437439 name : "event src and alert in diff NS" ,
438440 alertNamespace : "bar-ns" ,
439441 providerNamespace : "bar-ns" ,
440442 secretNamespace : "bar-ns" ,
443+ wantParams : true ,
441444 },
442445 {
443446 name : "event src and alert in diff NS with no cross NS refs" ,
@@ -464,6 +467,7 @@ func TestGetNotificationParams(t *testing.T) {
464467 {
465468 name : "alert with summary, no event metadata" ,
466469 alertSummary : "some summary text" ,
470+ wantParams : true ,
467471 },
468472 {
469473 name : "alert with summary, with event metadata" ,
@@ -472,13 +476,15 @@ func TestGetNotificationParams(t *testing.T) {
472476 "foo" : "bar" ,
473477 "summary" : "baz" ,
474478 },
479+ wantParams : true ,
475480 },
476481 {
477482 name : "alert with event metadata" ,
478483 alertEventMetadata : map [string ]string {
479484 "aaa" : "bbb" ,
480485 "ccc" : "ddd" ,
481486 },
487+ wantParams : true ,
482488 },
483489 {
484490 name : "object level workload identity feature gate disabled" ,
@@ -490,7 +496,7 @@ func TestGetNotificationParams(t *testing.T) {
490496 name : "object level workload identity feature gate enabled" ,
491497 providerServiceAccount : "foo" ,
492498 enableObjLevelWI : true ,
493- wantErr : false ,
499+ wantParams : true ,
494500 },
495501 {
496502 name : "commit status provider drops event without commit key" ,
@@ -503,7 +509,24 @@ func TestGetNotificationParams(t *testing.T) {
503509 eventMetadata : map [string ]string {
504510 "kustomize.toolkit.fluxcd.io/" + eventv1 .MetaCommitStatusKey : eventv1 .MetaCommitStatusUpdateValue ,
505511 },
506- wantErr : true , // proceeds past the guard and fails on notifier creation
512+ wantErr : true ,
513+ },
514+ {
515+ name : "generic provider does not drop commit status update event" ,
516+ providerType : apiv1beta3 .GenericProvider ,
517+ eventMetadata : map [string ]string {
518+ "kustomize.toolkit.fluxcd.io/" + eventv1 .MetaCommitStatusKey : eventv1 .MetaCommitStatusUpdateValue ,
519+ },
520+ wantParams : true ,
521+ },
522+ {
523+ name : "generic-hmac provider does not drop commit status update event" ,
524+ providerType : apiv1beta3 .GenericHMACProvider ,
525+ secretData : map [string ][]byte {"token" : []byte ("test-hmac-key" )},
526+ eventMetadata : map [string ]string {
527+ "kustomize.toolkit.fluxcd.io/" + eventv1 .MetaCommitStatusKey : eventv1 .MetaCommitStatusUpdateValue ,
528+ },
529+ wantParams : true ,
507530 },
508531 }
509532
@@ -538,6 +561,9 @@ func TestGetNotificationParams(t *testing.T) {
538561 if tt .secretNamespace != "" {
539562 secret .Namespace = tt .secretNamespace
540563 }
564+ if tt .secretData != nil {
565+ secret .Data = tt .secretData
566+ }
541567 if tt .eventMetadata != nil {
542568 event .Metadata = tt .eventMetadata
543569 }
@@ -561,8 +587,9 @@ func TestGetNotificationParams(t *testing.T) {
561587 }
562588
563589 params , dropped , err := eventServer .getNotificationParams (context .TODO (), event , alert )
564- g .Expect (err != nil ).To (Equal (tt .wantErr ))
590+ g .Expect (err != nil ).To (Equal (tt .wantErr ), "unexpected error: %v" , err )
565591 g .Expect (dropped .commitStatus ).To (Equal (tt .wantDroppedCommitStatus ))
592+ g .Expect (params != nil ).To (Equal (tt .wantParams ), "unexpected params: %v" , params )
566593 if tt .alertSummary != "" {
567594 g .Expect (params .event .Metadata ["summary" ]).To (Equal (tt .alertSummary ))
568595 }
0 commit comments