mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-29 08:26:24 +00:00
Make Request#RequestURI honor configured context root
Kubernetes-commit: 5677f7ab0b1b1ab22a71d01e4a710bf0f5e633aa
This commit is contained in:
committed by
Kubernetes Publisher
parent
7aa362d5dd
commit
25d4fa6ba8
@@ -292,14 +292,36 @@ func TestRequestError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRequestURI(t *testing.T) {
|
||||
r := (&Request{}).Param("foo", "a")
|
||||
r := (&Request{c: &RESTClient{base: &url.URL{Path: "/"}}}).Param("foo", "a").Param("bar", "b")
|
||||
r.Prefix("other")
|
||||
r.RequestURI("/test?foo=b&a=b&c=1&c=2")
|
||||
if r.pathPrefix != "/test" {
|
||||
t.Errorf("path is wrong: %#v", r)
|
||||
}
|
||||
if !reflect.DeepEqual(r.params, url.Values{"a": []string{"b"}, "foo": []string{"b"}, "c": []string{"1", "2"}}) {
|
||||
t.Errorf("should have set a param: %#v", r)
|
||||
t.Errorf("should have set a param, got: %#v", r.params)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestURIContext(t *testing.T) {
|
||||
r := (&Request{c: &RESTClient{base: &url.URL{Path: "/context"}}}).Param("foo", "a").Param("bar", "b")
|
||||
r.Prefix("other")
|
||||
r.RequestURI("/test?foo=b&a=b&c=1&c=2")
|
||||
if r.pathPrefix != "/context/test" {
|
||||
t.Errorf("path is wrong: %#v", r)
|
||||
}
|
||||
if !reflect.DeepEqual(r.params, url.Values{"a": []string{"b"}, "foo": []string{"b"}, "c": []string{"1", "2"}}) {
|
||||
t.Errorf("should have set a param, got: %#v", r.params)
|
||||
}
|
||||
|
||||
r = (&Request{c: &RESTClient{base: &url.URL{Path: "/context"}}}).Param("foo", "a").Param("bar", "b")
|
||||
r.Prefix("other")
|
||||
r.RequestURI("../test?foo=b&a=b&c=1&c=2")
|
||||
if r.pathPrefix != "/test" {
|
||||
t.Errorf("path is wrong: %#v", r)
|
||||
}
|
||||
if !reflect.DeepEqual(r.params, url.Values{"a": []string{"b"}, "foo": []string{"b"}, "c": []string{"1", "2"}}) {
|
||||
t.Errorf("should have set a param, got: %#v", r.params)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user