TUN-3484: OriginService that responds with configured HTTP status

This commit is contained in:
Adam Chalmers
2020-11-04 12:22:21 -06:00
parent d01770107e
commit bc015995d8
4 changed files with 78 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ import (
"net/url"
"regexp"
"testing"
"github.com/stretchr/testify/require"
)
func Test_rule_matches(t *testing.T) {
@@ -117,3 +119,19 @@ func Test_rule_matches(t *testing.T) {
})
}
}
func TestStaticHTTPStatus(t *testing.T) {
o := newStatusCode(404)
buf := make([]byte, 100)
sendReq := func() {
resp, err := o.RoundTrip(nil)
require.NoError(t, err)
_, err = resp.Body.Read(buf)
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
require.Equal(t, 404, resp.StatusCode)
}
sendReq()
sendReq()
}