def test_routes_are_correct(self): """Tests to ensure that a plugins routes are correct""" expected = [ { "id": "column", "op": "0", "type": "TEXT", "name": "foo", }, { "id": "column", "op": "0", "type": "TEXT", "name": "baz", }, { "id": "column", "op": "0", "type": "INTEGER", "name": "int", }, ] osquery.ExtensionManager().add_plugin(MockTablePlugin) mtp = MockTablePlugin() self.assertEqual(expected, mtp.routes())
def test_simple_call(self): """Tests for the call method of osquery.TablePlugin""" ext_manager = osquery.ExtensionManager() ext_manager.add_plugin(MockLoggerPlugin) test_log_string = "test_log_string" ext_manager.call("logger", "foobar", {"string": test_log_string}) mlp = MockLoggerPlugin() self.assertTrue(test_log_string in mlp.logs)
def test_simple_call(self): """Tests for the call method of osquery.TablePlugin""" ext_manager = osquery.ExtensionManager() ext_manager.add_plugin(MockConfigPlugin) response = ext_manager.call("config", "foobar", {"action":"genConfig"}) self.assertEqual(0, response.status.code) self.assertTrue(len(response.response) > 0) self.assertTrue("source_1" in response.response[0])
def test_simple_call(self): """Tests for the call method of osquery.TablePlugin""" ext_manager = osquery.ExtensionManager() results = ext_manager.call("table", "foobar", {"action": "generate"}) expected = [ { "foo": "bar", "baz": "baz", }, { "foo": "bar", "baz": "baz", }, ] self.assertEqual(results.response, expected)
def test_plugin_was_registered(self): """Tests to ensure that a plugin was registered""" osquery.ExtensionManager().add_plugin(MockTablePlugin) registry = osquery.ExtensionManager().registry() self.assertTrue("table" in registry) self.assertTrue("foobar" in registry["table"])