def test_missing_command(self): valid_but_missing = ["foo_bar_not_exist"] invalid = ["foo_bar_not_exist_and_not_matched"] filtermatch = wrapper.match_filter(self.filters, valid_but_missing) self.assertTrue(filtermatch is not None) filtermatch = wrapper.match_filter(self.filters, invalid) self.assertTrue(filtermatch is None)
def test_RegExpFilter_match(self): usercmd = ["ls", "/root"] filtermatch = wrapper.match_filter(self.filters, usercmd) self.assertFalse(filtermatch is None) self.assertEqual(filtermatch.get_command(usercmd), ["/bin/ls", "/root"])
def test_RegExpFilter_reject(self): usercmd = ["ls", "root"] filtermatch = wrapper.match_filter(self.filters, usercmd) self.assertTrue(filtermatch is None)
def test_skips(self): # Check that all filters are skipped and that the last matches usercmd = ["cat", "/"] filtermatch = wrapper.match_filter(self.filters, usercmd) self.assertTrue(filtermatch is self.filters[-1])