@@ -433,6 +433,58 @@ func TestStaticFileServerFactory_SPAConfigKey(t *testing.T) {
433433 }
434434}
435435
436+ func TestPipelineTriggerConfigWrappers (t * testing.T ) {
437+ p := New ()
438+ wrappers := p .PipelineTriggerConfigWrappers ()
439+ wrapper , ok := wrappers ["http" ]
440+ if ! ok {
441+ t .Fatal ("missing pipeline trigger config wrapper for http" )
442+ }
443+
444+ t .Run ("forwards path, method, and middlewares" , func (t * testing.T ) {
445+ cfg := map [string ]any {
446+ "path" : "/items" ,
447+ "method" : "GET" ,
448+ "middlewares" : []any {"auth-bearer" , "rate-limit" },
449+ }
450+ result := wrapper ("list-items" , cfg )
451+ routes , ok := result ["routes" ].([]any )
452+ if ! ok || len (routes ) != 1 {
453+ t .Fatalf ("expected 1 route, got %v" , result ["routes" ])
454+ }
455+ route := routes [0 ].(map [string ]any )
456+ if route ["path" ] != "/items" {
457+ t .Errorf ("path = %v, want /items" , route ["path" ])
458+ }
459+ if route ["method" ] != "GET" {
460+ t .Errorf ("method = %v, want GET" , route ["method" ])
461+ }
462+ mw , ok := route ["middlewares" ].([]any )
463+ if ! ok || len (mw ) != 2 {
464+ t .Fatalf ("middlewares = %v, want [auth-bearer rate-limit]" , route ["middlewares" ])
465+ }
466+ if mw [0 ] != "auth-bearer" || mw [1 ] != "rate-limit" {
467+ t .Errorf ("middlewares = %v, want [auth-bearer rate-limit]" , mw )
468+ }
469+ if route ["workflow" ] != "pipeline:list-items" {
470+ t .Errorf ("workflow = %v, want pipeline:list-items" , route ["workflow" ])
471+ }
472+ })
473+
474+ t .Run ("omits middlewares when not set" , func (t * testing.T ) {
475+ cfg := map [string ]any {
476+ "path" : "/items" ,
477+ "method" : "GET" ,
478+ }
479+ result := wrapper ("list-items" , cfg )
480+ routes := result ["routes" ].([]any )
481+ route := routes [0 ].(map [string ]any )
482+ if _ , exists := route ["middlewares" ]; exists {
483+ t .Error ("middlewares key should not be present when not configured" )
484+ }
485+ })
486+ }
487+
436488func TestPluginLoaderIntegration (t * testing.T ) {
437489 p := New ()
438490
0 commit comments