mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
EventManager: add IDP login trigger and check account action
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -1596,6 +1596,9 @@ func checkEventAction(expected, actual dataprovider.BaseEventAction) error {
|
||||
if expected.Options.PwdExpirationConfig.Threshold != actual.Options.PwdExpirationConfig.Threshold {
|
||||
return errors.New("password expiration threshold mismatch")
|
||||
}
|
||||
if err := compareEventActionIDPConfigFields(expected.Options.IDPConfig, actual.Options.IDPConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := compareEventActionCmdConfigFields(expected.Options.CmdConfig, actual.Options.CmdConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1707,6 +1710,9 @@ func checkEventConditions(expected, actual dataprovider.EventConditions) error {
|
||||
if err := checkEventConditionOptions(expected.Options, actual.Options); err != nil {
|
||||
return err
|
||||
}
|
||||
if expected.IDPLoginEvent != actual.IDPLoginEvent {
|
||||
return errors.New("IDP login event mismatch")
|
||||
}
|
||||
|
||||
return checkEventSchedules(expected.Schedules, actual.Schedules)
|
||||
}
|
||||
@@ -2707,6 +2713,19 @@ func compareEventActionFsConfigFields(expected, actual dataprovider.EventActionF
|
||||
return compareEventActionFsCompressFields(expected.Compress, actual.Compress)
|
||||
}
|
||||
|
||||
func compareEventActionIDPConfigFields(expected, actual dataprovider.EventActionIDPAccountCheck) error {
|
||||
if expected.Mode != actual.Mode {
|
||||
return errors.New("mode mismatch")
|
||||
}
|
||||
if expected.TemplateAdmin != actual.TemplateAdmin {
|
||||
return errors.New("admin template mismatch")
|
||||
}
|
||||
if expected.TemplateUser != actual.TemplateUser {
|
||||
return errors.New("user template mismatch")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func compareEventActionCmdConfigFields(expected, actual dataprovider.EventActionCommandConfig) error {
|
||||
if expected.Cmd != actual.Cmd {
|
||||
return errors.New("command mismatch")
|
||||
|
||||
Reference in New Issue
Block a user