-
Notifications
You must be signed in to change notification settings - Fork 353
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Pushpalanka Jayawardhana <pushpalanka.jayawardhana@zalando.de>
7c90924
to
7316b8f
Compare
Signed-off-by: Pushpalanka Jayawardhana <pushpalanka.jayawardhana@zalando.de>
7316b8f
to
7da400c
Compare
👍 |
if err != nil { | ||
t.Fatal(err) | ||
} |
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.
require.NoError fits better here for consistency.
Use require.* to ensure execution flow has no errors and assert.* for conditions that you test
for name, values := range ti.removeHeaders { | ||
for _, value := range values { | ||
req.Header.Add(name, value) //adding the headers to validate removal. | ||
} | ||
} |
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.
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.
for name, values := range ti.requestHeaders { | ||
for _, value := range values { | ||
req.Header.Add(name, value) | ||
} | ||
} |
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.
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) |
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.
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)] |
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.
Its better to have less transformations as possible of the expected values - here we can expect canonical header names in the test cases.
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"