mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 17:44:49 +02:00
Add ban feature to fail2ban script (#2538)
This commit is contained in:
parent
9aaf15b38f
commit
de61d42e68
9 changed files with 105 additions and 30 deletions
|
@ -116,32 +116,41 @@ function teardown_file() {
|
|||
refute_output "${FAIL_AUTH_MAILER_IP}"
|
||||
}
|
||||
|
||||
#
|
||||
# debug
|
||||
#
|
||||
@test "checking fail2ban ban" {
|
||||
run docker exec mail_fail2ban fail2ban ban 192.0.66.7
|
||||
assert_success
|
||||
assert_output "Banned custom IP: 1"
|
||||
|
||||
@test "checking setup.sh: setup.sh debug fail2ban" {
|
||||
run docker exec mail_fail2ban fail2ban
|
||||
assert_success
|
||||
assert_output --regexp "Banned in custom:.*192\.0\.66\.7"
|
||||
|
||||
run docker exec mail_fail2ban fail2ban unban 192.0.66.7
|
||||
assert_success
|
||||
assert_output --partial "Unbanned IP from custom: 1"
|
||||
}
|
||||
|
||||
@test "checking setup.sh: setup.sh fail2ban" {
|
||||
|
||||
run docker exec mail_fail2ban /bin/sh -c "fail2ban-client set dovecot banip 192.0.66.4"
|
||||
run docker exec mail_fail2ban /bin/sh -c "fail2ban-client set dovecot banip 192.0.66.5"
|
||||
|
||||
sleep 10
|
||||
|
||||
run ./setup.sh -c mail_fail2ban debug fail2ban
|
||||
assert_output --partial 'Banned in dovecot:'
|
||||
assert_output --partial '192.0.66.5'
|
||||
assert_output --partial '192.0.66.4'
|
||||
run ./setup.sh -c mail_fail2ban fail2ban
|
||||
assert_output --regexp '^Banned in dovecot:.*192\.0\.66\.4'
|
||||
assert_output --regexp '^Banned in dovecot:.*192\.0\.66\.5'
|
||||
|
||||
run ./setup.sh -c mail_fail2ban debug fail2ban unban 192.0.66.4
|
||||
run ./setup.sh -c mail_fail2ban fail2ban unban 192.0.66.4
|
||||
assert_output --partial "Unbanned IP from dovecot: 1"
|
||||
|
||||
run ./setup.sh -c mail_fail2ban debug fail2ban
|
||||
assert_output --regexp "^Banned in dovecot:.*192.0.66.5.*"
|
||||
run ./setup.sh -c mail_fail2ban fail2ban
|
||||
assert_output --regexp "^Banned in dovecot:.*192\.0\.66\.5"
|
||||
|
||||
run ./setup.sh -c mail_fail2ban debug fail2ban unban 192.0.66.5
|
||||
run ./setup.sh -c mail_fail2ban fail2ban unban 192.0.66.5
|
||||
assert_output --partial "Unbanned IP from dovecot: 1"
|
||||
|
||||
run ./setup.sh -c mail_fail2ban debug fail2ban unban
|
||||
run ./setup.sh -c mail_fail2ban fail2ban unban
|
||||
assert_output --partial "You need to specify an IP address: Run"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue