github.com/xmplusdev/xray-core@v1.8.10/proxy/blackhole/config_test.go (about)

     1  package blackhole_test
     2  
     3  import (
     4  	"bufio"
     5  	"net/http"
     6  	"testing"
     7  
     8  	"github.com/xmplusdev/xray-core/common"
     9  	"github.com/xmplusdev/xray-core/common/buf"
    10  	. "github.com/xmplusdev/xray-core/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  
    23  	if response.StatusCode != 403 {
    24  		t.Error("expected status code 403, but got ", response.StatusCode)
    25  	}
    26  }