Skip to content

conformance test: CORS - #4494

Merged
k8s-ci-robot merged 26 commits into
kubernetes-sigs:mainfrom
rikatz:cors-test
Feb 11, 2026
Merged

k8s-ci-robot merged 26 commits into
kubernetes-sigs:mainfrom
rikatz:cors-test

Conversation

@rikatz

@rikatz rikatz commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

What type of PR is this?
/area conformance-test

What this PR does / why we need it:
This PR adds conformance tests for HTTPCORSFilter.

This PR is a fork from #3739 to make CORS promotion possible

Which issue(s) this PR fixes:

Related to #3649

Does this PR introduce a user-facing change?:

Implement conformance test for CORS

zhaohuabing and others added 23 commits August 28, 2025 12:08
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. area/conformance-test Issues or PRs related to Conformance tests. labels Feb 5, 2026
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 5, 2026
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2026
@rikatz

rikatz commented Feb 6, 2026

Copy link
Copy Markdown
Member Author

do not unhold :D

@DamianSawicki is fixing the GEP and we will be fixing this conformance test. I am aware that this may break current passing implementations (some of those I fixed yesterday, and will need another fix) but we want the feature to be as close as possible of the specs!

DamianSawicki added a commit to DamianSawicki/gateway-api that referenced this pull request Feb 6, 2026
As per
kubernetes-sigs#4494 (comment)
Mozilla has an example where in response to an uncredentialed request,
the server responds with `Access-Control-Allow-Origin: *`.

However, responding with the value of the Origin from the request is
also valid (and the only allowed behavior for credentialed requests),
and it is the behavior of some implementations as per
https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401
so let's relax the requirement in the GEP to allow it.
@robscott

robscott commented Feb 6, 2026

Copy link
Copy Markdown
Member

do not unhold :D

@DamianSawicki is fixing the GEP and we will be fixing this conformance test. I am aware that this may break current passing implementations (some of those I fixed yesterday, and will need another fix) but we want the feature to be as close as possible of the specs!

Thanks @rikatz and @DamianSawicki!

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2026
k8s-ci-robot pushed a commit that referenced this pull request Feb 6, 2026
* Remove implementation-specific methods/headers

Previously, the GEP mentioned allowing "implementatio-specific default
methods and headers". It's not obvious what that means, but my
understanding is that this would allow implementations to arbitrarily
add certain values (not specified by the user) to the headers
Access-Control-Allow-Methods and Access-Control-Request-Headers`.
It does not seem to be needed. We can revisit this aspect
if it turns out otherwise.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Unify gep-1767 and httproute_types.go

It seems that not all changes in GEP 1767 were correctly reflected in
apis/v1/httproute_types.go. This is now fixed.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Allow specific Allow-Origin despite wildcard

As per
#4494 (comment)
Mozilla has an example where in response to an uncredentialed request,
the server responds with `Access-Control-Allow-Origin: *`.

However, responding with the value of the Origin from the request is
also valid (and the only allowed behavior for credentialed requests),
and it is the behavior of some implementations as per
https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401
so let's relax the requirement in the GEP to allow it.

* Allow specific Allow-Methods despite wildcard

As per
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#syntax
wildcard is a valid value for the Access-Control-Allow-Methods header.

However, as per
 * envoyproxy/envoy#8218
 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#browser_compatibility
the wildcard was not universally supported by browsers in 2019,
and hence many implementations don't use the wildcard.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Reword comment for allowHeaders to match methods

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Copy validation for * from allowMethods to headers

This uniformizes the validation for allowMethods and allowHeaders by
requiring that when '*' appears in allowHeaders, it must be the only
value in the list.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Add section on wildcards to GEP 1767

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Update GEP 1767 metadata with new PR

Signed-off-by: Damian Sawicki <dsawicki@google.com>

---------

Signed-off-by: Damian Sawicki <dsawicki@google.com>
k8s-infra-cherrypick-robot pushed a commit to k8s-infra-cherrypick-robot/gateway-api that referenced this pull request Feb 6, 2026
As per
kubernetes-sigs#4494 (comment)
Mozilla has an example where in response to an uncredentialed request,
the server responds with `Access-Control-Allow-Origin: *`.

However, responding with the value of the Origin from the request is
also valid (and the only allowed behavior for credentialed requests),
and it is the behavior of some implementations as per
https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401
so let's relax the requirement in the GEP to allow it.
@rikatz

rikatz commented Feb 8, 2026 •

Copy link
Copy Markdown
Member Author

/hold cancel
@robscott Now this is ready for that lgtm

Istio (on main) and Envou Gateway are passing with the current tests, the missing pieces are actually making the headers more permissive, which I think we can make if some implementation feels they should be sending wildcard methods instead of specific methods.

CORS is a bit tricky, because it actually relies not on the server sending the right information always, but on the browser trusting it. Envoy wise, all the wildcards passed as requests (methods, headers) are answered echoing the request or hiding the header in case it does not match the request from the user.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 8, 2026
k8s-ci-robot pushed a commit that referenced this pull request Feb 8, 2026
* Remove implementation-specific methods/headers

Previously, the GEP mentioned allowing "implementatio-specific default
methods and headers". It's not obvious what that means, but my
understanding is that this would allow implementations to arbitrarily
add certain values (not specified by the user) to the headers
Access-Control-Allow-Methods and Access-Control-Request-Headers`.
It does not seem to be needed. We can revisit this aspect
if it turns out otherwise.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Unify gep-1767 and httproute_types.go

It seems that not all changes in GEP 1767 were correctly reflected in
apis/v1/httproute_types.go. This is now fixed.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Allow specific Allow-Origin despite wildcard

As per
#4494 (comment)
Mozilla has an example where in response to an uncredentialed request,
the server responds with `Access-Control-Allow-Origin: *`.

However, responding with the value of the Origin from the request is
also valid (and the only allowed behavior for credentialed requests),
and it is the behavior of some implementations as per
https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401
so let's relax the requirement in the GEP to allow it.

* Allow specific Allow-Methods despite wildcard

As per
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#syntax
wildcard is a valid value for the Access-Control-Allow-Methods header.

However, as per
 * envoyproxy/envoy#8218
 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#browser_compatibility
the wildcard was not universally supported by browsers in 2019,
and hence many implementations don't use the wildcard.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Reword comment for allowHeaders to match methods

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Copy validation for * from allowMethods to headers

This uniformizes the validation for allowMethods and allowHeaders by
requiring that when '*' appears in allowHeaders, it must be the only
value in the list.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Add section on wildcards to GEP 1767

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Update GEP 1767 metadata with new PR

Signed-off-by: Damian Sawicki <dsawicki@google.com>

---------

Signed-off-by: Damian Sawicki <dsawicki@google.com>
Co-authored-by: Damian Sawicki <dsawicki@google.com>

@robscott robscott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work on this @rikatz! Just a couple nits, otherwise LGTM.

Comment thread conformance/utils/http/http.go Resolved
Comment thread conformance/utils/http/http.go Resolved
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rikatz, robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zhaohuabing

zhaohuabing commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

Hi @rikatz thanks for taking this on. I tested it against Envoy Gateway v1.7.0 and it passed.

@nbam-e

nbam-e commented Feb 10, 2026

Copy link
Copy Markdown

Hi @rikatz, I can confirm that Airlock Microgateway 4.8 also passes these tests in their current state.

@robscott

Copy link
Copy Markdown
Member

Thanks @rikatz!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 11, 2026
@k8s-ci-robot
k8s-ci-robot merged commit 0e7b37c into kubernetes-sigs:main Feb 11, 2026
20 checks passed
@rikatz

rikatz commented Feb 11, 2026

Copy link
Copy Markdown
Member Author

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@rikatz: #4494 failed to apply on top of branch "release-1.5":

Applying: add test for cors
Applying: add more tests
Applying: address comment
Applying: address comment
Applying: Update conformance/tests/httproute-cors.go
Applying: Update conformance/tests/httproute-cors.go
Applying: Add option to ignore whitespace in the resposnse header values
Applying: support multiple status codes
Using index info to reconstruct a base tree...
M	conformance/utils/http/http.go
Falling back to patching base and 3-way merge...
Auto-merging conformance/utils/http/http.go
Applying: address comment
Using index info to reconstruct a base tree...
M	conformance/utils/http/http.go
Falling back to patching base and 3-way merge...
Auto-merging conformance/utils/http/http.go
CONFLICT (content): Merge conflict in conformance/utils/http/http.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0009 address comment

Details

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@rikatz rikatz mentioned this pull request Feb 11, 2026
rikatz added a commit to rikatz/gateway-api that referenced this pull request Feb 11, 2026
* add test for cors

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* add more tests

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* Update conformance/tests/httproute-cors.go

Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>

* Update conformance/tests/httproute-cors.go

Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>

* Add option to ignore whitespace in the resposnse header values

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* support multiple status codes

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* fix lint

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* fix test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address some comments

* Add wildcard test on cors

* Add more tests to CORS

* Add more CORS conformance tests

* address comments on cors tests

---------

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
k8s-ci-robot pushed a commit that referenced this pull request Feb 11, 2026
* add test for cors



* add more tests



* address comment



* address comment



* Update conformance/tests/httproute-cors.go



* Update conformance/tests/httproute-cors.go



* Add option to ignore whitespace in the resposnse header values



* support multiple status codes



* address comment



* address comment



* fix lint



* fix test



* address comment



* address comments



* address comments



* address comments



* address comments



* address comments



* address comments



* address comments



* address some comments

* Add wildcard test on cors

* Add more tests to CORS

* Add more CORS conformance tests

* address comments on cors tests

---------

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
danehans pushed a commit to danehans/gateway-api that referenced this pull request Mar 10, 2026
* Remove implementation-specific methods/headers

Previously, the GEP mentioned allowing "implementatio-specific default
methods and headers". It's not obvious what that means, but my
understanding is that this would allow implementations to arbitrarily
add certain values (not specified by the user) to the headers
Access-Control-Allow-Methods and Access-Control-Request-Headers`.
It does not seem to be needed. We can revisit this aspect
if it turns out otherwise.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Unify gep-1767 and httproute_types.go

It seems that not all changes in GEP 1767 were correctly reflected in
apis/v1/httproute_types.go. This is now fixed.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Allow specific Allow-Origin despite wildcard

As per
kubernetes-sigs#4494 (comment)
Mozilla has an example where in response to an uncredentialed request,
the server responds with `Access-Control-Allow-Origin: *`.

However, responding with the value of the Origin from the request is
also valid (and the only allowed behavior for credentialed requests),
and it is the behavior of some implementations as per
https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401
so let's relax the requirement in the GEP to allow it.

* Allow specific Allow-Methods despite wildcard

As per
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#syntax
wildcard is a valid value for the Access-Control-Allow-Methods header.

However, as per
 * envoyproxy/envoy#8218
 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#browser_compatibility
the wildcard was not universally supported by browsers in 2019,
and hence many implementations don't use the wildcard.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Reword comment for allowHeaders to match methods

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Copy validation for * from allowMethods to headers

This uniformizes the validation for allowMethods and allowHeaders by
requiring that when '*' appears in allowHeaders, it must be the only
value in the list.

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Add section on wildcards to GEP 1767

Signed-off-by: Damian Sawicki <dsawicki@google.com>

* Update GEP 1767 metadata with new PR

Signed-off-by: Damian Sawicki <dsawicki@google.com>

---------

Signed-off-by: Damian Sawicki <dsawicki@google.com>
danehans pushed a commit to danehans/gateway-api that referenced this pull request Mar 10, 2026
* add test for cors

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* add more tests

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* Update conformance/tests/httproute-cors.go

Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>

* Update conformance/tests/httproute-cors.go

Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>

* Add option to ignore whitespace in the resposnse header values

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* support multiple status codes

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* fix lint

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* fix test

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comment

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address comments

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>

* address some comments

* Add wildcard test on cors

* Add more tests to CORS

* Add more CORS conformance tests

* address comments on cors tests

---------

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/conformance-test Issues or PRs related to Conformance tests. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants