-
Notifications
You must be signed in to change notification settings - Fork 588
conformance test: CORS #3739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
conformance test: CORS #3739
Conversation
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 Once the patch is verified, the new status will be reflected by the 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. |
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 I verified the new CORS tests against our implementation and identified a difference in how the Just a heads-up: depending on the outcome of #3648, the tests might need to be adapted or extended accordingly. |
e6c17a3
to
d0e2f9a
Compare
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: snorwin, zhaohuabing 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 |
@rikatz I rebased and might have broken conformance/utils/http/http.go - I will wrap this up this weekend. Thanks! |
Thank you @zhaohuabing! Sorry that this lagged for a while. We're trying to code freeze next wednesday for |
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
There was a problem hiding this 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.
/release-note-none |
if expected.ExpectedRequest == nil { | ||
expected.ExpectedRequest = &ExpectedRequest{Request: expected.Request} | ||
} | ||
if cRes.StatusCode == 200 || cRes.StatusCode == 204 { |
There was a problem hiding this comment.
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?)
/hold 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 :) |
HeadersWithMultipleValues: map[string][]string{ | ||
"access-control-allow-origin": {"https://www.bar.com"}, | ||
"access-control-allow-methods": { | ||
"GET, OPTIONS", |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be replaced by https://pkg.go.dev/slices#Contains
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?: