From 4a837413970279f4024647ca8dbe79ceee639032 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sat, 21 Mar 2015 22:30:58 -0400 Subject: [PATCH] BF: do not expect setting logtarget to SYSLOG to work on non-Linuxes I have no BSD buildbots available for *BSDs etc, so can't speak for all, but http://nipy.bic.berkeley.edu/builders/fail2ban-py2.6-osx-10.6_master/builds/151/steps/shell_1/logs/stdio suggests that logically fails on OSX --- fail2ban/tests/servertestcase.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index 8c5e99a8..66825923 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -30,6 +30,7 @@ import tempfile import os import locale import sys +import platform from ..server.failregex import Regex, FailRegex, RegexException from ..server.server import Server @@ -70,7 +71,7 @@ class TransmitterBase(unittest.TestCase): """Call after every test case.""" self.server.quit() - def setGetTest(self, cmd, inValue, outValue=None, jail=None): + def setGetTest(self, cmd, inValue, outValue=None, outCode=0, jail=None): setCmd = ["set", cmd, inValue] getCmd = ["get", cmd] if jail is not None: @@ -79,8 +80,10 @@ class TransmitterBase(unittest.TestCase): if outValue is None: outValue = inValue - self.assertEqual(self.transm.proceed(setCmd), (0, outValue)) - self.assertEqual(self.transm.proceed(getCmd), (0, outValue)) + self.assertEqual(self.transm.proceed(setCmd), (outCode, outValue)) + if not outCode: + # if we expected to get it set without problem, check new value + self.assertEqual(self.transm.proceed(getCmd), (0, outValue)) def setGetTestNOK(self, cmd, inValue, jail=None): setCmd = ["set", cmd, inValue] @@ -787,7 +790,12 @@ class TransmitterLogging(TransmitterBase): self.setGetTestNOK("logtarget", "SYSLOG") # set back for other tests self.setGetTest("syslogsocket", "/dev/log") - self.setGetTest("logtarget", "SYSLOG") + self.setGetTest("logtarget", "SYSLOG", + **{True: {}, # should work on Linux + False: dict( # expect to fail otherwise + outCode=1, + outValue=Exception('Failed to change log target'))} + [platform.system() in ('Linux',)]) def testLogLevel(self): self.setGetTest("loglevel", "HEAVYDEBUG")