diff --git a/cmd/rest-server/main_test.go b/cmd/rest-server/main_test.go index b2a71e1..44b06a2 100644 --- a/cmd/rest-server/main_test.go +++ b/cmd/rest-server/main_test.go @@ -71,3 +71,24 @@ 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) + } + } +}