From ba480725ab99cf21ea881b9767f32cdfc7068581 Mon Sep 17 00:00:00 2001 From: Lukas Rist Date: Tue, 24 Jan 2023 22:23:44 +0100 Subject: [PATCH] httpbin test --- system_test/rules.yaml | 2 +- system_test/system_test.go | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/system_test/rules.yaml b/system_test/rules.yaml index 4d57cf1..14b71bb 100644 --- a/system_test/rules.yaml +++ b/system_test/rules.yaml @@ -4,7 +4,7 @@ rules: type: log_http - match: tcp port 1337 type: proxy - target: tcp://tcpbin.com:4242 + target: tcp://httpbin.org:443 - match: tcp portrange 7000-8000 type: conn_handler target: echo diff --git a/system_test/system_test.go b/system_test/system_test.go index 7d34112..68ca27d 100644 --- a/system_test/system_test.go +++ b/system_test/system_test.go @@ -5,7 +5,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "net/http" "testing" @@ -25,7 +25,7 @@ func TestEndToEnd(t *testing.T) { So(resp.StatusCode, ShouldEqual, 200) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) So(err, ShouldBeNil) So(bytes.Equal(body, []byte("OK\n")), ShouldBeTrue) resp.Body.Close() @@ -36,21 +36,20 @@ func TestEndToEnd(t *testing.T) { }) Convey("Port 1137 should proxy to port.party:666", func() { - resp, err := http.Get("http://freki:1337/cors.json") + resp, err := http.Get("http://freki:1337/json") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode, ShouldEqual, 200) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) So(err, ShouldBeNil) - j := make(map[string]int) + j := make(map[string]string) So(json.Unmarshal(body, &j), ShouldBeNil) - So(j, ShouldContainKey, "Port") - So(j["Port"], ShouldEqual, 666) + So(j, ShouldContainKey, "slideshow") resp.Body.Close() })