diff options
Diffstat (limited to 'caddytest/integration/sni_test.go')
-rw-r--r-- | caddytest/integration/sni_test.go | 497 |
1 files changed, 257 insertions, 240 deletions
diff --git a/caddytest/integration/sni_test.go b/caddytest/integration/sni_test.go index aa47c75..24dddc5 100644 --- a/caddytest/integration/sni_test.go +++ b/caddytest/integration/sni_test.go @@ -11,92 +11,95 @@ func TestDefaultSNI(t *testing.T) { // arrange tester := caddytest.NewTester(t) tester.InitServer(`{ - "apps": { - "http": { - "http_port": 9080, - "https_port": 9443, - "grace_period": 1, - "servers": { - "srv0": { - "listen": [ - ":9443" - ], - "routes": [ - { - "handle": [ - { - "handler": "subroute", - "routes": [ - { - "handle": [ - { - "body": "hello from a.caddy.localhost", - "handler": "static_response", - "status_code": 200 - } - ], - "match": [ - { - "path": [ - "/version" - ] - } - ] - } - ] - } - ], - "match": [ - { - "host": [ - "127.0.0.1" - ] - } - ], - "terminal": true - } - ], - "tls_connection_policies": [ - { - "certificate_selection": { - "any_tag": ["cert0"] - }, - "match": { - "sni": [ - "127.0.0.1" - ] - } - }, - { - "default_sni": "*.caddy.localhost" - } - ] - } - } - }, - "tls": { - "certificates": { - "load_files": [ - { - "certificate": "/caddy.localhost.crt", - "key": "/caddy.localhost.key", - "tags": [ - "cert0" - ] - } - ] - } - }, - "pki": { - "certificate_authorities" : { - "local" : { - "install_trust": false - } - } - } - } - } - `, "json") + "admin": { + "listen": "localhost:2999" + }, + "apps": { + "http": { + "http_port": 9080, + "https_port": 9443, + "grace_period": 1, + "servers": { + "srv0": { + "listen": [ + ":9443" + ], + "routes": [ + { + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "body": "hello from a.caddy.localhost", + "handler": "static_response", + "status_code": 200 + } + ], + "match": [ + { + "path": [ + "/version" + ] + } + ] + } + ] + } + ], + "match": [ + { + "host": [ + "127.0.0.1" + ] + } + ], + "terminal": true + } + ], + "tls_connection_policies": [ + { + "certificate_selection": { + "any_tag": ["cert0"] + }, + "match": { + "sni": [ + "127.0.0.1" + ] + } + }, + { + "default_sni": "*.caddy.localhost" + } + ] + } + } + }, + "tls": { + "certificates": { + "load_files": [ + { + "certificate": "/caddy.localhost.crt", + "key": "/caddy.localhost.key", + "tags": [ + "cert0" + ] + } + ] + } + }, + "pki": { + "certificate_authorities" : { + "local" : { + "install_trust": false + } + } + } + } + } + `, "json") // act and assert // makes a request with no sni @@ -108,97 +111,100 @@ func TestDefaultSNIWithNamedHostAndExplicitIP(t *testing.T) { // arrange tester := caddytest.NewTester(t) tester.InitServer(` - { - "apps": { - "http": { - "http_port": 9080, - "https_port": 9443, - "grace_period": 1, - "servers": { - "srv0": { - "listen": [ - ":9443" - ], - "routes": [ - { - "handle": [ - { - "handler": "subroute", - "routes": [ - { - "handle": [ - { - "body": "hello from a", - "handler": "static_response", - "status_code": 200 - } - ], - "match": [ - { - "path": [ - "/version" - ] - } - ] - } - ] - } - ], - "match": [ - { - "host": [ - "a.caddy.localhost", - "127.0.0.1" - ] - } - ], - "terminal": true - } - ], - "tls_connection_policies": [ - { - "certificate_selection": { - "any_tag": ["cert0"] - }, - "default_sni": "a.caddy.localhost", - "match": { - "sni": [ - "a.caddy.localhost", - "127.0.0.1", - "" - ] - } - }, - { - "default_sni": "a.caddy.localhost" - } - ] - } - } - }, - "tls": { - "certificates": { - "load_files": [ - { - "certificate": "/a.caddy.localhost.crt", - "key": "/a.caddy.localhost.key", - "tags": [ - "cert0" - ] - } - ] - } - }, - "pki": { - "certificate_authorities" : { - "local" : { - "install_trust": false - } - } - } - } - } - `, "json") + { + "admin": { + "listen": "localhost:2999" + }, + "apps": { + "http": { + "http_port": 9080, + "https_port": 9443, + "grace_period": 1, + "servers": { + "srv0": { + "listen": [ + ":9443" + ], + "routes": [ + { + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "body": "hello from a", + "handler": "static_response", + "status_code": 200 + } + ], + "match": [ + { + "path": [ + "/version" + ] + } + ] + } + ] + } + ], + "match": [ + { + "host": [ + "a.caddy.localhost", + "127.0.0.1" + ] + } + ], + "terminal": true + } + ], + "tls_connection_policies": [ + { + "certificate_selection": { + "any_tag": ["cert0"] + }, + "default_sni": "a.caddy.localhost", + "match": { + "sni": [ + "a.caddy.localhost", + "127.0.0.1", + "" + ] + } + }, + { + "default_sni": "a.caddy.localhost" + } + ] + } + } + }, + "tls": { + "certificates": { + "load_files": [ + { + "certificate": "/a.caddy.localhost.crt", + "key": "/a.caddy.localhost.key", + "tags": [ + "cert0" + ] + } + ] + } + }, + "pki": { + "certificate_authorities" : { + "local" : { + "install_trust": false + } + } + } + } + } + `, "json") // act and assert // makes a request with no sni @@ -209,69 +215,72 @@ func TestDefaultSNIWithPortMappingOnly(t *testing.T) { // arrange tester := caddytest.NewTester(t) tester.InitServer(` - { - "apps": { - "http": { - "http_port": 9080, - "https_port": 9443, - "grace_period": 1, - "servers": { - "srv0": { - "listen": [ - ":9443" - ], - "routes": [ - { - "handle": [ - { - "body": "hello from a.caddy.localhost", - "handler": "static_response", - "status_code": 200 - } - ], - "match": [ - { - "path": [ - "/version" - ] - } - ] - } - ], - "tls_connection_policies": [ - { - "certificate_selection": { - "any_tag": ["cert0"] - }, - "default_sni": "a.caddy.localhost" - } - ] - } - } - }, - "tls": { - "certificates": { - "load_files": [ - { - "certificate": "/a.caddy.localhost.crt", - "key": "/a.caddy.localhost.key", - "tags": [ - "cert0" - ] - } - ] - } - }, - "pki": { - "certificate_authorities" : { - "local" : { - "install_trust": false - } - } - } - } - } - `, "json") + { + "admin": { + "listen": "localhost:2999" + }, + "apps": { + "http": { + "http_port": 9080, + "https_port": 9443, + "grace_period": 1, + "servers": { + "srv0": { + "listen": [ + ":9443" + ], + "routes": [ + { + "handle": [ + { + "body": "hello from a.caddy.localhost", + "handler": "static_response", + "status_code": 200 + } + ], + "match": [ + { + "path": [ + "/version" + ] + } + ] + } + ], + "tls_connection_policies": [ + { + "certificate_selection": { + "any_tag": ["cert0"] + }, + "default_sni": "a.caddy.localhost" + } + ] + } + } + }, + "tls": { + "certificates": { + "load_files": [ + { + "certificate": "/a.caddy.localhost.crt", + "key": "/a.caddy.localhost.key", + "tags": [ + "cert0" + ] + } + ] + } + }, + "pki": { + "certificate_authorities" : { + "local" : { + "install_trust": false + } + } + } + } + } + `, "json") // act and assert // makes a request with no sni @@ -281,6 +290,7 @@ func TestDefaultSNIWithPortMappingOnly(t *testing.T) { func TestHttpOnlyOnDomainWithSNI(t *testing.T) { caddytest.AssertAdapt(t, ` { + skip_install_trust default_sni a.caddy.localhost } :80 { @@ -316,6 +326,13 @@ func TestHttpOnlyOnDomainWithSNI(t *testing.T) { ] } } + }, + "pki": { + "certificate_authorities": { + "local": { + "install_trust": false + } + } } } }`) |