def test_denies(self):
     """test denies rules."""
     # keys in denies list will be removed from filtered config.
     denies = {
         '/1': config_filter.DenyRule(),
         '2/22': config_filter.DenyRule(),
         '2/33/333': config_filter.DenyRule(),
         '5': config_filter.DenyRule()
     }
     expected_config = {'2': {'33': {'44': '444'}}, '3': {'33': '44'}}
     configfilter = config_filter.ConfigFilter(denies=denies)
     filtered_config = configfilter.filter(self.config_)
     self.assertEqual(filtered_config, expected_config)
 def test_init(self):
     config_filter.ConfigFilter(allows={
         'abc': config_filter.AllowRule(),
         'def': config_filter.AllowRule()
     },
                                denies={
                                    'def': config_filter.DenyRule(),
                                    'ghi': config_filter.DenyRule()
                                })
     config_filter.ConfigFilter(allows={
         u'abc': config_filter.AllowRule(),
         u'def': config_filter.AllowRule()
     },
                                denies={
                                    u'def': config_filter.DenyRule(),
                                    u'ghi': config_filter.DenyRule()
                                })
Esempio n. 3
0
from compass.db.model import Adapter
from compass.db.model import Cluster
from compass.db.model import ClusterHost
from compass.db.model import ClusterState
from compass.db.model import HostState
from compass.db.model import LogProgressingHistory
from compass.db.model import Machine
from compass.db.model import Role
from compass.db.model import Switch
from compass.db.model import SwitchConfig
from compass.utils import setting_wrapper as setting

GET_CLUSTER_ALLOWS = {'*': config_filter.AllowRule()}
GET_CLUSTER_DENIES = {
    '/networking/global/ha_vip':
    config_filter.DenyRule(check=config_filter_callbacks.deny_if_empty)
}
GET_HOST_ALLOWS = {'*': config_filter.AllowRule()}
GET_HOST_DENIES = {
    '/roles':
    config_filter.DenyRule(check=config_filter_callbacks.deny_if_empty),
    '/dashboard_roles':
    config_filter.DenyRule(check=config_filter_callbacks.deny_if_empty),
    '/haproxy_roles':
    config_filter.DenyRule(check=config_filter_callbacks.deny_if_empty),
}
UPDATE_CLUSTER_ALLOWS = {
    '/security': config_filter.AllowRule(),
    '/networking': config_filter.AllowRule(),
    '/partition': config_filter.AllowRule()
}
 def tet_deneis_asterisks_in_path(self):
     denies = {'*/33': config_filter.DenyRule()}
     expected_config = {'1': '1', '2': {'22': '22'}}
     configfilter = config_filter.ConfigFilter(denies=denies)
     filtered_config = configfilter.filter(self.config_)
     self.assertEqual(filtered_config, expected_config)
 def test_denies_asterisks(self):
     denies = {'*': config_filter.DenyRule()}
     configfilter = config_filter.ConfigFilter(denies=denies)
     filtered_config = configfilter.filter(self.config_)
     self.assertIsNone(filtered_config)