2013-09-28 20:43:06 +05:30
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Copyright (C) 2013 Kshitij Gupta <kgupta8592@gmail.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of version 2 of the GNU General Public
|
|
|
|
# License as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# ----------------------------------------------------------------------
|
2013-07-19 00:44:55 +05:30
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append('../')
|
|
|
|
import apparmor.config as config
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def test_IniConfig(self):
|
|
|
|
ini_config = config.Config('ini')
|
2013-07-20 04:19:07 +05:30
|
|
|
ini_config.CONF_DIR = '.'
|
2013-07-19 00:44:55 +05:30
|
|
|
conf = ini_config.read_config('logprof.conf')
|
|
|
|
logprof_sections = ['settings', 'repository', 'qualifiers', 'required_hats', 'defaulthat', 'globs']
|
|
|
|
logprof_sections_options = ['profiledir', 'inactive_profiledir', 'logfiles', 'parser', 'ldd', 'logger', 'default_owner_prompt', 'custom_includes']
|
|
|
|
logprof_settings_parser = '/sbin/apparmor_parser /sbin/subdomain_parser'
|
2013-09-22 22:51:30 +05:30
|
|
|
|
2013-07-19 00:44:55 +05:30
|
|
|
self.assertEqual(conf.sections(), logprof_sections)
|
|
|
|
self.assertEqual(conf.options('settings'), logprof_sections_options)
|
|
|
|
self.assertEqual(conf['settings']['parser'], logprof_settings_parser)
|
2013-09-22 22:51:30 +05:30
|
|
|
|
2013-07-19 00:44:55 +05:30
|
|
|
def test_ShellConfig(self):
|
2013-07-20 04:19:07 +05:30
|
|
|
shell_config = config.Config('shell')
|
|
|
|
shell_config.CONF_DIR = '.'
|
|
|
|
conf = shell_config.read_config('easyprof.conf')
|
2013-07-19 00:44:55 +05:30
|
|
|
easyprof_sections = ['POLICYGROUPS_DIR', 'TEMPLATES_DIR']
|
2014-02-28 16:09:00 +05:30
|
|
|
easyprof_Policygroup = './policygroups'
|
|
|
|
easyprof_Templates = './templates'
|
2013-09-22 22:51:30 +05:30
|
|
|
|
2013-07-20 04:19:07 +05:30
|
|
|
self.assertEqual(sorted(list(conf[''].keys())), sorted(easyprof_sections))
|
2013-07-19 00:44:55 +05:30
|
|
|
self.assertEqual(conf['']['POLICYGROUPS_DIR'], easyprof_Policygroup)
|
|
|
|
self.assertEqual(conf['']['TEMPLATES_DIR'], easyprof_Templates)
|
2013-09-22 22:51:30 +05:30
|
|
|
|
|
|
|
|
2013-07-19 00:44:55 +05:30
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
#import sys;sys.argv = ['', 'Test.testConfig']
|
2013-12-20 03:12:58 +05:30
|
|
|
unittest.main()
|