summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-05-17 11:28:43 +0200
committerMatus Fabian <matfabia@cisco.com>2024-05-17 11:28:43 +0200
commit595d8cb6689a2c6f6f4444125127270b2e10b380 (patch)
tree781f6b6a68c8fae3de638365d470f5b3ee81d4f2
parent46d66000fbccaaf782ca0313107355c77768f164 (diff)
http: ignore http_proxy env in tests
Type: test Change-Id: I45a091a43e7ecb3f321fc9ecc761df2b44c9c351 Signed-off-by: Matus Fabian <matfabia@cisco.com>
-rw-r--r--extras/hs-test/http_test.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index f52d2816930..37416194e6c 100644
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -115,10 +115,13 @@ func HttpStaticMovedTest(s *NoTopoSuite) {
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
s.log(vpp.vppctl("http static server www-root /tmp uri tcp://" + serverAddress + "/80 debug"))
+ transport := http.DefaultTransport
+ transport.(*http.Transport).Proxy = nil
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
+ Transport: transport,
}
req, err := http.NewRequest("GET", "http://"+serverAddress+":80/tmp.aaa", nil)
s.assertNil(err, fmt.Sprint(err))
@@ -134,9 +137,12 @@ func HttpStaticNotFoundTest(s *NoTopoSuite) {
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
s.log(vpp.vppctl("http static server www-root /tmp uri tcp://" + serverAddress + "/80 debug"))
+ transport := http.DefaultTransport
+ transport.(*http.Transport).Proxy = nil
+ client := &http.Client{Transport: transport}
req, err := http.NewRequest("GET", "http://"+serverAddress+":80/notfound.html", nil)
s.assertNil(err, fmt.Sprint(err))
- resp, err := http.DefaultClient.Do(req)
+ resp, err := client.Do(req)
s.assertNil(err, fmt.Sprint(err))
defer resp.Body.Close()
s.assertEqual(404, resp.StatusCode)
@@ -147,9 +153,12 @@ func HttpCliMethodNotAllowedTest(s *NoTopoSuite) {
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
vpp.vppctl("http cli server")
+ transport := http.DefaultTransport
+ transport.(*http.Transport).Proxy = nil
+ client := &http.Client{Transport: transport}
req, err := http.NewRequest("POST", "http://"+serverAddress+":80/test", nil)
s.assertNil(err, fmt.Sprint(err))
- resp, err := http.DefaultClient.Do(req)
+ resp, err := client.Do(req)
s.assertNil(err, fmt.Sprint(err))
defer resp.Body.Close()
s.assertEqual(405, resp.StatusCode)
@@ -162,9 +171,12 @@ func HttpCliBadRequestTest(s *NoTopoSuite) {
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
vpp.vppctl("http cli server")
+ transport := http.DefaultTransport
+ transport.(*http.Transport).Proxy = nil
+ client := &http.Client{Transport: transport}
req, err := http.NewRequest("GET", "http://"+serverAddress+":80", nil)
s.assertNil(err, fmt.Sprint(err))
- resp, err := http.DefaultClient.Do(req)
+ resp, err := client.Do(req)
s.assertNil(err, fmt.Sprint(err))
defer resp.Body.Close()
s.assertEqual(400, resp.StatusCode)
@@ -175,9 +187,12 @@ func HeaderServerTest(s *NoTopoSuite) {
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
vpp.vppctl("http cli server")
+ transport := http.DefaultTransport
+ transport.(*http.Transport).Proxy = nil
+ client := &http.Client{Transport: transport}
req, err := http.NewRequest("GET", "http://"+serverAddress+":80/show/version", nil)
s.assertNil(err, fmt.Sprint(err))
- resp, err := http.DefaultClient.Do(req)
+ resp, err := client.Do(req)
s.assertNil(err, fmt.Sprint(err))
defer resp.Body.Close()
s.assertEqual("http_cli_server", resp.Header.Get("Server"))