Skip to content

Conversation

zhaohuabing
Copy link
Contributor

@zhaohuabing zhaohuabing commented Apr 9, 2025

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

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

Which issue(s) this PR fixes:

Related #3649

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added kind/test do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. area/conformance-test Issues or PRs related to Conformance tests. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 9, 2025
@zhaohuabing zhaohuabing marked this pull request as draft April 9, 2025 02:25
@k8s-ci-robot
Copy link
Contributor

Hi @zhaohuabing. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Apr 9, 2025
@zhaohuabing zhaohuabing changed the title test: cors conformance test: CORS Apr 9, 2025
@zhaohuabing zhaohuabing marked this pull request as ready for review April 24, 2025 12:00
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 24, 2025
@k8s-ci-robot k8s-ci-robot requested a review from youngnick April 24, 2025 12:00
@zhaohuabing
Copy link
Contributor Author

Hi @mikemorris @sunjayBhatia @youngnick Is there anything I can do to help the review? This is the first time creating a conformance test PR, so there is a good chance I may have missed something that's blocking the review. Please feel free to let me know if there's anything I can address. Thanks!

cc @arkodg

@zhaohuabing zhaohuabing requested a review from snorwin May 14, 2025 08:00
@snorwin
Copy link
Member

snorwin commented May 15, 2025

@zhaohuabing I verified the new CORS tests against our implementation and identified a difference in how the access-control-request-headers is mapped. See the comment here: #3739 (comment).

Just a heads-up: depending on the outcome of #3648, the tests might need to be adapted or extended accordingly.

@zhaohuabing zhaohuabing force-pushed the cors-test branch 2 times, most recently from e6c17a3 to d0e2f9a Compare May 15, 2025 11:01
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@k8s-ci-robot k8s-ci-robot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 28, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: snorwin, zhaohuabing
Once this PR has been reviewed and has the lgtm label, please ask for approval from shaneutt. For more information see the Code Review Process.

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

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

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 28, 2025
@zhaohuabing
Copy link
Contributor Author

@rikatz I rebased and might have broken conformance/utils/http/http.go - I will wrap this up this weekend.

Thanks!

@shaneutt
Copy link
Member

Thank you @zhaohuabing! Sorry that this lagged for a while. We're trying to code freeze next wednesday for v1.4.0 and we appreciate you jumping back in 🖖

Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 31, 2025
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Copy link
Member

@snorwin snorwin left a comment

Choose a reason for hiding this comment

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

I haven’t had the time to review the recent changes in detail. However, I can confirm that the Airlock Microgateway implementation successfully passes all HTTPRouteCORS conformance tests.

@rikatz
Copy link
Member

rikatz commented Sep 2, 2025

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 2, 2025
if expected.ExpectedRequest == nil {
expected.ExpectedRequest = &ExpectedRequest{Request: expected.Request}
}
if cRes.StatusCode == 200 || cRes.StatusCode == 204 {
Copy link
Member

Choose a reason for hiding this comment

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

it is a bit confusing here to understand why the code "204" was added here, just then to be checked on line 391.

What if you split the cases here as:

  • just code 200 specifics (from line 328 to 391)
  • code 200 or 204 specifics (from 391 onwards)

Also, please add a comment why we care now about code 204, that is used by CORS preflight tests (should this be an option instead of implicit on 200 returns?)

@rikatz
Copy link
Member

rikatz commented Sep 2, 2025

/hold
/assign
/cc

I am taking a look into it. I think the test is fine, but I have some concerns on changing the http library, so I will take a deeper look into the changes :)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 2, 2025
@k8s-ci-robot k8s-ci-robot requested a review from rikatz September 2, 2025 12:58
HeadersWithMultipleValues: map[string][]string{
"access-control-allow-origin": {"https://www.bar.com"},
"access-control-allow-methods": {
"GET, OPTIONS",
Copy link
Member

Choose a reason for hiding this comment

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

is the order relevant here or is it because the assertion is not able to check if the array contains an item?

If this is the second, I would prefer that we have single entries here, and that we fix the http library to check if the array contains both items

if cRes.Headers == nil {
return fmt.Errorf("no headers captured, expected %v", len(expected.ExpectedRequest.Headers))
return fmt.Errorf("no headers captured, expected %v", len(expected.Response.Headers))
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this error contain the len of HeadersWithMultipleValues as well?

return fmt.Errorf("expected %s header to be set to one of %v, got %s", name, expectedVals, actualValStr)
}
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I think this else is unnecessary, right?

Like, you can check the headerswithMultipleValues, and then if Headers is also set you check it.

I think the whole if expected.Response.HeadersWithMultipleValues != nil { can be removed, you simply iterate over the HeadersWithMultipleValues first, and then on the Response.Headers, wdyt?

}
}
matched := false
for _, expectedVal := range expectedVals {
Copy link
Member

Choose a reason for hiding this comment

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

@shaneutt shaneutt removed this from Release v1.4.0 Sep 3, 2025
@shaneutt shaneutt modified the milestones: v1.4.0, v1.5.0 Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/conformance-test Issues or PRs related to Conformance tests. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/test ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. 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.

8 participants