Skip to content

Commit

Permalink
Add unit test coverage
Browse files Browse the repository at this point in the history
Adds unit test coverage for the new functions. A possible nil pointer
dereference is fixed, which could occur if port matching is not
utilized.
  • Loading branch information
dhild committed Apr 16, 2024
1 parent b0ffeb3 commit 9db2860
Show file tree
Hide file tree
Showing 2 changed files with 468 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/virtualrouter/routes_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ func taintedSDKRouteRefs(routes []appmesh.Route, sdkVR *appmeshsdk.VirtualRouter

for _, name := range matchedNameSet.List() {
route := routeByName[name]
if route.TCPRoute != nil && route.TCPRoute.Match != nil && sdkListenerByPort[aws.Int64Value(route.TCPRoute.Match.Port)] != appmesh.PortProtocolTCP {
if route.TCPRoute != nil && route.TCPRoute.Match != nil && route.TCPRoute.Match.Port != nil && sdkListenerByPort[aws.Int64Value(route.TCPRoute.Match.Port)] != appmesh.PortProtocolTCP {
unmatchedSDKRouteRefNameSet.Insert(route.Name)
} else if route.GRPCRoute != nil && sdkListenerByPort[aws.Int64Value(route.GRPCRoute.Match.Port)] != appmesh.PortProtocolGRPC {
} else if route.GRPCRoute != nil && route.GRPCRoute.Match.Port != nil && sdkListenerByPort[aws.Int64Value(route.GRPCRoute.Match.Port)] != appmesh.PortProtocolGRPC {
unmatchedSDKRouteRefNameSet.Insert(route.Name)
} else if route.HTTP2Route != nil && sdkListenerByPort[aws.Int64Value(route.HTTP2Route.Match.Port)] != appmesh.PortProtocolHTTP2 {
} else if route.HTTP2Route != nil && route.HTTP2Route.Match.Port != nil && sdkListenerByPort[aws.Int64Value(route.HTTP2Route.Match.Port)] != appmesh.PortProtocolHTTP2 {
unmatchedSDKRouteRefNameSet.Insert(route.Name)
} else if route.HTTPRoute != nil && sdkListenerByPort[aws.Int64Value(route.HTTPRoute.Match.Port)] != appmesh.PortProtocolHTTP {
} else if route.HTTPRoute != nil && route.HTTPRoute.Match.Port != nil && sdkListenerByPort[aws.Int64Value(route.HTTPRoute.Match.Port)] != appmesh.PortProtocolHTTP {
unmatchedSDKRouteRefNameSet.Insert(route.Name)
}
}
Expand Down
Loading

0 comments on commit 9db2860

Please sign in to comment.