mirror of
https://github.com/1f349/violet.git
synced 2024-11-21 19:01:39 +00:00
Change the wildcard test to actually test wildcard hosts
This commit is contained in:
parent
8ab677964d
commit
dfdc2b2c11
@ -194,7 +194,7 @@ func TestRouter_AddRoute(t *testing.T) {
|
|||||||
if v == "" {
|
if v == "" {
|
||||||
if transSecure.req != nil {
|
if transSecure.req != nil {
|
||||||
t.Logf("Test URL: %#v\n", req.URL)
|
t.Logf("Test URL: %#v\n", req.URL)
|
||||||
t.Log(r.redirect["example.com"].String())
|
t.Log(r.route["example.com"].String())
|
||||||
t.Fatalf("%s => %s\n", k, v)
|
t.Fatalf("%s => %s\n", k, v)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -269,29 +269,29 @@ func TestRouter_AddWildcardRoute(t *testing.T) {
|
|||||||
r := New(proxy.NewHybridTransportWithCalls(transSecure, transInsecure))
|
r := New(proxy.NewHybridTransportWithCalls(transSecure, transInsecure))
|
||||||
dst := i.dst
|
dst := i.dst
|
||||||
dst.Dst = path.Join("127.0.0.1:8080", dst.Dst)
|
dst.Dst = path.Join("127.0.0.1:8080", dst.Dst)
|
||||||
dst.Src = path.Join("example.com", i.path)
|
dst.Src = path.Join("*.example.com", i.path)
|
||||||
t.Logf("Running tests for %#v\n", dst)
|
t.Logf("Running tests for %#v\n", dst)
|
||||||
r.AddRoute(dst)
|
r.AddRoute(dst)
|
||||||
for k, v := range i.tests {
|
for k, v := range i.tests {
|
||||||
u1 := &url.URL{Scheme: "https", Host: "example.com", Path: k}
|
u1 := &url.URL{Scheme: "https", Host: "test.example.com", Path: k}
|
||||||
req, _ := http.NewRequest(http.MethodGet, u1.String(), nil)
|
req, _ := http.NewRequest(http.MethodGet, u1.String(), nil)
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
r.ServeHTTP(rec, req)
|
r.ServeHTTP(rec, req)
|
||||||
if v == "" {
|
if v == "" {
|
||||||
if transSecure.req != nil {
|
if transSecure.req != nil {
|
||||||
t.Logf("Test URL: %#v\n", req.URL)
|
t.Logf("Test URL: %#v\n", req.URL)
|
||||||
t.Log(r.redirect["example.com"].String())
|
t.Log(r.route["*.example.com"].String())
|
||||||
t.Fatalf("%s => %s\n", k, v)
|
t.Fatalf("%s => %s\n", k, v)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if transSecure.req == nil {
|
if transSecure.req == nil {
|
||||||
t.Logf("Test URL: %#v\n", req.URL)
|
t.Logf("Test URL: %#v\n", req.URL)
|
||||||
t.Log(r.route["example.com"].String())
|
t.Log(r.route["*.example.com"].String())
|
||||||
t.Fatalf("\nexpected %s => %s\n got %s => %s\n", k, v, k, "")
|
t.Fatalf("\nexpected %s => %s\n got %s => %s\n", k, v, k, "")
|
||||||
}
|
}
|
||||||
if v != transSecure.req.URL.Path {
|
if v != transSecure.req.URL.Path {
|
||||||
t.Logf("Test URL: %#v\n", req.URL)
|
t.Logf("Test URL: %#v\n", req.URL)
|
||||||
t.Log(r.route["example.com"].String())
|
t.Log(r.route["*.example.com"].String())
|
||||||
t.Fatalf("\nexpected %s => %s\n got %s => %s\n", k, v, k, transSecure.req.URL.Path)
|
t.Fatalf("\nexpected %s => %s\n got %s => %s\n", k, v, k, transSecure.req.URL.Path)
|
||||||
}
|
}
|
||||||
transSecure.req = nil
|
transSecure.req = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user