mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
add a basic web interface
The builtin web interface allows to manage users and connections
This commit is contained in:
@@ -21,9 +21,9 @@ import (
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"github.com/drakkan/sftpgo/api"
|
||||
"github.com/drakkan/sftpgo/config"
|
||||
"github.com/drakkan/sftpgo/dataprovider"
|
||||
"github.com/drakkan/sftpgo/httpd"
|
||||
"github.com/drakkan/sftpgo/logger"
|
||||
"github.com/drakkan/sftpgo/sftpd"
|
||||
"github.com/pkg/sftp"
|
||||
@@ -103,7 +103,6 @@ func TestMain(m *testing.M) {
|
||||
dataProvider := dataprovider.GetProvider()
|
||||
sftpdConf := config.GetSFTPDConfig()
|
||||
httpdConf := config.GetHTTPDConfig()
|
||||
router := api.GetHTTPRouter()
|
||||
sftpdConf.BindPort = 2022
|
||||
sftpdConf.KexAlgorithms = []string{"curve25519-sha256@libssh.org", "ecdh-sha2-nistp256",
|
||||
"ecdh-sha2-nistp384"}
|
||||
@@ -137,7 +136,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
sftpd.SetDataProvider(dataProvider)
|
||||
api.SetDataProvider(dataProvider)
|
||||
httpd.SetDataProvider(dataProvider)
|
||||
|
||||
scpPath, err = exec.LookPath("scp")
|
||||
if err != nil {
|
||||
@@ -154,15 +153,7 @@ func TestMain(m *testing.M) {
|
||||
}()
|
||||
|
||||
go func() {
|
||||
logger.Debug(logSender, "", "initializing HTTP server with config %+v", httpdConf)
|
||||
s := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", httpdConf.BindAddress, httpdConf.BindPort),
|
||||
Handler: router,
|
||||
ReadTimeout: 300 * time.Second,
|
||||
WriteTimeout: 300 * time.Second,
|
||||
MaxHeaderBytes: 1 << 20, // 1MB
|
||||
}
|
||||
if err := s.ListenAndServe(); err != nil {
|
||||
if err := httpdConf.Initialize(configDir); err != nil {
|
||||
logger.Error(logSender, "", "could not start HTTP server: %v", err)
|
||||
}
|
||||
}()
|
||||
@@ -192,7 +183,7 @@ func TestBasicSFTPHandling(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.QuotaSize = 6553600
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -219,7 +210,7 @@ func TestBasicSFTPHandling(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("file download error: %v", err)
|
||||
}
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -237,7 +228,7 @@ func TestBasicSFTPHandling(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("stat for deleted file must not succeed")
|
||||
}
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -248,7 +239,7 @@ func TestBasicSFTPHandling(t *testing.T) {
|
||||
t.Errorf("quota size does not match, expected: %v, actual: %v", expectedQuotaSize-testFileSize, user.UsedQuotaSize)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -257,7 +248,7 @@ func TestBasicSFTPHandling(t *testing.T) {
|
||||
|
||||
func TestDirCommands(t *testing.T) {
|
||||
usePubKey := false
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -318,7 +309,7 @@ func TestDirCommands(t *testing.T) {
|
||||
t.Errorf("remove missing path must fail")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -327,7 +318,7 @@ func TestDirCommands(t *testing.T) {
|
||||
|
||||
func TestLink(t *testing.T) {
|
||||
usePubKey := false
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -372,7 +363,7 @@ func TestLink(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -381,7 +372,7 @@ func TestLink(t *testing.T) {
|
||||
|
||||
func TestStat(t *testing.T) {
|
||||
usePubKey := false
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -429,7 +420,7 @@ func TestStat(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -439,7 +430,7 @@ func TestStat(t *testing.T) {
|
||||
// basic tests to verify virtual chroot, should be improved to cover more cases ...
|
||||
func TestEscapeHomeDir(t *testing.T) {
|
||||
usePubKey := true
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -502,7 +493,7 @@ func TestEscapeHomeDir(t *testing.T) {
|
||||
}
|
||||
os.Remove(linkPath)
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -513,7 +504,7 @@ func TestHomeSpecialChars(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.HomeDir = filepath.Join(homeBasePath, "abc açà#&%lk")
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -549,7 +540,7 @@ func TestHomeSpecialChars(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -559,7 +550,7 @@ func TestHomeSpecialChars(t *testing.T) {
|
||||
func TestLogin(t *testing.T) {
|
||||
u := getTestUser(false)
|
||||
u.PublicKeys = []string{testPubKey}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -592,7 +583,7 @@ func TestLogin(t *testing.T) {
|
||||
// testPubKey1 is not authorized
|
||||
user.PublicKeys = []string{testPubKey1}
|
||||
user.Password = ""
|
||||
_, _, err = api.UpdateUser(user, http.StatusOK)
|
||||
_, _, err = httpd.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to update user: %v", err)
|
||||
}
|
||||
@@ -604,7 +595,7 @@ func TestLogin(t *testing.T) {
|
||||
// login a user with multiple public keys, only the second one is valid
|
||||
user.PublicKeys = []string{testPubKey1, testPubKey}
|
||||
user.Password = ""
|
||||
_, _, err = api.UpdateUser(user, http.StatusOK)
|
||||
_, _, err = httpd.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to update user: %v", err)
|
||||
}
|
||||
@@ -618,7 +609,7 @@ func TestLogin(t *testing.T) {
|
||||
t.Errorf("sftp client with multiple public key must work if at least one public key is valid")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -627,14 +618,14 @@ func TestLogin(t *testing.T) {
|
||||
|
||||
func TestLoginAfterUserUpdateEmptyPwd(t *testing.T) {
|
||||
usePubKey := false
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
user.Password = ""
|
||||
user.PublicKeys = []string{}
|
||||
// password and public key should remain unchanged
|
||||
_, _, err = api.UpdateUser(user, http.StatusOK)
|
||||
_, _, err = httpd.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to update user: %v", err)
|
||||
}
|
||||
@@ -652,7 +643,7 @@ func TestLoginAfterUserUpdateEmptyPwd(t *testing.T) {
|
||||
t.Errorf("unable to read remote dir: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -661,14 +652,14 @@ func TestLoginAfterUserUpdateEmptyPwd(t *testing.T) {
|
||||
|
||||
func TestLoginAfterUserUpdateEmptyPubKey(t *testing.T) {
|
||||
usePubKey := true
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
user.Password = ""
|
||||
user.PublicKeys = []string{}
|
||||
// password and public key should remain unchanged
|
||||
_, _, err = api.UpdateUser(user, http.StatusOK)
|
||||
_, _, err = httpd.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to update user: %v", err)
|
||||
}
|
||||
@@ -686,7 +677,7 @@ func TestLoginAfterUserUpdateEmptyPubKey(t *testing.T) {
|
||||
t.Errorf("unable to read remote dir: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -697,7 +688,7 @@ func TestMaxSessions(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.MaxSessions = 1
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -719,7 +710,7 @@ func TestMaxSessions(t *testing.T) {
|
||||
t.Errorf("max sessions exceeded, new login should not succeed")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -730,10 +721,11 @@ func TestQuotaFileReplace(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.QuotaFiles = 1000
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
os.RemoveAll(user.GetHomeDir())
|
||||
testFileSize := int64(65535)
|
||||
testFileName := "test_file.dat"
|
||||
testFilePath := filepath.Join(homeBasePath, testFileName)
|
||||
@@ -752,7 +744,7 @@ func TestQuotaFileReplace(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("file upload error: %v", err)
|
||||
}
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -761,7 +753,7 @@ func TestQuotaFileReplace(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("file upload error: %v", err)
|
||||
}
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -774,7 +766,7 @@ func TestQuotaFileReplace(t *testing.T) {
|
||||
}
|
||||
// now set a quota size restriction and upload the same fail, upload should fail for space limit exceeded
|
||||
user.QuotaSize = testFileSize - 1
|
||||
user, _, err = api.UpdateUser(user, http.StatusOK)
|
||||
user, _, err = httpd.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error updating user: %v", err)
|
||||
}
|
||||
@@ -791,7 +783,7 @@ func TestQuotaFileReplace(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -800,7 +792,7 @@ func TestQuotaFileReplace(t *testing.T) {
|
||||
|
||||
func TestQuotaScan(t *testing.T) {
|
||||
usePubKey := false
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -823,31 +815,31 @@ func TestQuotaScan(t *testing.T) {
|
||||
t.Errorf("file upload error: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
// create user with the same home dir, so there is at least an untracked file
|
||||
user, _, err = api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err = httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
_, err = api.StartQuotaScan(user, http.StatusCreated)
|
||||
_, err = httpd.StartQuotaScan(user, http.StatusCreated)
|
||||
if err != nil {
|
||||
t.Errorf("error starting quota scan: %v", err)
|
||||
}
|
||||
scans, _, err := api.GetQuotaScans(http.StatusOK)
|
||||
scans, _, err := httpd.GetQuotaScans(http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting active quota scans: %v", err)
|
||||
}
|
||||
for len(scans) > 0 {
|
||||
scans, _, err = api.GetQuotaScans(http.StatusOK)
|
||||
scans, _, err = httpd.GetQuotaScans(http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting active quota scans: %v", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -857,7 +849,7 @@ func TestQuotaScan(t *testing.T) {
|
||||
if expectedQuotaSize != user.UsedQuotaSize {
|
||||
t.Errorf("quota size does not match after scan, expected: %v, actual: %v", expectedQuotaSize, user.UsedQuotaSize)
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -880,7 +872,7 @@ func TestQuotaSize(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.QuotaFiles = 1
|
||||
u.QuotaSize = testFileSize - 1
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -908,7 +900,7 @@ func TestQuotaSize(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -926,7 +918,7 @@ func TestBandwidthAndConnections(t *testing.T) {
|
||||
// 100 ms tolerance
|
||||
wantedUploadElapsed -= 100
|
||||
wantedDownloadElapsed -= 100
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -980,7 +972,7 @@ func TestBandwidthAndConnections(t *testing.T) {
|
||||
t.Errorf("connection closed upload must fail")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -990,7 +982,7 @@ func TestBandwidthAndConnections(t *testing.T) {
|
||||
func TestMissingFile(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1005,7 +997,7 @@ func TestMissingFile(t *testing.T) {
|
||||
t.Errorf("download missing file must fail")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1015,7 +1007,7 @@ func TestMissingFile(t *testing.T) {
|
||||
func TestOverwriteDirWithFile(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1057,7 +1049,7 @@ func TestOverwriteDirWithFile(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1070,7 +1062,7 @@ func TestPasswordsHashPbkdf2Sha1(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.Password = pbkdf2Pwd
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1090,7 +1082,7 @@ func TestPasswordsHashPbkdf2Sha1(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("login with wrong password must fail")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1103,7 +1095,7 @@ func TestPasswordsHashPbkdf2Sha256(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.Password = pbkdf2Pwd
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1123,7 +1115,7 @@ func TestPasswordsHashPbkdf2Sha256(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("login with wrong password must fail")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1136,7 +1128,7 @@ func TestPasswordsHashPbkdf2Sha512(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.Password = pbkdf2Pwd
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1156,7 +1148,7 @@ func TestPasswordsHashPbkdf2Sha512(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("login with wrong password must fail")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1169,7 +1161,7 @@ func TestPasswordsHashBcrypt(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.Password = bcryptPwd
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1189,7 +1181,7 @@ func TestPasswordsHashBcrypt(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("login with wrong password must fail")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1202,7 +1194,7 @@ func TestPasswordsHashSHA512Crypt(t *testing.T) {
|
||||
usePubKey := false
|
||||
u := getTestUser(usePubKey)
|
||||
u.Password = sha512CryptPwd
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1222,7 +1214,7 @@ func TestPasswordsHashSHA512Crypt(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("login with wrong password must fail")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1234,7 +1226,7 @@ func TestPermList(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermDownload, dataprovider.PermUpload, dataprovider.PermDelete, dataprovider.PermRename,
|
||||
dataprovider.PermCreateDirs, dataprovider.PermCreateSymlinks, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1252,7 +1244,7 @@ func TestPermList(t *testing.T) {
|
||||
t.Errorf("stat remote file without permission should not succeed")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1264,7 +1256,7 @@ func TestPermDownload(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermUpload, dataprovider.PermDelete, dataprovider.PermRename,
|
||||
dataprovider.PermCreateDirs, dataprovider.PermCreateSymlinks, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1294,7 +1286,7 @@ func TestPermDownload(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1306,7 +1298,7 @@ func TestPermUpload(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermDownload, dataprovider.PermDelete, dataprovider.PermRename,
|
||||
dataprovider.PermCreateDirs, dataprovider.PermCreateSymlinks, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1327,7 +1319,7 @@ func TestPermUpload(t *testing.T) {
|
||||
t.Errorf("file upload without permission should not succeed")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1339,7 +1331,7 @@ func TestPermOverwrite(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermDownload, dataprovider.PermUpload, dataprovider.PermDelete,
|
||||
dataprovider.PermRename, dataprovider.PermCreateDirs, dataprovider.PermCreateSymlinks}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1364,7 +1356,7 @@ func TestPermOverwrite(t *testing.T) {
|
||||
t.Errorf("file overwrite without permission should not succeed")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1376,7 +1368,7 @@ func TestPermDelete(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermDownload, dataprovider.PermUpload, dataprovider.PermRename,
|
||||
dataprovider.PermCreateDirs, dataprovider.PermCreateSymlinks, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1401,7 +1393,7 @@ func TestPermDelete(t *testing.T) {
|
||||
t.Errorf("delete without permission should not succeed")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1413,7 +1405,7 @@ func TestPermRename(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermDownload, dataprovider.PermUpload, dataprovider.PermDelete,
|
||||
dataprovider.PermCreateDirs, dataprovider.PermCreateSymlinks, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1442,7 +1434,7 @@ func TestPermRename(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1454,7 +1446,7 @@ func TestPermCreateDirs(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermDownload, dataprovider.PermUpload, dataprovider.PermDelete,
|
||||
dataprovider.PermRename, dataprovider.PermCreateSymlinks, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1479,7 +1471,7 @@ func TestPermCreateDirs(t *testing.T) {
|
||||
t.Errorf("mkdir without permission should not succeed")
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1491,7 +1483,7 @@ func TestPermSymlink(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermListItems, dataprovider.PermDownload, dataprovider.PermUpload, dataprovider.PermDelete,
|
||||
dataprovider.PermRename, dataprovider.PermCreateDirs, dataprovider.PermOverwrite}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1520,7 +1512,7 @@ func TestPermSymlink(t *testing.T) {
|
||||
t.Errorf("error removing uploaded file: %v", err)
|
||||
}
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1529,7 +1521,7 @@ func TestPermSymlink(t *testing.T) {
|
||||
|
||||
func TestSSHConnection(t *testing.T) {
|
||||
usePubKey := false
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1537,7 +1529,7 @@ func TestSSHConnection(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("ssh connection must fail: %v", err)
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1551,7 +1543,7 @@ func TestSCPBasicHandling(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.QuotaSize = 6553600
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1589,7 +1581,7 @@ func TestSCPBasicHandling(t *testing.T) {
|
||||
}
|
||||
}
|
||||
os.Remove(localPath)
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -1603,7 +1595,7 @@ func TestSCPBasicHandling(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1616,7 +1608,7 @@ func TestSCPUploadFileOverwrite(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.QuotaFiles = 1000
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1638,7 +1630,7 @@ func TestSCPUploadFileOverwrite(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error uploading existing file via scp: %v", err)
|
||||
}
|
||||
user, _, err = api.GetUserByID(user.ID, http.StatusOK)
|
||||
user, _, err = httpd.GetUserByID(user.ID, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("error getting user: %v", err)
|
||||
}
|
||||
@@ -1665,7 +1657,7 @@ func TestSCPUploadFileOverwrite(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1677,7 +1669,7 @@ func TestSCPRecursive(t *testing.T) {
|
||||
}
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1739,7 +1731,7 @@ func TestSCPRecursive(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1752,7 +1744,7 @@ func TestSCPPermCreateDirs(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermDownload, dataprovider.PermUpload}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1788,7 +1780,7 @@ func TestSCPPermCreateDirs(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1801,7 +1793,7 @@ func TestSCPPermUpload(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermDownload, dataprovider.PermCreateDirs}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1825,7 +1817,7 @@ func TestSCPPermUpload(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1838,7 +1830,7 @@ func TestSCPPermOverwrite(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermUpload, dataprovider.PermCreateDirs}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1866,7 +1858,7 @@ func TestSCPPermOverwrite(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1879,7 +1871,7 @@ func TestSCPPermDownload(t *testing.T) {
|
||||
usePubKey := true
|
||||
u := getTestUser(usePubKey)
|
||||
u.Permissions = []string{dataprovider.PermUpload, dataprovider.PermCreateDirs}
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1909,7 +1901,7 @@ func TestSCPPermDownload(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1924,7 +1916,7 @@ func TestSCPQuotaSize(t *testing.T) {
|
||||
u := getTestUser(usePubKey)
|
||||
u.QuotaFiles = 1
|
||||
u.QuotaSize = testFileSize - 1
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -1951,7 +1943,7 @@ func TestSCPQuotaSize(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -1962,7 +1954,7 @@ func TestSCPEscapeHomeDir(t *testing.T) {
|
||||
t.Skip("scp command not found, unable to execute this test")
|
||||
}
|
||||
usePubKey := true
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -2004,7 +1996,7 @@ func TestSCPEscapeHomeDir(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -2015,7 +2007,7 @@ func TestSCPUploadPaths(t *testing.T) {
|
||||
t.Skip("scp command not found, unable to execute this test")
|
||||
}
|
||||
usePubKey := true
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -2050,7 +2042,7 @@ func TestSCPUploadPaths(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -2061,7 +2053,7 @@ func TestSCPOverwriteDirWithFile(t *testing.T) {
|
||||
t.Skip("scp command not found, unable to execute this test")
|
||||
}
|
||||
usePubKey := true
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -2083,7 +2075,7 @@ func TestSCPOverwriteDirWithFile(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -2094,14 +2086,14 @@ func TestSCPRemoteToRemote(t *testing.T) {
|
||||
t.Skip("scp command not found, unable to execute this test")
|
||||
}
|
||||
usePubKey := true
|
||||
user, _, err := api.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
user, _, err := httpd.AddUser(getTestUser(usePubKey), http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
u := getTestUser(usePubKey)
|
||||
u.Username += "1"
|
||||
u.HomeDir += "1"
|
||||
user1, _, err := api.AddUser(u, http.StatusOK)
|
||||
user1, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -2126,7 +2118,7 @@ func TestSCPRemoteToRemote(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
@@ -2134,7 +2126,7 @@ func TestSCPRemoteToRemote(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files for user1")
|
||||
}
|
||||
_, err = api.RemoveUser(user1, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user1, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user1: %v", err)
|
||||
}
|
||||
@@ -2145,7 +2137,7 @@ func TestSCPErrors(t *testing.T) {
|
||||
t.Skip("scp command not found, unable to execute this test")
|
||||
}
|
||||
u := getTestUser(true)
|
||||
user, _, err := api.AddUser(u, http.StatusOK)
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to add user: %v", err)
|
||||
}
|
||||
@@ -2165,7 +2157,7 @@ func TestSCPErrors(t *testing.T) {
|
||||
}
|
||||
user.UploadBandwidth = 512
|
||||
user.DownloadBandwidth = 512
|
||||
_, _, err = api.UpdateUser(user, http.StatusOK)
|
||||
_, _, err = httpd.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to update user: %v", err)
|
||||
}
|
||||
@@ -2201,7 +2193,7 @@ func TestSCPErrors(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("error removing uploaded files")
|
||||
}
|
||||
_, err = api.RemoveUser(user, http.StatusOK)
|
||||
_, err = httpd.RemoveUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to remove user: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user