From d11cad209a7697091fe18bc5da2167e5710afd42 Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Fri, 19 Apr 2024 12:14:16 -0500 Subject: [PATCH] test improvements --- pkg/envoy/listener_test.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/pkg/envoy/listener_test.go b/pkg/envoy/listener_test.go index 4860540..bb003fc 100644 --- a/pkg/envoy/listener_test.go +++ b/pkg/envoy/listener_test.go @@ -253,7 +253,7 @@ func TestUpdateListener(t *testing.T) { } params6 := ListenerParams{ Auth: Auth{ - JwtProvider: "testJwt2", + JwtProvider: "testJwt2a", Issuer: "http://issuer3.example.com", Forward: true, RemoteJwks: "https://remotejwks3.example.com", @@ -864,20 +864,24 @@ func validateJWTProvider(listeners []cacheTypes.Resource, auth Auth) error { return err } err = validateJWTProviderWithJWTConfig(jwtConfig, auth, cachedListener.Name) + if err != nil { + return err + } } else if cachedListener.Name == "l_tls" { - for _, filterChain := range cachedListener.FilterChains { - if len(filterChain.Filters) == 0 { - return fmt.Errorf("No filters found in listener %s", cachedListener.Name) - } - manager, err := getManager((filterChain.Filters[getFilterIndexByName(filterChain.Filters, Envoy_HTTP_Filter)].ConfigType).(*api.Filter_TypedConfig)) - if err != nil { - return fmt.Errorf("Could not extract manager from listener %s", cachedListener.Name) - } - jwtConfig, err := getListenerHTTPFilterJwtAuth(manager.HttpFilters) - if err != nil { - return err - } - err = validateJWTProviderWithJWTConfig(jwtConfig, auth, cachedListener.Name) + if len(cachedListener.FilterChains) == 0 { + return fmt.Errorf("No filters found in listener %s", cachedListener.Name) + } + manager, err := getManager((cachedListener.FilterChains[0].Filters[getFilterIndexByName(cachedListener.FilterChains[0].Filters, Envoy_HTTP_Filter)].ConfigType).(*api.Filter_TypedConfig)) + if err != nil { + return fmt.Errorf("Could not extract manager from listener %s", cachedListener.Name) + } + jwtConfig, err := getListenerHTTPFilterJwtAuth(manager.HttpFilters) + if err != nil { + return err + } + err = validateJWTProviderWithJWTConfig(jwtConfig, auth, cachedListener.Name) + if err != nil { + return err } } else { return fmt.Errorf("Unknown listener %s", cachedListener.Name)