mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 23:28:39 +03:00
defender: allow to impose a delay between login attempts
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -419,6 +419,9 @@ func TestDefenderIntegration(t *testing.T) {
|
||||
ObservationTime: 15,
|
||||
EntriesSoftLimit: 100,
|
||||
EntriesHardLimit: 150,
|
||||
LoginDelay: LoginDelay{
|
||||
PasswordFailed: 200,
|
||||
},
|
||||
}
|
||||
err = Initialize(Config, 0)
|
||||
// ScoreInvalid cannot be greater than threshold
|
||||
@@ -477,6 +480,16 @@ func TestDefenderIntegration(t *testing.T) {
|
||||
assert.Nil(t, banTime)
|
||||
assert.False(t, DeleteDefenderHost(ip))
|
||||
|
||||
startTime := time.Now()
|
||||
DelayLogin(nil)
|
||||
elapsed := time.Since(startTime)
|
||||
assert.Less(t, elapsed, time.Millisecond*50)
|
||||
|
||||
startTime = time.Now()
|
||||
DelayLogin(ErrInternalFailure)
|
||||
elapsed = time.Since(startTime)
|
||||
assert.Greater(t, elapsed, time.Millisecond*150)
|
||||
|
||||
Config = configCopy
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user