Fix fail2ban by removal of internal timer logic (#19456)
* Remove timer logic from sensor class Proposed fix for issue #10500 * Updating the tests to remove timer logic * Removing unecessary dependancy * Fixing requested changes * Commit to try to fix the CLA ?
This commit is contained in:
1 parent
4bdb21a871
commit
1099018a5e
2 files changed
+12
-25
No files matched your search
@@ -2,7 +2,6 @@
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from datetime import timedelta
|
||||
from mock_open import MockOpen
|
||||
|
||||
from homeassistant.setup import setup_component
|
||||
@@ -99,7 +98,7 @@ class TestBanSensor(unittest.TestCase):
|
||||
|
||||
def test_single_ban(self):
|
||||
"""Test that log is parsed correctly for single ban."""
|
||||
log_parser = BanLogParser(timedelta(seconds=-1), '/tmp')
|
||||
log_parser = BanLogParser('/tmp')
|
||||
sensor = BanSensor('fail2ban', 'jail_one', log_parser)
|
||||
assert sensor.name == 'fail2ban jail_one'
|
||||
mock_fh = MockOpen(read_data=fake_log('single_ban'))
|
||||
@@ -115,7 +114,7 @@ class TestBanSensor(unittest.TestCase):
|
||||
|
||||
def test_multiple_ban(self):
|
||||
"""Test that log is parsed correctly for multiple ban."""
|
||||
log_parser = BanLogParser(timedelta(seconds=-1), '/tmp')
|
||||
log_parser = BanLogParser('/tmp')
|
||||
sensor = BanSensor('fail2ban', 'jail_one', log_parser)
|
||||
assert sensor.name == 'fail2ban jail_one'
|
||||
mock_fh = MockOpen(read_data=fake_log('multi_ban'))
|
||||
@@ -131,7 +130,7 @@ class TestBanSensor(unittest.TestCase):
|
||||
|
||||
def test_unban_all(self):
|
||||
"""Test that log is parsed correctly when unbanning."""
|
||||
log_parser = BanLogParser(timedelta(seconds=-1), '/tmp')
|
||||
log_parser = BanLogParser('/tmp')
|
||||
sensor = BanSensor('fail2ban', 'jail_one', log_parser)
|
||||
assert sensor.name == 'fail2ban jail_one'
|
||||
mock_fh = MockOpen(read_data=fake_log('unban_all'))
|
||||
@@ -146,7 +145,7 @@ class TestBanSensor(unittest.TestCase):
|
||||
|
||||
def test_unban_one(self):
|
||||
"""Test that log is parsed correctly when unbanning one ip."""
|
||||
log_parser = BanLogParser(timedelta(seconds=-1), '/tmp')
|
||||
log_parser = BanLogParser('/tmp')
|
||||
sensor = BanSensor('fail2ban', 'jail_one', log_parser)
|
||||
assert sensor.name == 'fail2ban jail_one'
|
||||
mock_fh = MockOpen(read_data=fake_log('unban_one'))
|
||||
@@ -162,7 +161,7 @@ class TestBanSensor(unittest.TestCase):
|
||||
|
||||
def test_multi_jail(self):
|
||||
"""Test that log is parsed correctly when using multiple jails."""
|
||||
log_parser = BanLogParser(timedelta(seconds=-1), '/tmp')
|
||||
log_parser = BanLogParser('/tmp')
|
||||
sensor1 = BanSensor('fail2ban', 'jail_one', log_parser)
|
||||
sensor2 = BanSensor('fail2ban', 'jail_two', log_parser)
|
||||
assert sensor1.name == 'fail2ban jail_one'
|
||||
@@ -184,7 +183,7 @@ class TestBanSensor(unittest.TestCase):
|
||||
|
||||
def test_ban_active_after_update(self):
|
||||
"""Test that ban persists after subsequent update."""
|
||||
log_parser = BanLogParser(timedelta(seconds=-1), '/tmp')
|
||||
log_parser = BanLogParser('/tmp')
|
||||
sensor = BanSensor('fail2ban', 'jail_one', log_parser)
|
||||
assert sensor.name == 'fail2ban jail_one'
|
||||
mock_fh = MockOpen(read_data=fake_log('single_ban'))
|
||||
|
||||
Reference in new issue
Block a user