mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Response body checked for all requests other than http HEAD
This commit is contained in:
parent
e9e74aa98b
commit
226f7c28e0
@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
@ -266,6 +267,7 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
ginkgo.It("A set of valid responses are returned for both pod and service ProxyWithPath", func() {
|
ginkgo.It("A set of valid responses are returned for both pod and service ProxyWithPath", func() {
|
||||||
|
|
||||||
ns := f.Namespace.Name
|
ns := f.Namespace.Name
|
||||||
|
msg := "foo"
|
||||||
|
|
||||||
framework.Logf("Creating pod...")
|
framework.Logf("Creating pod...")
|
||||||
_, err := f.ClientSet.CoreV1().Pods(ns).Create(context.TODO(), &v1.Pod{
|
_, err := f.ClientSet.CoreV1().Pods(ns).Create(context.TODO(), &v1.Pod{
|
||||||
@ -281,7 +283,7 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
Command: []string{"/agnhost", "porter"},
|
Command: []string{"/agnhost", "porter"},
|
||||||
Env: []v1.EnvVar{{
|
Env: []v1.EnvVar{{
|
||||||
Name: "SERVE_PORT_80",
|
Name: "SERVE_PORT_80",
|
||||||
Value: "foo",
|
Value: msg,
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
RestartPolicy: v1.RestartPolicyNever,
|
||||||
@ -325,6 +327,7 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All methods for Pod ProxyWithPath return 200
|
// All methods for Pod ProxyWithPath return 200
|
||||||
|
// response body returns 'foo' for all methods but HEAD
|
||||||
httpVerbs := []string{"DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"}
|
httpVerbs := []string{"DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"}
|
||||||
for _, httpVerb := range httpVerbs {
|
for _, httpVerb := range httpVerbs {
|
||||||
|
|
||||||
@ -337,11 +340,21 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
framework.ExpectNoError(err, "processing response")
|
framework.ExpectNoError(err, "processing response")
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
buf.ReadFrom(resp.Body)
|
||||||
|
response := buf.String()
|
||||||
|
|
||||||
framework.Logf("http.Client request:%s StatusCode:%d", httpVerb, resp.StatusCode)
|
framework.Logf("http.Client request:%s StatusCode:%d", httpVerb, resp.StatusCode)
|
||||||
|
framework.Logf("http.Client request:%s | StatusCode:%d | Response: %s", httpVerb, resp.StatusCode, response)
|
||||||
framework.ExpectEqual(resp.StatusCode, 200, "The resp.StatusCode returned: %d", resp.StatusCode)
|
framework.ExpectEqual(resp.StatusCode, 200, "The resp.StatusCode returned: %d", resp.StatusCode)
|
||||||
|
|
||||||
|
if httpVerb != "HEAD" {
|
||||||
|
framework.ExpectEqual(response, msg, "The resp.Body returned: %v", resp.Body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All methods for Service ProxyWithPath return 200
|
// All methods for Service ProxyWithPath return 200
|
||||||
|
// response body returns 'foo' for all methods but HEAD
|
||||||
for _, httpVerb := range httpVerbs {
|
for _, httpVerb := range httpVerbs {
|
||||||
|
|
||||||
urlString := f.ClientConfig().Host + "/api/v1/namespaces/" + ns + "/services/test-service/proxy/some/path/with/" + httpVerb
|
urlString := f.ClientConfig().Host + "/api/v1/namespaces/" + ns + "/services/test-service/proxy/some/path/with/" + httpVerb
|
||||||
@ -353,8 +366,16 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
framework.ExpectNoError(err, "processing response")
|
framework.ExpectNoError(err, "processing response")
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
framework.Logf("http.Client request:%s StatusCode:%d", httpVerb, resp.StatusCode)
|
buf := new(bytes.Buffer)
|
||||||
|
buf.ReadFrom(resp.Body)
|
||||||
|
response := buf.String()
|
||||||
|
|
||||||
|
framework.Logf("http.Client request:%s | StatusCode:%d | Response: %s", httpVerb, resp.StatusCode, response)
|
||||||
framework.ExpectEqual(resp.StatusCode, 200, "The resp.StatusCode returned: %d", resp.StatusCode)
|
framework.ExpectEqual(resp.StatusCode, 200, "The resp.StatusCode returned: %d", resp.StatusCode)
|
||||||
|
|
||||||
|
if httpVerb != "HEAD" {
|
||||||
|
framework.ExpectEqual(response, msg, "The resp.Body returned: %v", resp.Body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user