Skip to content

Commit

Permalink
httpbin test
Browse files Browse the repository at this point in the history
  • Loading branch information
glaslos committed Jan 24, 2023
1 parent ebde46e commit ba48072
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion system_test/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions system_test/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"testing"
Expand All @@ -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()
Expand All @@ -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()
})
Expand Down

0 comments on commit ba48072

Please sign in to comment.