sftpd: minor improvements and docs for the prefix middleware

This commit is contained in:
Nicola Murino
2021-07-29 20:12:23 +02:00
parent 4781921336
commit f778e47d22
6 changed files with 168 additions and 41 deletions

View File

@@ -2061,3 +2061,26 @@ func newFakeListener(err error) net.Listener {
err: err,
}
}
func TestFolderPrefix(t *testing.T) {
c := Configuration{
FolderPrefix: "files",
}
c.checkFolderPrefix()
assert.Equal(t, "/files", c.FolderPrefix)
c.FolderPrefix = ""
c.checkFolderPrefix()
assert.Empty(t, c.FolderPrefix)
c.FolderPrefix = "/"
c.checkFolderPrefix()
assert.Empty(t, c.FolderPrefix)
c.FolderPrefix = "/."
c.checkFolderPrefix()
assert.Empty(t, c.FolderPrefix)
c.FolderPrefix = "."
c.checkFolderPrefix()
assert.Empty(t, c.FolderPrefix)
c.FolderPrefix = ".."
c.checkFolderPrefix()
assert.Empty(t, c.FolderPrefix)
}