mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
Move TestIsUserPath to correct package
This commit is contained in:
committed by
Zlatko Čalušić
parent
cda126a99c
commit
69ed06aa66
@@ -71,24 +71,3 @@ func TestTLSSettings(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsUserPath(t *testing.T) {
|
||||
var tests = []struct {
|
||||
username string
|
||||
path string
|
||||
result bool
|
||||
}{
|
||||
{"foo", "/", false},
|
||||
{"foo", "/foo", true},
|
||||
{"foo", "/foo/", true},
|
||||
{"foo", "/foo/bar", true},
|
||||
{"foo", "/foobar", false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
result := isUserPath(test.username, test.path)
|
||||
if result != test.result {
|
||||
t.Errorf("isUserPath(%q, %q) was incorrect, got: %v, want: %v.", test.username, test.path, result, test.result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,3 +37,24 @@ func TestJoin(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsUserPath(t *testing.T) {
|
||||
var tests = []struct {
|
||||
username string
|
||||
path string
|
||||
result bool
|
||||
}{
|
||||
{"foo", "/", false},
|
||||
{"foo", "/foo", true},
|
||||
{"foo", "/foo/", true},
|
||||
{"foo", "/foo/bar", true},
|
||||
{"foo", "/foobar", false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
result := isUserPath(test.username, test.path)
|
||||
if result != test.result {
|
||||
t.Errorf("isUserPath(%q, %q) was incorrect, got: %v, want: %v.", test.username, test.path, result, test.result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user