2019-07-27 07:38:09 +00:00
|
|
|
package sftpd
|
|
|
|
|
|
|
|
import (
|
2019-07-27 19:19:30 +00:00
|
|
|
"runtime"
|
2019-07-27 07:38:09 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWrongActions(t *testing.T) {
|
|
|
|
actionsCopy := actions
|
2019-07-27 19:19:30 +00:00
|
|
|
badCommand := "/bad/command"
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
badCommand = "C:\\bad\\command"
|
|
|
|
}
|
2019-07-27 07:38:09 +00:00
|
|
|
actions = Actions{
|
|
|
|
ExecuteOn: []string{operationDownload},
|
2019-07-27 19:19:30 +00:00
|
|
|
Command: badCommand,
|
2019-07-27 07:38:09 +00:00
|
|
|
HTTPNotificationURL: "",
|
|
|
|
}
|
|
|
|
err := executeAction(operationDownload, "username", "path", "")
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("action with bad command must fail")
|
|
|
|
}
|
|
|
|
actions.Command = ""
|
|
|
|
actions.HTTPNotificationURL = "http://foo\x7f.com/"
|
|
|
|
err = executeAction(operationDownload, "username", "path", "")
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("action with bad url must fail")
|
|
|
|
}
|
|
|
|
actions = actionsCopy
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRemoveNonexistentTransfer(t *testing.T) {
|
|
|
|
transfer := Transfer{}
|
|
|
|
err := removeTransfer(&transfer)
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("remove nonexistent transfer must fail")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRemoveNonexistentQuotaScan(t *testing.T) {
|
|
|
|
err := RemoveQuotaScan("username")
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("remove nonexistent transfer must fail")
|
|
|
|
}
|
|
|
|
}
|