mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
add support for custom actions
Configurable custom commands and/or HTTP notifications on SFTP upload, download, delete or rename
This commit is contained in:
40
sftpd/internal_test.go
Normal file
40
sftpd/internal_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user