mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
refactor custom actions
SFTPGo is now fully auditable, all fs and provider events that change something are notified and can be collected using hooks/plugins. There are some backward incompatible changes for command hooks
This commit is contained in:
@@ -420,7 +420,8 @@ func TestPluginsFromEnv(t *testing.T) {
|
||||
|
||||
os.Setenv("SFTPGO_PLUGINS__0__TYPE", "notifier")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__FS_EVENTS", "upload,download")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__USER_EVENTS", "add,update")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__PROVIDER_EVENTS", "add,update")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__PROVIDER_OBJECTS", "user,admin")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__RETRY_MAX_TIME", "2")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__RETRY_QUEUE_MAX_SIZE", "1000")
|
||||
os.Setenv("SFTPGO_PLUGINS__0__CMD", "plugin_start_cmd")
|
||||
@@ -432,7 +433,8 @@ func TestPluginsFromEnv(t *testing.T) {
|
||||
t.Cleanup(func() {
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__TYPE")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__FS_EVENTS")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__USER_EVENTS")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__PROVIDER_EVENTS")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__PROVIDER_OBJECTS")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__RETRY_MAX_TIME")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__NOTIFIER_OPTIONS__RETRY_QUEUE_MAX_SIZE")
|
||||
os.Unsetenv("SFTPGO_PLUGINS__0__CMD")
|
||||
@@ -453,9 +455,12 @@ func TestPluginsFromEnv(t *testing.T) {
|
||||
require.Len(t, pluginConf.NotifierOptions.FsEvents, 2)
|
||||
require.True(t, util.IsStringInSlice("upload", pluginConf.NotifierOptions.FsEvents))
|
||||
require.True(t, util.IsStringInSlice("download", pluginConf.NotifierOptions.FsEvents))
|
||||
require.Len(t, pluginConf.NotifierOptions.UserEvents, 2)
|
||||
require.Equal(t, "add", pluginConf.NotifierOptions.UserEvents[0])
|
||||
require.Equal(t, "update", pluginConf.NotifierOptions.UserEvents[1])
|
||||
require.Len(t, pluginConf.NotifierOptions.ProviderEvents, 2)
|
||||
require.Equal(t, "add", pluginConf.NotifierOptions.ProviderEvents[0])
|
||||
require.Equal(t, "update", pluginConf.NotifierOptions.ProviderEvents[1])
|
||||
require.Len(t, pluginConf.NotifierOptions.ProviderObjects, 2)
|
||||
require.Equal(t, "user", pluginConf.NotifierOptions.ProviderObjects[0])
|
||||
require.Equal(t, "admin", pluginConf.NotifierOptions.ProviderObjects[1])
|
||||
require.Equal(t, 2, pluginConf.NotifierOptions.RetryMaxTime)
|
||||
require.Equal(t, 1000, pluginConf.NotifierOptions.RetryQueueMaxSize)
|
||||
require.Equal(t, "plugin_start_cmd", pluginConf.Cmd)
|
||||
@@ -488,9 +493,12 @@ func TestPluginsFromEnv(t *testing.T) {
|
||||
require.Len(t, pluginConf.NotifierOptions.FsEvents, 2)
|
||||
require.True(t, util.IsStringInSlice("upload", pluginConf.NotifierOptions.FsEvents))
|
||||
require.True(t, util.IsStringInSlice("download", pluginConf.NotifierOptions.FsEvents))
|
||||
require.Len(t, pluginConf.NotifierOptions.UserEvents, 2)
|
||||
require.Equal(t, "add", pluginConf.NotifierOptions.UserEvents[0])
|
||||
require.Equal(t, "update", pluginConf.NotifierOptions.UserEvents[1])
|
||||
require.Len(t, pluginConf.NotifierOptions.ProviderEvents, 2)
|
||||
require.Equal(t, "add", pluginConf.NotifierOptions.ProviderEvents[0])
|
||||
require.Equal(t, "update", pluginConf.NotifierOptions.ProviderEvents[1])
|
||||
require.Len(t, pluginConf.NotifierOptions.ProviderObjects, 2)
|
||||
require.Equal(t, "user", pluginConf.NotifierOptions.ProviderObjects[0])
|
||||
require.Equal(t, "admin", pluginConf.NotifierOptions.ProviderObjects[1])
|
||||
require.Equal(t, 2, pluginConf.NotifierOptions.RetryMaxTime)
|
||||
require.Equal(t, 1000, pluginConf.NotifierOptions.RetryQueueMaxSize)
|
||||
require.Equal(t, "plugin_start_cmd1", pluginConf.Cmd)
|
||||
|
||||
Reference in New Issue
Block a user