Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
38e65e28
Commit
38e65e28
authored
Mar 28, 2018
by
Matt Holt
Committed by
GitHub
Mar 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: Fix tests on Windows (#2093)
parent
73b61af5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
14 deletions
+31
-14
caddytls/filestorage_test.go
caddytls/filestorage_test.go
+31
-14
No files found.
caddytls/filestorage_test.go
View file @
38e65e28
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment