github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/proxy/blackhole/config_test.go (about) 1 package blackhole_test 2 3 import ( 4 "bufio" 5 "net/http" 6 "testing" 7 8 "github.com/v2fly/v2ray-core/v5/common" 9 "github.com/v2fly/v2ray-core/v5/common/buf" 10 . "github.com/v2fly/v2ray-core/v5/proxy/blackhole" 11 ) 12 13 func TestHTTPResponse(t *testing.T) { 14 buffer := buf.New() 15 16 httpResponse := new(HTTPResponse) 17 httpResponse.WriteTo(buf.NewWriter(buffer)) 18 19 reader := bufio.NewReader(buffer) 20 response, err := http.ReadResponse(reader, nil) 21 common.Must(err) 22 defer response.Body.Close() 23 24 if response.StatusCode != 403 { 25 t.Error("expected status code 403, but got ", response.StatusCode) 26 } 27 }