Exemple #1
0
/* Setup a proxy server and a https server and the client context to connect to
   that proxy server */
apr_status_t
test_https_server_proxy_setup(test_baton_t **tb_p,
                              test_server_message_t *serv_message_list,
                              apr_size_t serv_message_count,
                              test_server_action_t *serv_action_list,
                              apr_size_t serv_action_count,
                              test_server_message_t *proxy_message_list,
                              apr_size_t proxy_message_count,
                              test_server_action_t *proxy_action_list,
                              apr_size_t proxy_action_count,
                              apr_int32_t options,
                              serf_connection_setup_t conn_setup,
                              const char *keyfile,
                              const char **certfiles,
                              const char *client_cn,
                              serf_ssl_need_server_cert_t server_cert_cb,
                              apr_pool_t *pool)
{
    apr_status_t status;
    test_baton_t *tb;

    status = setup(tb_p,
                   conn_setup ? conn_setup : default_https_conn_setup,
                   HTTPS_SERV_URL,
                   TRUE, /* use proxy */
                   serv_message_count,
                   pool);
    if (status != APR_SUCCESS)
        return status;

    tb = *tb_p;
    tb->server_cert_cb = server_cert_cb;

    /* Prepare a https server. */
    setup_https_test_server(&tb->serv_ctx, tb->serv_addr,
                            serv_message_list, serv_message_count,
                            serv_action_list, serv_action_count,
                            options,
                            keyfile, certfiles, client_cn,
                            pool);
    status = start_test_server(tb->serv_ctx);

    /* Prepare the proxy. */
    setup_test_server(&tb->proxy_ctx, tb->proxy_addr,
                      proxy_message_list, proxy_message_count,
                      proxy_action_list, proxy_action_count,
                      options,
                      pool);
    status = start_test_server(tb->proxy_ctx);

    return status;
}
Exemple #2
0
/* Setup a proxy server and an http server and the client context to connect to
   that proxy server */
apr_status_t
test_server_proxy_setup(test_baton_t **tb_p,
                        test_server_message_t *serv_message_list,
                        apr_size_t serv_message_count,
                        test_server_action_t *serv_action_list,
                        apr_size_t serv_action_count,
                        test_server_message_t *proxy_message_list,
                        apr_size_t proxy_message_count,
                        test_server_action_t *proxy_action_list,
                        apr_size_t proxy_action_count,
                        apr_int32_t options,
                        serf_connection_setup_t conn_setup,
                        apr_pool_t *pool)
{
    apr_status_t status;
    test_baton_t *tb;

    status = setup(tb_p,
                   conn_setup ? conn_setup : default_http_conn_setup,
                   HTTP_SERV_URL,
                   TRUE,
                   serv_message_count,
                   pool);
    if (status != APR_SUCCESS)
        return status;

    tb = *tb_p;

    /* Prepare the server. */
    setup_test_server(&tb->serv_ctx, tb->serv_addr,
                      serv_message_list, serv_message_count,
                      serv_action_list, serv_action_count,
                      options,
                      pool);
    status = start_test_server(tb->serv_ctx);
    if (status != APR_SUCCESS)
        return status;

    /* Prepare the proxy. */
    setup_test_server(&tb->proxy_ctx, tb->proxy_addr,
                      proxy_message_list, proxy_message_count,
                      proxy_action_list, proxy_action_count,
                      options,
                      pool);
    status = start_test_server(tb->proxy_ctx);

    return status;
}
static void setup(char **argv, const char *username, const char *password,
                  const char *bucket)
{
    const char *endpoint;
    struct lcb_create_st options;

    lcb_assert(session == NULL);
    lcb_assert(mock == NULL);
    lcb_assert(io == NULL);

    if (lcb_create_io_ops(&io, NULL) != LCB_SUCCESS) {
        fprintf(stderr, "Failed to create IO instance\n");
        exit(1);
    }

    mock = start_test_server(argv);
    if (mock == NULL) {
        err_exit("Failed to start mock server");
    }

    endpoint = get_mock_http_server(mock);
    memset(&options, 0, sizeof(options));

    if (!mock->is_mock) {
        username = mock->username;
        password = mock->password;
        bucket = mock->bucket;
    }
    options.version = 2;
    options.v.v2.host = endpoint;
    options.v.v2.user = username;
    options.v.v2.passwd = password;
    options.v.v2.bucket = bucket;
    options.v.v2.io = io;
    options.v.v2.transports = enabled_transports;

    if (lcb_create(&session, &options) != LCB_SUCCESS) {
        err_exit("Failed to create libcouchbase session");
    }

    (void)lcb_set_error_callback(session, error_callback);

    if (lcb_connect(session) != LCB_SUCCESS) {
        err_exit("Failed to connect to server");
    }
    lcb_wait(session);

    if (!mock->is_mock) {
        const char *const *servers;
        total_node_count = 0;
        servers = lcb_get_server_list(session);
        for (; *servers; servers++, total_node_count++);
    }
}
static lcb_error_t test_connect(char **argv, const char *username,
                                const char *password,
                                const char *bucket)
{
    const char *endpoint;
    lcb_error_t rc;
    struct lcb_create_st options;

    lcb_assert(session == NULL);
    lcb_assert(mock == NULL);
    lcb_assert(io == NULL);

    if (lcb_create_io_ops(&io, NULL) != LCB_SUCCESS) {
        fprintf(stderr, "Failed to create IO instance\n");
        exit(1);
    }

    mock = start_test_server(argv);
    if (mock == NULL) {
        err_exit("Failed to start mock server");
    }

    endpoint = get_mock_http_server(mock);

    memset(&options, 0, sizeof(options));
    options.version = 2;
    options.v.v2.host = endpoint;
    options.v.v2.user = username;
    options.v.v2.passwd = password;
    options.v.v2.bucket = bucket;
    options.v.v2.io = io;
    options.v.v2.transports = enabled_transports;

    if (lcb_create(&session, &options) != LCB_SUCCESS) {
        err_exit("Failed to create libcouchbase session");
    }

    (void)lcb_set_error_callback(session, error_callback2);

    if (lcb_connect(session) != LCB_SUCCESS) {
        err_exit("Failed to connect to server");
    }
    lcb_wait(session);
    rc = global_error;

    lcb_destroy(session);
    lcb_destroy_io_ops(io);
    session = NULL;
    io = NULL;
    shutdown_mock_server(mock);
    mock = NULL;

    return rc;
}