mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-03 23:09:57 -05:00
tls: Fix tests on Windows (#2093)
This commit is contained in:
parent
73b61af58d
commit
38e65e28d4
1 changed files with 31 additions and 14 deletions
|
@ -14,7 +14,10 @@
|
|||
|
||||
package caddytls
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// *********************************** NOTE ********************************
|
||||
// Due to circular package dependencies with the storagetest sub package and
|
||||
|
@ -22,33 +25,47 @@ import "testing"
|
|||
// the tests for file storage are done in the storagetest package.
|
||||
|
||||
func TestPathBuilders(t *testing.T) {
|
||||
fs := FileStorage{Path: "/test"}
|
||||
fs := FileStorage{Path: "test"}
|
||||
|
||||
for i, testcase := range []struct {
|
||||
in, folder, certFile, keyFile, metaFile string
|
||||
}{
|
||||
{
|
||||
in: "example.com",
|
||||
folder: "/test/sites/example.com",
|
||||
certFile: "/test/sites/example.com/example.com.crt",
|
||||
keyFile: "/test/sites/example.com/example.com.key",
|
||||
metaFile: "/test/sites/example.com/example.com.json",
|
||||
folder: filepath.Join("test", "sites", "example.com"),
|
||||
certFile: filepath.Join("test", "sites", "example.com", "example.com.crt"),
|
||||
keyFile: filepath.Join("test", "sites", "example.com", "example.com.key"),
|
||||
metaFile: filepath.Join("test", "sites", "example.com", "example.com.json"),
|
||||
},
|
||||
{
|
||||
in: "*.example.com",
|
||||
folder: "/test/sites/wildcard_.example.com",
|
||||
certFile: "/test/sites/wildcard_.example.com/wildcard_.example.com.crt",
|
||||
keyFile: "/test/sites/wildcard_.example.com/wildcard_.example.com.key",
|
||||
metaFile: "/test/sites/wildcard_.example.com/wildcard_.example.com.json",
|
||||
folder: filepath.Join("test", "sites", "wildcard_.example.com"),
|
||||
certFile: filepath.Join("test", "sites", "wildcard_.example.com", "wildcard_.example.com.crt"),
|
||||
keyFile: filepath.Join("test", "sites", "wildcard_.example.com", "wildcard_.example.com.key"),
|
||||
metaFile: filepath.Join("test", "sites", "wildcard_.example.com", "wildcard_.example.com.json"),
|
||||
},
|
||||
{
|
||||
// prevent directory traversal! very important, esp. with on-demand TLS
|
||||
// see issue #2092
|
||||
in: "a/../../../foo",
|
||||
folder: "/test/sites/afoo",
|
||||
certFile: "/test/sites/afoo/afoo.crt",
|
||||
keyFile: "/test/sites/afoo/afoo.key",
|
||||
metaFile: "/test/sites/afoo/afoo.json",
|
||||
folder: filepath.Join("test", "sites", "afoo"),
|
||||
certFile: filepath.Join("test", "sites", "afoo", "afoo.crt"),
|
||||
keyFile: filepath.Join("test", "sites", "afoo", "afoo.key"),
|
||||
metaFile: filepath.Join("test", "sites", "afoo", "afoo.json"),
|
||||
},
|
||||
{
|
||||
in: "b\\..\\..\\..\\foo",
|
||||
folder: filepath.Join("test", "sites", "bfoo"),
|
||||
certFile: filepath.Join("test", "sites", "bfoo", "bfoo.crt"),
|
||||
keyFile: filepath.Join("test", "sites", "bfoo", "bfoo.key"),
|
||||
metaFile: filepath.Join("test", "sites", "bfoo", "bfoo.json"),
|
||||
},
|
||||
{
|
||||
in: "c/foo",
|
||||
folder: filepath.Join("test", "sites", "cfoo"),
|
||||
certFile: filepath.Join("test", "sites", "cfoo", "cfoo.crt"),
|
||||
keyFile: filepath.Join("test", "sites", "cfoo", "cfoo.key"),
|
||||
metaFile: filepath.Join("test", "sites", "cfoo", "cfoo.json"),
|
||||
},
|
||||
} {
|
||||
if actual := fs.site(testcase.in); actual != testcase.folder {
|
||||
|
|
Loading…
Add table
Reference in a new issue