mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 16:19:57 +00:00
TUN-3484: OriginService that responds with configured HTTP status
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user