Esempio n. 1
0
    def test_match_filter_recurses_exec_command_filter(self):
        filter_list = [filters.IpNetnsExecFilter('/sbin/ip', 'root'),
                       filters.IpFilter('/sbin/ip', 'root')]
        args = ['ip', 'netns', 'exec', 'foo', 'ip', 'netns', 'exec', 'bar',
                'ip', 'link', 'list']

        self.assertIsNone(wrapper.match_filter(filter_list, args))
Esempio n. 2
0
    def test_match_filter_recurses_exec_command_filter_does_not_match(self):
        filter_list = [
            filters.IpNetnsExecFilter('/sbin/ip', 'root'),
            filters.IpFilter('/sbin/ip', 'root')
        ]
        args = [
            'ip', 'netns', 'exec', 'foo', 'ip', 'netns', 'exec', 'bar', 'ip',
            'link', 'list'
        ]

        self.assertRaises(wrapper.NoFilterMatched, wrapper.match_filter,
                          filter_list, args)
Esempio n. 3
0
 def test_IpNetnsExecFilter_nomatch(self):
     f = filters.IpNetnsExecFilter('/sbin/ip', 'root')
     self.assertFalse(f.match(['ip', 'link', 'list']))
Esempio n. 4
0
 def test_IpNetnsExecFilter_match(self):
     f = filters.IpNetnsExecFilter('/sbin/ip', 'root')
     self.assertTrue(
         f.match(['ip', 'netns', 'exec', 'foo', 'ip', 'link', 'list']))