Skip to content

Commit

Permalink
internal-endpoint-testing: handle x-choreo-test-session-id header cor…
Browse files Browse the repository at this point in the history
…s config

Signed-off-by: Lahiru De Silva <[email protected]>
  • Loading branch information
NomadXD committed Jan 23, 2024
1 parent c48f892 commit 930e647
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions adapter/internal/oasparser/envoyconf/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ const (
AccessLogTypeText = "text"
AccessLogTypeJSON = "json"
)

// Test session header name used for internal endpoint testing
const (
choreoTestSessionHeaderName = "x-choreo-test-session-id"
)
2 changes: 1 addition & 1 deletion adapter/internal/oasparser/envoyconf/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func CreateRoutesConfigForRds(vHosts []*routev3.VirtualHost) *routev3.RouteConfi
routeConfiguration := routev3.RouteConfiguration{
Name: rdsConfigName,
VirtualHosts: vHosts,
RequestHeadersToRemove: []string{clusterHeaderName, gatewayURLHeaderName},
RequestHeadersToRemove: []string{clusterHeaderName, gatewayURLHeaderName, choreoTestSessionHeaderName},
}
return &routeConfiguration
}
Expand Down
3 changes: 3 additions & 0 deletions adapter/internal/oasparser/envoyconf/routes_with_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,9 @@ func getCorsPolicy(corsConfig *model.CorsConfig) *cors_filter_v3.CorsPolicy {
return nil
}

// Append `x-choreo-test-session-id` used for internal endpoint testing to AccessControlAllowHeaders.
corsConfig.AccessControlAllowHeaders = append(corsConfig.AccessControlAllowHeaders, choreoTestSessionHeaderName)

stringMatcherArray := []*envoy_type_matcherv3.StringMatcher{}
for _, origin := range corsConfig.AccessControlAllowOrigins {
regexMatcher := &envoy_type_matcherv3.StringMatcher{
Expand Down

0 comments on commit 930e647

Please sign in to comment.