diff options
author | Matthew Holt <[email protected]> | 2018-04-20 00:03:57 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2018-04-20 00:03:57 -0600 |
commit | b019501b8b1ab8346f858be02886e7e7dff0a1d9 (patch) | |
tree | c6a0e8c19ba3ad44396ec1b346979d5fd9ff7253 /caddyhttp/httpserver/server_test.go | |
parent | 8039a7127f3a8635b95f8e1ee2f7c5a08ffff62a (diff) | |
parent | 2922d09bef3c504dde66bc12f7441668fcef6a20 (diff) | |
download | caddy-b019501b8b1ab8346f858be02886e7e7dff0a1d9.tar.gz caddy-b019501b8b1ab8346f858be02886e7e7dff0a1d9.zip |
Merge branch 'master' into telemetry
# Conflicts:
# caddy/caddymain/run.go
# caddyhttp/httpserver/plugin.go
# caddytls/client.go
Diffstat (limited to 'caddyhttp/httpserver/server_test.go')
-rw-r--r-- | caddyhttp/httpserver/server_test.go | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/caddyhttp/httpserver/server_test.go b/caddyhttp/httpserver/server_test.go index 82926851d..afd29a983 100644 --- a/caddyhttp/httpserver/server_test.go +++ b/caddyhttp/httpserver/server_test.go @@ -129,88 +129,108 @@ func TestMakeHTTPServerWithTimeouts(t *testing.T) { func TestTrimPathPrefix(t *testing.T) { for i, pt := range []struct { - path string + url string prefix string expected string shouldFail bool }{ { - path: "/my/path", + url: "/my/path", prefix: "/my", expected: "/path", shouldFail: false, }, { - path: "/my/%2f/path", + url: "/my/%2f/path", prefix: "/my", expected: "/%2f/path", shouldFail: false, }, { - path: "/my/path", + url: "/my/path", prefix: "/my/", expected: "/path", shouldFail: false, }, { - path: "/my///path", + url: "/my///path", prefix: "/my", expected: "/path", shouldFail: true, }, { - path: "/my///path", + url: "/my///path", prefix: "/my", expected: "///path", shouldFail: false, }, { - path: "/my/path///slash", + url: "/my/path///slash", prefix: "/my", expected: "/path///slash", shouldFail: false, }, { - path: "/my/%2f/path/%2f", + url: "/my/%2f/path/%2f", prefix: "/my", expected: "/%2f/path/%2f", shouldFail: false, }, { - path: "/my/%20/path", + url: "/my/%20/path", prefix: "/my", expected: "/%20/path", shouldFail: false, }, { - path: "/path", + url: "/path", prefix: "", expected: "/path", shouldFail: false, }, { - path: "/path/my/", + url: "/path/my/", prefix: "/my", expected: "/path/my/", shouldFail: false, }, { - path: "", + url: "", prefix: "/my", expected: "/", shouldFail: false, }, { - path: "/apath", + url: "/apath", prefix: "", expected: "/apath", shouldFail: false, + }, { + url: "/my/path/page.php?akey=value", + prefix: "/my", + expected: "/path/page.php?akey=value", + shouldFail: false, + }, { + url: "/my/path/page?key=value#fragment", + prefix: "/my", + expected: "/path/page?key=value#fragment", + shouldFail: false, + }, { + url: "/my/path/page#fragment", + prefix: "/my", + expected: "/path/page#fragment", + shouldFail: false, + }, { + url: "/my/apath?", + prefix: "/my", + expected: "/apath?", + shouldFail: false, }, } { - u, _ := url.Parse(pt.path) - if got, want := trimPathPrefix(u, pt.prefix), pt.expected; got.EscapedPath() != want { + u, _ := url.Parse(pt.url) + if got, want := trimPathPrefix(u, pt.prefix), pt.expected; got.String() != want { if !pt.shouldFail { - t.Errorf("Test %d: Expected='%s', but was '%s' ", i, want, got.EscapedPath()) + t.Errorf("Test %d: Expected='%s', but was '%s' ", i, want, got.String()) } } else if pt.shouldFail { - t.Errorf("SHOULDFAIL Test %d: Expected='%s', and was '%s' but should fail", i, want, got.EscapedPath()) + t.Errorf("SHOULDFAIL Test %d: Expected='%s', and was '%s' but should fail", i, want, got.String()) } } } |