istio-config-validator icon indicating copy to clipboard operation
istio-config-validator copied to clipboard

Rewrite test issue

Open ianrenUipath opened this issue 4 years ago • 0 comments

Hi, For a VS rewrite rule, VS would rewrite the path (or the prefix) portion of the URI with the uri value provided.

If the original URI was matched based on prefix, the value provided in this field will replace the corresponding matched prefix. (https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRewrite)

But, in the validator, it does not support compare the test request uri after rewriting with the uri we provided in the test case.

For example, we have a VS rule:

name: example_rule
match:
  uri:
    prefix: /examplePrefix
rewrite:
  uri: /
route:
  destination:
    host: example_destination_host
    port:
      number: 80

and a test:

description:  example_rule_test
wantMatch: true
request:
  authority: ["example"]
  method: ["GET"]
  uri: ["/examplePrefix", "/examplePrefix/somePrefix"]
route:
  destination:
    host: example_destination_host
    port:
      number: 80
rewrite:
  uri: /

it should work as the test case has same rewrite section as "example_rule".

Is there any way we can compare the test request uri after rewriting with the uri we provided in the test case?

like:

description:  example_rule_test
wantMatch: true
request:
  authority: ["example"]
  method: ["GET"]
  uri: ["/examplePrefix/somePrefix"]
route:
  destination:
    host: example_destination_host
    port:
      number: 80
uriAfterRewrite:
  uri: /somePrefix

ianrenUipath avatar Oct 26 '21 18:10 ianrenUipath