Exemplo n.º 1
0
        ex = client2.getEX()

        # Trigger an async update from the extension.
        request = {
            "action": "update",
            "source": "test",
            "data": "{\"options\": {\"config_plugin\": \"update_test\"}}"
        }
        ex.call("config", "example", request)

        # The update call in the extension should filter to the core.
        options = em.options()
        self.assertTrue("config_plugin" in options.keys())
        self.assertTrue(options["config_plugin"], "update_test")

        # Cleanup thrift connections and subprocesses.
        client2.close()
        client.close()
        extension.kill()
        daemon.kill()


if __name__ == "__main__":
    test_base.assertPermissions()
    module = test_base.Tester()

    # Find and import the thrift-generated python interface
    test_base.loadThriftFromBuild(test_base.ARGS.build)

    module.run()
Exemplo n.º 2
0
    def test_3_module_prevent_create(self):
        '''Test a failed module create (we interrupt the static construction).
        This test uses a special environment variable checked in the example
        module built as part of the default SDK build.
        '''
        self.osqueryi = test_base.OsqueryWrapper(self.binary,
                                                 {"modules_autoload": self.modules_loader.path}, {"TESTFAIL1": "1"})
        result = self.osqueryi.run_query(
            'SELECT * from time;')
        # Make sure the environment variable did not introduce any unexpected
        # crashes with the unit or integration tests.
        self.assertEqual(len(result), 1)
        # The environment variable should have prevented the module load.
        self.assertRaises(test_base.OsqueryException,
                          self.osqueryi.run_query, 'SELECT * from example;')

    def test_4_module_prevent_initialize(self):
        '''Test a failed module initialize (we interrupt the registry call).
        '''
        self.osqueryi = test_base.OsqueryWrapper(self.binary,
                                                 {"modules_autoload": self.modules_loader.path}, {"TESTFAIL2": "1"})
        # The environment variable should have prevented the module load.
        self.assertRaises(test_base.OsqueryException,
                          self.osqueryi.run_query, 'SELECT * from example;')


if __name__ == "__main__":
    test_base.assertPermissions()
    module = test_base.Tester().run()