mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Apply review comments - change the used domain, remove obsolete function, remove commented tests
This commit is contained in:
parent
bd4d9c6fe2
commit
d6242e9cac
1 changed files with 12 additions and 22 deletions
|
@ -119,7 +119,7 @@ func TestCookie(t *testing.T) {
|
||||||
},
|
},
|
||||||
// Test 3 - cookie with optional fields
|
// Test 3 - cookie with optional fields
|
||||||
{
|
{
|
||||||
cookie: &http.Cookie{Name: "cookie", Value: "cookieValue", Path: "/path", Domain: "https://caddy.com", Expires: (time.Now().Add(10 * time.Minute)), MaxAge: 120},
|
cookie: &http.Cookie{Name: "cookie", Value: "cookieValue", Path: "/path", Domain: "https://localhost", Expires: (time.Now().Add(10 * time.Minute)), MaxAge: 120},
|
||||||
cookieName: "cookie",
|
cookieName: "cookie",
|
||||||
expectedValue: "cookieValue",
|
expectedValue: "cookieValue",
|
||||||
},
|
},
|
||||||
|
@ -194,12 +194,6 @@ func TestIP(t *testing.T) {
|
||||||
{"[2001:db8:a0b:12f0::1]", "[2001:db8:a0b:12f0::1]"},
|
{"[2001:db8:a0b:12f0::1]", "[2001:db8:a0b:12f0::1]"},
|
||||||
// Test 4 - ipv6 with zone and port
|
// Test 4 - ipv6 with zone and port
|
||||||
{`[fe80:1::3%eth0]:44`, `fe80:1::3%eth0`},
|
{`[fe80:1::3%eth0]:44`, `fe80:1::3%eth0`},
|
||||||
// Test 5 - ipv6 without port with brackets
|
|
||||||
// {"[:fe:2]", ":fe:2"}, // TODO - failing (error in SplitHostPort) returns the host with brackets
|
|
||||||
// Test 6 - invalid address
|
|
||||||
// {":::::::::::::", ""}, // TODO - failing (error in SplitHostPort) returns the invalid address
|
|
||||||
// Test 7 - invalid address
|
|
||||||
// {"[::1][]", ""}, // TODO - failing (error in SplitHostPort) returns the invalid address
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
@ -323,49 +317,49 @@ func TestPathMatches(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
// Test 0
|
// Test 0
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com/",
|
urlStr: "http://localhost/",
|
||||||
pattern: "",
|
pattern: "",
|
||||||
shouldMatch: true,
|
shouldMatch: true,
|
||||||
},
|
},
|
||||||
// Test 1
|
// Test 1
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com",
|
urlStr: "http://localhost",
|
||||||
pattern: "",
|
pattern: "",
|
||||||
shouldMatch: true,
|
shouldMatch: true,
|
||||||
},
|
},
|
||||||
// Test 1
|
// Test 1
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com/",
|
urlStr: "http://localhost/",
|
||||||
pattern: "/",
|
pattern: "/",
|
||||||
shouldMatch: true,
|
shouldMatch: true,
|
||||||
},
|
},
|
||||||
// Test 3
|
// Test 3
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com/?param=val",
|
urlStr: "http://localhost/?param=val",
|
||||||
pattern: "/",
|
pattern: "/",
|
||||||
shouldMatch: true,
|
shouldMatch: true,
|
||||||
},
|
},
|
||||||
// Test 4
|
// Test 4
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com/dir1/dir2",
|
urlStr: "http://localhost/dir1/dir2",
|
||||||
pattern: "/dir2",
|
pattern: "/dir2",
|
||||||
shouldMatch: false,
|
shouldMatch: false,
|
||||||
},
|
},
|
||||||
// Test 5
|
// Test 5
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com/dir1/dir2",
|
urlStr: "http://localhost/dir1/dir2",
|
||||||
pattern: "/dir1",
|
pattern: "/dir1",
|
||||||
shouldMatch: true,
|
shouldMatch: true,
|
||||||
},
|
},
|
||||||
// Test 6
|
// Test 6
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com:444/dir1/dir2",
|
urlStr: "http://localhost:444/dir1/dir2",
|
||||||
pattern: "/dir1",
|
pattern: "/dir1",
|
||||||
shouldMatch: true,
|
shouldMatch: true,
|
||||||
},
|
},
|
||||||
// Test 7
|
// Test 7
|
||||||
{
|
{
|
||||||
urlStr: "http://caddy.com/dir1/dir2",
|
urlStr: "http://localhost/dir1/dir2",
|
||||||
pattern: "*/dir2",
|
pattern: "*/dir2",
|
||||||
shouldMatch: false,
|
shouldMatch: false,
|
||||||
},
|
},
|
||||||
|
@ -387,13 +381,13 @@ func TestPathMatches(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initTestContext() (Context, error) {
|
func initTestContext() (Context, error) {
|
||||||
rootDir := getTestFilesFolder()
|
|
||||||
body := bytes.NewBufferString("request body")
|
body := bytes.NewBufferString("request body")
|
||||||
request, err := http.NewRequest("GET", "https://caddy.com", body)
|
request, err := http.NewRequest("GET", "https://localhost", body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Context{}, err
|
return Context{}, err
|
||||||
}
|
}
|
||||||
return Context{Root: http.Dir(rootDir), Req: request}, nil
|
|
||||||
|
return Context{Root: http.Dir(os.TempDir()), Req: request}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContextOrFail(t *testing.T) Context {
|
func getContextOrFail(t *testing.T) Context {
|
||||||
|
@ -404,10 +398,6 @@ func getContextOrFail(t *testing.T) Context {
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestFilesFolder() string {
|
|
||||||
return os.TempDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getTestPrefix(testN int) string {
|
func getTestPrefix(testN int) string {
|
||||||
return fmt.Sprintf("Test [%d]: ", testN)
|
return fmt.Sprintf("Test [%d]: ", testN)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue