TST: test for filter coverage in jail.conf

pull/569/head
Daniel Black 2014-01-07 10:00:08 +11:00
parent bc5809ead0
commit 51d4263358
3 changed files with 24 additions and 0 deletions

View File

@ -46,6 +46,11 @@ class JailReader(ConfigReader):
self.__filter = None self.__filter = None
self.__force_enable = force_enable self.__force_enable = force_enable
self.__actions = list() self.__actions = list()
self.__opts = None
@property
def options(self):
return self.__opts
def setName(self, value): def setName(self, value):
self.__name = value self.__name = value

View File

@ -46,6 +46,10 @@ class JailsReader(ConfigReader):
self.__jails = list() self.__jails = list()
self.__force_enable = force_enable self.__force_enable = force_enable
@property
def jails(self):
return self.__jails
def read(self): def read(self):
return ConfigReader.read(self, "jail") return ConfigReader.read(self, "jail")

View File

@ -483,6 +483,21 @@ class JailsReaderTest(LogCaptureTestCase):
# self.assertEqual(get_all_confs('filter.d').difference(allFilters), # self.assertEqual(get_all_confs('filter.d').difference(allFilters),
# set(['common'])) # set(['common']))
def testReadSockJailConfComplete(self):
jails = JailsReader(basedir=CONFIG_DIR, force_enable=True)
self.assertTrue(jails.read()) # opens fine
self.assertTrue(jails.getOptions()) # reads fine
# grab all filter names
filters = set(os.path.splitext(os.path.split(a)[1])[0]
for a in glob.glob(os.path.join('config', 'filter.d', '*.conf'))
if not a.endswith('common.conf'))
filters_jail = set(jail.options['filter'] for jail in jails.jails)
self.maxDiff = None
self.assertTrue(filters.issubset(filters_jail),
"More filters exists than are referenced in stock jail.conf %r" % filters.difference(filters_jail))
self.assertTrue(filters_jail.issubset(filters),
"Stock jail.conf references non-existent filters %r" % filters_jail.difference(filters))
def testReadStockJailConfForceEnabled(self): def testReadStockJailConfForceEnabled(self):
# more of a smoke test to make sure that no obvious surprises # more of a smoke test to make sure that no obvious surprises
# on users' systems when enabling shipped jails # on users' systems when enabling shipped jails