def curvezmq_client():
    with get_server_auth_files() as auth_files:
        curve_dir, server_key_id, server_public_key, server_private_key = auth_files
        client_key_id = "id_client_{}_curve".format(socket.gethostname())
        key_generator = KeyGenerator(destination_dir=curve_dir,
                                     key_id=client_key_id)
        key_generator.generate()
        client_public_key = os.path.join(curve_dir,
                                         "{}.key".format(client_key_id))
        client_private_key = os.path.join(
            curve_dir, "{}.key_secret".format(client_key_id))
        shutil.copyfile(
            client_public_key,
            os.path.join(curve_dir, 'authorized_clients',
                         "{}.key".format(client_key_id)))
        auth_config = {sqlite3.SQLITE_OK: {sqlite3.SQLITE_DROP_TABLE}}
        server = SQLiteServer(bind_address="tcp://127.0.0.1:5002",
                              use_encryption=True,
                              curve_dir=curve_dir,
                              server_curve_id=server_key_id,
                              auth_config=auth_config,
                              database=":memory:")

        client = SQLiteClient(connect_address="tcp://127.0.0.1:5002",
                              server_curve_id=server_key_id,
                              client_curve_id=client_key_id,
                              curve_dir=curve_dir,
                              use_encryption=True)
        server.start()
        LOG.info("Started Test SQLiteServer")
        yield client
        os.kill(server.pid, signal.SIGINT)
        server.join()
        client.shutdown()
Exemple #2
0
def plain_client():
    auth_config = {sqlite3.SQLITE_OK: {sqlite3.SQLITE_DROP_TABLE}}
    server = SQLiteServer(bind_address="tcp://127.0.0.1:5003",
                          database=":memory:",
                          auth_config=auth_config)

    client = SQLiteClient(connect_address="tcp://127.0.0.1:5003")

    server.start()
    LOG.info("Started Test SQLiteServer")
    yield client
    os.kill(server.pid, signal.SIGINT)
    server.join()
    client.shutdown()
Exemple #3
0
def error_client():
    LOG.info("Initializing SQLite Client")
    client = SQLiteClient(connect_address="tcp://127.0.0.1:5004")
    yield client
    LOG.info("Shutting down SQLite Client")
    client.shutdown()