mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
Fixed sporadic tab-replacement (\n\t instead of \n by word wrapping) in mime content of smtp-message in test cases, see
https://github.com/fail2ban/fail2ban/pull/1410#issuecomment-262000804
This commit is contained in:
parent
44fddc102d
commit
261f875748
1 changed files with 7 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ import os
|
|||
import smtpd
|
||||
import threading
|
||||
import unittest
|
||||
import re
|
||||
import sys
|
||||
if sys.version_info >= (3, 3):
|
||||
import importlib
|
||||
|
|
@ -38,7 +39,9 @@ class TestSMTPServer(smtpd.SMTPServer):
|
|||
self.peer = peer
|
||||
self.mailfrom = mailfrom
|
||||
self.rcpttos = rcpttos
|
||||
self.data = data
|
||||
self.org_data = data
|
||||
# replace new line (with tab or space) for possible mime translations (word wrap):
|
||||
self.data = re.sub(r"\n[\t ]", " ", data)
|
||||
|
||||
|
||||
class SMTPActionTest(unittest.TestCase):
|
||||
|
|
@ -104,9 +107,9 @@ class SMTPActionTest(unittest.TestCase):
|
|||
self.assertEqual(self.smtpd.rcpttos, ["root"])
|
||||
subject = "Subject: [Fail2Ban] %s: banned %s" % (
|
||||
self.jail.name, aInfo['ip'])
|
||||
self.assertIn(subject, self.smtpd.data.replace("\n", ""))
|
||||
self.assertTrue(
|
||||
"%i attempts" % aInfo['failures'] in self.smtpd.data)
|
||||
self.assertIn(subject, self.smtpd.data)
|
||||
self.assertIn(
|
||||
"%i attempts" % aInfo['failures'], self.smtpd.data)
|
||||
|
||||
self.action.matches = "matches"
|
||||
self.action.ban(aInfo)
|
||||
|
|
|
|||
Loading…
Reference in a new issue