makes test case more precise;

pull/975/head
sebres 2015-02-25 12:38:09 +01:00
parent 6c788a32ee
commit 2bfe22aa66
2 changed files with 8 additions and 4 deletions

View File

@ -38,8 +38,8 @@ ver. 0.9.2 (2014/XX/XXX) - wanna-be-released
system authentication issues system authentication issues
* fail2ban-regex reads filter file(s) completely, incl. '.local' file etc. (gh-954) * fail2ban-regex reads filter file(s) completely, incl. '.local' file etc. (gh-954)
* firewallcmd-* actions: split output into separate lines for grepping (gh-908) * firewallcmd-* actions: split output into separate lines for grepping (gh-908)
* binding parameter error (unsupported type) by writing json with invalid encoded * Guard unicode encode/decode issues while storing records in the database.
lines into sqlite database (gh-973), thanks to kot for issue reporting; Fixes "binding parameter error (unsupported type)" (gh-973), thanks to kot for reporting
- New Features: - New Features:
- New filters: - New filters:

View File

@ -181,12 +181,16 @@ class DatabaseTest(LogCaptureTestCase):
if Fail2BanDb is None: # pragma: no cover if Fail2BanDb is None: # pragma: no cover
return return
self.testAddJail() self.testAddJail()
ticket = FailTicket("127.0.0.1", 0, {'m': ['... user "\xd1\xe2\xe5\xf2\xe0" ...'], 'a': 1}) ticket = FailTicket("127.0.0.1", 0, ['... user "\xd1\xe2\xe5\xf2\xe0" ...'])
self.db.addBan(self.jail, ticket) self.db.addBan(self.jail, ticket)
self.assertEqual(len(self.db.getBans(jail=self.jail)), 1) self.assertEqual(len(self.db.getBans(jail=self.jail)), 1)
readticket = self.db.getBans(jail=self.jail)[0]
## python 2 or 3 :
self.assertTrue( self.assertTrue(
isinstance(self.db.getBans(jail=self.jail)[0], FailTicket)) readticket == FailTicket("127.0.0.1", 0, [u'... user "\ufffd\ufffd\ufffd\ufffd\ufffd" ...'])
or readticket == ticket
)
def testDelBan(self): def testDelBan(self):
self.testAddBan() self.testAddBan()