1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-07 03:29:11 -04:00

fully migrate to new assertion lib

This commit is contained in:
Darien Raymond
2017-10-24 16:15:35 +02:00
parent 4a0ca30d08
commit 74cf833758
70 changed files with 974 additions and 942 deletions

View File

@@ -7,13 +7,13 @@ import (
"testing"
. "v2ray.com/core/proxy/http"
"v2ray.com/core/testing/assert"
. "v2ray.com/ext/assert"
_ "v2ray.com/core/transport/internet/tcp"
)
func TestHopByHopHeadersStrip(t *testing.T) {
assert := assert.On(t)
assert := With(t)
rawRequest := `GET /pkg/net/http/ HTTP/1.1
Host: golang.org
@@ -31,17 +31,17 @@ Accept-Language: de,en;q=0.7,en-us;q=0.3
`
b := bufio.NewReader(strings.NewReader(rawRequest))
req, err := http.ReadRequest(b)
assert.Error(err).IsNil()
assert.String(req.Header.Get("Foo")).Equals("foo")
assert.String(req.Header.Get("Bar")).Equals("bar")
assert.String(req.Header.Get("Connection")).Equals("keep-alive,Foo, Bar")
assert.String(req.Header.Get("Proxy-Connection")).Equals("keep-alive")
assert.String(req.Header.Get("Proxy-Authenticate")).Equals("abc")
assert(err, IsNil)
assert(req.Header.Get("Foo"), Equals, "foo")
assert(req.Header.Get("Bar"), Equals, "bar")
assert(req.Header.Get("Connection"), Equals, "keep-alive,Foo, Bar")
assert(req.Header.Get("Proxy-Connection"), Equals, "keep-alive")
assert(req.Header.Get("Proxy-Authenticate"), Equals, "abc")
StripHopByHopHeaders(req.Header)
assert.String(req.Header.Get("Connection")).IsEmpty()
assert.String(req.Header.Get("Foo")).IsEmpty()
assert.String(req.Header.Get("Bar")).IsEmpty()
assert.String(req.Header.Get("Proxy-Connection")).IsEmpty()
assert.String(req.Header.Get("Proxy-Authenticate")).IsEmpty()
assert(req.Header.Get("Connection"), IsEmpty)
assert(req.Header.Get("Foo"), IsEmpty)
assert(req.Header.Get("Bar"), IsEmpty)
assert(req.Header.Get("Proxy-Connection"), IsEmpty)
assert(req.Header.Get("Proxy-Authenticate"), IsEmpty)
}