summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile/addresses_test.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-01-19 11:51:17 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2020-01-19 11:51:17 -0700
commitaad9f90cad23d709075073fd59214a51249de386 (patch)
treee0283a010e379fd84e2f0af425ebc79afec637db /caddyconfig/httpcaddyfile/addresses_test.go
parent07ef4b0c7db356bfc1d334187c0920f85aa416f3 (diff)
httpcaddyfile: Fix address parsing; don't infer port at parse-time
Before, listener ports could be wrong because ParseAddress doesn't know about the user-configured HTTP/HTTPS ports, instead hard-coding port 80 or 443, which could be wrong if the user changed them to something else. Now we defer port and scheme validation/inference to a later part of building the output JSON.
Diffstat (limited to 'caddyconfig/httpcaddyfile/addresses_test.go')
-rw-r--r--caddyconfig/httpcaddyfile/addresses_test.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/caddyconfig/httpcaddyfile/addresses_test.go b/caddyconfig/httpcaddyfile/addresses_test.go
index 70577f1..e22535c 100644
--- a/caddyconfig/httpcaddyfile/addresses_test.go
+++ b/caddyconfig/httpcaddyfile/addresses_test.go
@@ -28,17 +28,17 @@ func TestParseAddress(t *testing.T) {
{`http://localhost:https`, "", "", "", "", true}, // conflict
{`http://localhost:http`, "", "", "", "", true}, // repeated scheme
{`host:https/path`, "", "", "", "", true},
- {`http://localhost:443`, "", "", "", "", true}, // not conventional
- {`https://localhost:80`, "", "", "", "", true}, // not conventional
- {`http://localhost`, "http", "localhost", "80", "", false},
- {`https://localhost`, "https", "localhost", "443", "", false},
- {`http://{env.APP_DOMAIN}`, "http", "{env.APP_DOMAIN}", "80", "", false},
+ {`http://localhost:443`, "http", "localhost", "443", "", false}, // NOTE: not conventional
+ {`https://localhost:80`, "https", "localhost", "80", "", false}, // NOTE: not conventional
+ {`http://localhost`, "http", "localhost", "", "", false},
+ {`https://localhost`, "https", "localhost", "", "", false},
+ {`http://{env.APP_DOMAIN}`, "http", "{env.APP_DOMAIN}", "", "", false},
{`{env.APP_DOMAIN}:80`, "", "{env.APP_DOMAIN}", "80", "", false},
{`{env.APP_DOMAIN}/path`, "", "{env.APP_DOMAIN}", "", "/path", false},
{`example.com/{env.APP_PATH}`, "", "example.com", "", "/{env.APP_PATH}", false},
- {`http://127.0.0.1`, "http", "127.0.0.1", "80", "", false},
- {`https://127.0.0.1`, "https", "127.0.0.1", "443", "", false},
- {`http://[::1]`, "http", "::1", "80", "", false},
+ {`http://127.0.0.1`, "http", "127.0.0.1", "", "", false},
+ {`https://127.0.0.1`, "https", "127.0.0.1", "", "", false},
+ {`http://[::1]`, "http", "::1", "", "", false},
{`http://localhost:1234`, "http", "localhost", "1234", "", false},
{`https://127.0.0.1:1234`, "https", "127.0.0.1", "1234", "", false},
{`http://[::1]:1234`, "http", "::1", "1234", "", false},
@@ -47,10 +47,10 @@ func TestParseAddress(t *testing.T) {
{`localhost::`, "", "localhost::", "", "", false},
{`#$%@`, "", "#$%@", "", "", false}, // don't want to presume what the hostname could be
{`host/path`, "", "host", "", "/path", false},
- {`http://host/`, "http", "host", "80", "/", false},
+ {`http://host/`, "http", "host", "", "/", false},
{`//asdf`, "", "", "", "//asdf", false},
{`:1234/asdf`, "", "", "1234", "/asdf", false},
- {`http://host/path`, "http", "host", "80", "/path", false},
+ {`http://host/path`, "http", "host", "", "/path", false},
{`https://host:443/path/foo`, "https", "host", "443", "/path/foo", false},
{`host:80/path`, "", "host", "80", "/path", false},
{`/path`, "", "", "", "/path", false},