mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 09:00:27 +00:00
add a test case for listing files with long names
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
3efcd94e14
commit
356795f8b0
1 changed files with 29 additions and 0 deletions
|
@ -23,6 +23,7 @@ import (
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -782,6 +783,34 @@ func TestSFTPFsEscapeHomeDir(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadDirLongNames(t *testing.T) {
|
||||||
|
usePubKey := true
|
||||||
|
user, _, err := httpdtest.AddUser(getTestUser(usePubKey), http.StatusCreated)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
conn, client, err := getSftpClient(user, usePubKey)
|
||||||
|
if assert.NoError(t, err) {
|
||||||
|
defer conn.Close()
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
numFiles := 1000
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
fPath := filepath.Join(user.GetHomeDir(), hex.EncodeToString(util.GenerateRandomBytes(127)))
|
||||||
|
err = os.WriteFile(fPath, util.GenerateRandomBytes(30), 0666)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
entries, err := client.ReadDir("/")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Len(t, entries, numFiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = httpdtest.RemoveUser(user, http.StatusOK)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
err = os.RemoveAll(user.GetHomeDir())
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestGroupSettingsOverride(t *testing.T) {
|
func TestGroupSettingsOverride(t *testing.T) {
|
||||||
usePubKey := true
|
usePubKey := true
|
||||||
g := getTestGroup()
|
g := getTestGroup()
|
||||||
|
|
Loading…
Reference in a new issue