Skip to content
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

Add a test case on input contract validation #3315

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pushpalanka
Copy link
Collaborator

@Pushpalanka Pushpalanka commented Nov 20, 2024

Confirm the included cases of envoy input format included in Skipper.

HTTP2 headers are not supported yet.
Also below items are not supported though available in the envoy input format.

input.attributes.request.http.protocol == "HTTP/1.1" input.attributes.destination.address.socketAddress.address == "10.25.95.68" input.attributes.destination.address.socketAddress.portValue == 8000 input.attributes.source.address.socketAddress.address == "10.25.95.69" input.attributes.source.address.socketAddress.portValue == 33772 input.attributes.request.http.headers[":authority"] == "example-app"

Signed-off-by: Pushpalanka Jayawardhana <pushpalanka.jayawardhana@zalando.de>
@Pushpalanka Pushpalanka added the minor no risk changes, for example new filters label Nov 20, 2024
Signed-off-by: Pushpalanka Jayawardhana <pushpalanka.jayawardhana@zalando.de>
@Pushpalanka Pushpalanka marked this pull request as ready for review November 20, 2024 16:25
@Pushpalanka Pushpalanka marked this pull request as draft December 6, 2024 15:30
@Pushpalanka Pushpalanka requested review from mjungsbluth and removed request for mjungsbluth December 6, 2024 15:31
@Pushpalanka Pushpalanka marked this pull request as ready for review January 8, 2025 12:20
@wisinghe
Copy link
Collaborator

👍

Comment on lines +643 to +645
if err != nil {
t.Fatal(err)
}
Copy link
Member

Choose a reason for hiding this comment

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

require.NoError fits better here for consistency.

Use require.* to ensure execution flow has no errors and assert.* for conditions that you test

Comment on lines +724 to +728
for name, values := range ti.removeHeaders {
for _, value := range values {
req.Header.Add(name, value) //adding the headers to validate removal.
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be unused by the test cases. Lets remove all unused testcase fields and introduce them later along with testcases that utilize them.

Comment on lines +729 to +733
for name, values := range ti.requestHeaders {
for _, value := range values {
req.Header.Add(name, value)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can simply assign here like req.Header = ti.requestHeaders


defer rsp.Body.Close()
body, err := io.ReadAll(rsp.Body)
assert.NoError(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

require.NoError fits better here.

func isHeadersPresent(t *testing.T, expectedHeaders http.Header, headers http.Header) bool {
for headerName, expectedValues := range expectedHeaders {
actualValues, headerFound := headers[headerName]
actualValues, headerFound := headers[http.CanonicalHeaderKey(headerName)]
Copy link
Member

Choose a reason for hiding this comment

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

Its better to have less transformations as possible of the expected values - here we can expect canonical header names in the test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor no risk changes, for example new filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants