def test_bad_parse_target_params(self, fileops_enable): """fileops:NotTouch: Invalid subcommands raise while looking for parser""" fileops_enable.return_value = ({}, []) params = { 'command': 'fileops', 'subcommand': 'NotTouch' } with self.assertRaises(ValueError): (_params_result, _method_args) = fileops.parse_target_params( params, self.app_logger)
def test_good_parse_target_params(self, fileops_Touch): """fileops:Touch: Test looking up a special parser passes""" fileops_Touch.return_value = ({}, []) params = { 'command': 'fileops', 'subcommand': 'Touch' } (_params_result, _method_args) = fileops.parse_target_params( params, self.app_logger) self.app_logger.debug.assert_called_once_with("Found parser: _parse_Touch") self.app_logger.reset_mock()
def test_dangerous_parse_target_params(self, fileops_Touch): """fileops:Touch: Verify that if bad shell chars return it's blocked""" for bad_data in ([';'], ['&&'], ['|'], ['$'], ['>'], ['<']): fileops_Touch.reset_mock() fileops_Touch.return_value = ({}, bad_data) params = { 'command': 'fileops', 'subcommand': 'Touch' } with self.assertRaises(TypeError): (_params_result, _method_args) = fileops.parse_target_params( params, self.app_logger)