add support for custom actions

Configurable custom commands and/or HTTP notifications on SFTP upload, download, delete or rename
This commit is contained in:
Nicola Murino
2019-07-27 09:38:09 +02:00
parent 70ae68a7c4
commit 48451a9924
12 changed files with 219 additions and 69 deletions

40
sftpd/internal_test.go Normal file
View File

@@ -0,0 +1,40 @@
package sftpd
import (
"testing"
)
func TestWrongActions(t *testing.T) {
actionsCopy := actions
actions = Actions{
ExecuteOn: []string{operationDownload},
Command: "/bad/command",
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")
}
}