Skip to content

Commit 5b22c76

Browse files
test(gateway): align dynamic endpoint metadata expectation
1 parent 358cfa3 commit 5b22c76

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

gateway/gateway-runtime/policy-engine/internal/kernel/translator_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,8 @@ func TestBuildDynamicMetadata_WithPath(t *testing.T) {
378378

379379
// TestTranslateRequestHeaderActions_DynamicEndpointDoesNotBakeBasePath guards the
380380
// per-op-upstream-ref behavior. When a dynamic-endpoint policy redirects a request to an
381-
// upstreamDefinition that has a base path, the kernel must NOT bake that base into a path
382-
// mutation: a baked path surfaces as metadata["path"], which the Lua filter reads before
383-
// request_transformation.target_path and would prepend the base twice
384-
// (e.g. /op-policy-svc/op-policy-svc/override). Instead the kernel passes the original
385-
// request path plus target_upstream_base_path, so the Lua prepends the base exactly once.
381+
// upstreamDefinition that has a base path, the kernel must pass the original request path
382+
// plus target_upstream_base_path so Lua prepends the base exactly once.
386383
func TestTranslateRequestHeaderActions_DynamicEndpointDoesNotBakeBasePath(t *testing.T) {
387384
kernel := NewKernel()
388385
chainExecutor := executor.NewChainExecutor(nil, nil, nil)
@@ -422,10 +419,10 @@ func TestTranslateRequestHeaderActions_DynamicEndpointDoesNotBakeBasePath(t *tes
422419

423420
// The target upstream's base path is advertised so the Lua prepends it exactly once.
424421
assert.Equal(t, "/op-policy-svc", extProc.Fields["target_upstream_base_path"].GetStringValue())
425-
// The ORIGINAL request path is handed to the Lua, not a pre-computed base-prefixed path.
426-
assert.Equal(t, "/per-op/v1.0/override", extProc.Fields["request_transformation.target_path"].GetStringValue())
427-
// Critically: no baked "path" mutation. If present, the Lua reads it first and double-prepends the base.
428-
assert.NotContains(t, extProc.Fields, "path")
422+
// The ORIGINAL request path is handed to Lua via the single path metadata channel,
423+
// not a pre-computed base-prefixed path.
424+
assert.Equal(t, "/per-op/v1.0/override", extProc.Fields["path"].GetStringValue())
425+
assert.NotContains(t, extProc.Fields, "request_transformation.target_path")
429426
}
430427

431428
// =============================================================================

0 commit comments

Comments
 (0)