serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1701832 - in /serf/branches/1.3.x: ./ test/server/test_sslserver.c test/test_context.c test/test_serf.h test/test_ssl.c test/test_util.c
Date Tue, 08 Sep 2015 16:10:21 GMT
Author: rhuijben
Date: Tue Sep  8 16:10:21 2015
New Revision: 1701832

URL: http://svn.apache.org/r1701832
Log:
On the 1.3.x branch: merge r1699859,1699861 from trunk.

Resolve a lot of conflicts caused by changing the testrunner
http server.

This patch which only changes the testsuite allows running the
tests via SCons' VPATH support.

* .
* test/server/test_sslserver.c
* test/test_context.c
* test/test_serf.h
* test/test_ssl.c
* test/test_util.c
  Fix calculating paths to testfiles.

Modified:
    serf/branches/1.3.x/   (props changed)
    serf/branches/1.3.x/test/server/test_sslserver.c
    serf/branches/1.3.x/test/test_context.c
    serf/branches/1.3.x/test/test_serf.h
    serf/branches/1.3.x/test/test_ssl.c
    serf/branches/1.3.x/test/test_util.c

Propchange: serf/branches/1.3.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep  8 16:10:21 2015
@@ -1,4 +1,4 @@
 /serf/branches/1.3.x:1699925,1699931
 /serf/branches/multiple_ssl_impls:1699382
 /serf/branches/windows-sspi:1698866-1698877
-/serf/trunk:1699516-1699518,1699520-1699522,1699528,1699530-1699535,1699537,1699539-1699541,1699543,1699548-1699549,1699553,1699555-1699556,1699559-1699560,1699563-1699565,1699567-1699570,1699572-1699573,1699578-1699580,1699582-1699597,1699599-1699602,1699607,1699610,1699615-1699618,1699622-1699623,1699626-1699627,1699633,1699637,1699642,1699645,1699647,1699649-1699650,1699652,1699654-1699655,1699659-1699665,1699671,1699674,1699680-1699683,1699687-1699688,1699690,1699692-1699694,1699698-1699700,1699702,1699707-1699708,1699712-1699716,1699720,1699724,1699728,1699730,1699733,1699762,1699770,1699773,1699777,1699780-1699781,1699798,1699800-1699801,1699817,1699819,1699838,1699843,1699846,1699850,1699858,1699873,1699881,1699884,1699902-1699903,1699906,1699924,1699926-1699927,1699930,1699932,1699936-1699937,1699941,1699948-1699950,1699954,1699957,1699964,1699973,1699975,1700234,1700236
+/serf/trunk:1699516-1699518,1699520-1699522,1699528,1699530-1699535,1699537,1699539-1699541,1699543,1699548-1699549,1699553,1699555-1699556,1699559-1699560,1699563-1699565,1699567-1699570,1699572-1699573,1699578-1699580,1699582-1699597,1699599-1699602,1699607,1699610,1699615-1699618,1699622-1699623,1699626-1699627,1699633,1699637,1699642,1699645,1699647,1699649-1699650,1699652,1699654-1699655,1699659-1699665,1699671,1699674,1699680-1699683,1699687-1699688,1699690,1699692-1699694,1699698-1699700,1699702,1699707-1699708,1699712-1699716,1699720,1699724,1699728,1699730,1699733,1699762,1699770,1699773,1699777,1699780-1699781,1699798,1699800-1699801,1699817,1699819,1699838,1699843,1699846,1699850,1699858-1699859,1699861,1699873,1699881,1699884,1699902-1699903,1699906,1699924,1699926-1699927,1699930,1699932,1699936-1699937,1699941,1699948-1699950,1699954,1699957,1699964,1699973,1699975,1700234,1700236

Modified: serf/branches/1.3.x/test/server/test_sslserver.c
URL: http://svn.apache.org/viewvc/serf/branches/1.3.x/test/server/test_sslserver.c?rev=1701832&r1=1701831&r2=1701832&view=diff
==============================================================================
--- serf/branches/1.3.x/test/server/test_sslserver.c (original)
+++ serf/branches/1.3.x/test/server/test_sslserver.c Tue Sep  8 16:10:21 2015
@@ -200,7 +200,7 @@ init_ssl_context(serv_ctx_t *serv_ctx,
         certfile = certfiles[0];
         rv = SSL_CTX_use_certificate_file(ssl_ctx->ctx, certfile, SSL_FILETYPE_PEM);
         if (rv != 1) {
-            fprintf(stderr, "Cannot load certficate from file '%s'\n", keyfile);
+            fprintf(stderr, "Cannot load certficate from file '%s'\n", certfile);
             exit(1);
         }
 

Modified: serf/branches/1.3.x/test/test_context.c
URL: http://svn.apache.org/viewvc/serf/branches/1.3.x/test/test_context.c?rev=1701832&r1=1701831&r2=1701832&view=diff
==============================================================================
--- serf/branches/1.3.x/test/test_context.c (original)
+++ serf/branches/1.3.x/test/test_context.c Tue Sep  8 16:10:21 2015
@@ -1016,6 +1016,22 @@ static const char *all_server_certs[] =
     "test/server/serfrootcacert.pem",
     NULL };
 
+static const char **server_certs_srcdir(const char **certs,
+                                         apr_pool_t *result_pool)
+{
+  const char **result;
+  int i = 0;
+  while (certs[i])
+    i++;
+
+  result = apr_pcalloc(result_pool, sizeof(result[0]) * (i + 1));
+
+  while (i-- > 0)
+    result[i] = get_srcdir_file(result_pool, certs[i]);
+
+  return result;
+}
+
 static apr_status_t validate_servercert(const serf_ssl_certificate_t *cert,
                                         apr_pool_t *pool)
 {
@@ -1170,8 +1186,8 @@ static void test_ssl_handshake(CuTest *t
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      NULL, /* default conn setup */
-                                     "test/server/serfserverkey.pem",
-                                     server_cert,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_cert, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_expect_failures,
                                      test_pool);
@@ -1208,7 +1224,8 @@ https_set_root_ca_conn_setup(apr_socket_
         return status;
 
     status = serf_ssl_load_cert_file(&rootcacert,
-                                     "test/server/serfrootcacert.pem",
+                                     get_srcdir_file(pool,
+                                               "test/server/serfrootcacert.pem"),
                                      pool);
     if (status)
         return status;
@@ -1241,8 +1258,8 @@ static void test_ssl_trust_rootca(CuTest
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      https_set_root_ca_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_expect_allok,
                                      test_pool);
@@ -1278,8 +1295,8 @@ static void test_ssl_application_rejects
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      https_set_root_ca_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_reject,
                                      test_pool);
@@ -1375,8 +1392,8 @@ static void test_ssl_certificate_chain_w
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      chain_rootca_callback_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_expect_allok,
                                      test_pool);
@@ -1450,8 +1467,8 @@ static void test_ssl_certificate_chain_a
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      chain_callback_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     all_server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(all_server_certs, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_expect_allok,
                                      test_pool);
@@ -1488,8 +1505,8 @@ static void test_ssl_no_servercert_callb
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      https_set_root_ca_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      NULL, /* No server cert callback */
                                      test_pool);
@@ -1523,8 +1540,8 @@ static void test_ssl_no_servercert_callb
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      NULL, /* default conn setup, no certs */
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      NULL, /* No server cert callback */
                                      test_pool);
@@ -1559,8 +1576,8 @@ static void test_ssl_large_response(CuTe
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      https_set_root_ca_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      NULL, /* No server cert callback */
                                      test_pool);
@@ -1598,8 +1615,8 @@ static void test_ssl_large_request(CuTes
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      https_set_root_ca_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(server_certs, test_pool),
                                      NULL, /* no client cert */
                                      NULL, /* No server cert callback */
                                      test_pool);
@@ -1622,7 +1639,7 @@ static apr_status_t client_cert_cb(void
 
     tb->result_flags |= TEST_RESULT_CLIENT_CERTCB_CALLED;
 
-    *cert_path = "test/server/serfclientcert.p12";
+    *cert_path = get_srcdir_file(tb->pool, "test/server/serfclientcert.p12");
 
     return APR_SUCCESS;
 }
@@ -1634,8 +1651,8 @@ static apr_status_t client_cert_pw_cb(vo
     test_baton_t *tb = data;
 
     tb->result_flags |= TEST_RESULT_CLIENT_CERTPWCB_CALLED;
-    
-    if (strcmp(cert_path, "test/server/serfclientcert.p12") == 0)
+    if (strcmp(cert_path,
+               get_srcdir_file(tb->pool, "test/server/serfclientcert.p12")) == 0)
     {
         *password = "serftest";
         return APR_SUCCESS;
@@ -1694,8 +1711,8 @@ static void test_ssl_client_certificate(
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      client_cert_conn_setup,
-                                     "test/server/serfserverkey.pem",
-                                     all_server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(all_server_certs, test_pool),
                                      "Serf Client",
                                      NULL, /* No server cert callback */
                                      test_pool);
@@ -1739,8 +1756,8 @@ static void test_ssl_expired_server_cert
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      NULL, /* default conn setup */
-                                     "test/server/serfserverkey.pem",
-                                     expired_server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(expired_server_certs, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_expect_failures,
                                      test_pool);
@@ -1785,8 +1802,8 @@ static void test_ssl_future_server_cert(
                                      message_list, num_requests,
                                      action_list, num_requests, 0,
                                      NULL, /* default conn setup */
-                                     "test/server/serfserverkey.pem",
-                                     future_server_certs,
+                                     get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                     server_certs_srcdir(future_server_certs, test_pool),
                                      NULL, /* no client cert */
                                      ssl_server_cert_cb_expect_failures,
                                      test_pool);
@@ -1852,8 +1869,8 @@ static void test_setup_ssltunnel(CuTest
                                            action_list_proxy, 2,
                                            0,
                                            https_set_root_ca_conn_setup,
-                                           "test/server/serfserverkey.pem",
-                                           server_certs,
+                                           get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                           server_certs_srcdir(server_certs, test_pool),
                                            NULL, /* no client cert */
                                            NULL, /* No server cert callback */
                                            test_pool);
@@ -1913,8 +1930,8 @@ static void test_ssltunnel_no_creds_cb(C
                                            action_list_proxy, 1,
                                            0,
                                            https_set_root_ca_conn_setup,
-                                           "test/server/serfserverkey.pem",
-                                           server_certs,
+                                           get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                           server_certs_srcdir(server_certs, test_pool),
                                            NULL, /* no client cert */
                                            NULL, /* No server cert callback */
                                            test_pool);
@@ -2093,8 +2110,8 @@ static void ssltunnel_basic_auth(CuTest
                                            action_list_proxy, 7,
                                            0,
                                            https_set_root_ca_conn_setup,
-                                           "test/server/serfserverkey.pem",
-                                           server_certs,
+                                           get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                           server_certs_srcdir(server_certs, test_pool),
                                            NULL, /* no client cert */
                                            NULL, /* No server cert callback */
                                            test_pool);
@@ -2242,8 +2259,8 @@ static void test_ssltunnel_digest_auth(C
                                            action_list_proxy, 3,
                                            0,
                                            https_set_root_ca_conn_setup,
-                                           "test/server/serfserverkey.pem",
-                                           server_certs,
+                                           get_srcdir_file(test_pool, "test/server/serfserverkey.pem"),
+                                           server_certs_srcdir(server_certs, test_pool),
                                            NULL, /* no client cert */
                                            NULL, /* No server cert callback */
                                            test_pool);

Modified: serf/branches/1.3.x/test/test_serf.h
URL: http://svn.apache.org/viewvc/serf/branches/1.3.x/test/test_serf.h?rev=1701832&r1=1701831&r2=1701832&view=diff
==============================================================================
--- serf/branches/1.3.x/test/test_serf.h (original)
+++ serf/branches/1.3.x/test/test_serf.h Tue Sep  8 16:10:21 2015
@@ -282,4 +282,8 @@ serf_bucket_t *serf_bucket_mock_create(m
                                        serf_bucket_alloc_t *allocator);
 apr_status_t serf_bucket_mock_more_data_arrived(serf_bucket_t *bucket);
 
+/* Helper to get a file relative to our source directory by looking at
+ * 'srcdir' env variable. */
+const char * get_srcdir_file(apr_pool_t *pool, const char * file);
+
 #endif /* TEST_SERF_H */

Modified: serf/branches/1.3.x/test/test_ssl.c
URL: http://svn.apache.org/viewvc/serf/branches/1.3.x/test/test_ssl.c?rev=1701832&r1=1701831&r2=1701832&view=diff
==============================================================================
--- serf/branches/1.3.x/test/test_ssl.c (original)
+++ serf/branches/1.3.x/test/test_ssl.c Tue Sep  8 16:10:21 2015
@@ -54,20 +54,7 @@ static void test_ssl_init(CuTest *tc)
     CuAssertIntEquals(tc, APR_SUCCESS, status);
 }
 
-
-static const char * get_ca_file(apr_pool_t *pool, const char * file)
-{
-    char *srcdir = "";
-
-    if (apr_env_get(&srcdir, "srcdir", pool) == APR_SUCCESS) {
-        return apr_pstrcat(pool, srcdir, "/", file, NULL);
-    }
-    else {
-        return file;
-    }
-}
-
-
+#define get_ca_file(pool, file)  get_srcdir_file(pool, file) 
 /* Test that loading a custom CA certificate file works. */
 static void test_ssl_load_cert_file(CuTest *tc)
 {
@@ -261,7 +248,8 @@ static void test_ssl_cert_export(CuTest
 
     /* A .pem file contains a Base64 encoded DER certificate, which is exactly
        what serf_ssl_cert_export is supposed to be returning. */
-    status = apr_file_open(&fp, "test/serftestca.pem",
+    status = apr_file_open(&fp,
+                           get_srcdir_file(test_pool, "test/serftestca.pem"),
                            APR_FOPEN_READ | APR_FOPEN_BINARY,
                            APR_FPROT_OS_DEFAULT, test_pool);
     CuAssertIntEquals(tc, APR_SUCCESS, status);

Modified: serf/branches/1.3.x/test/test_util.c
URL: http://svn.apache.org/viewvc/serf/branches/1.3.x/test/test_util.c?rev=1701832&r1=1701831&r2=1701832&view=diff
==============================================================================
--- serf/branches/1.3.x/test/test_util.c (original)
+++ serf/branches/1.3.x/test/test_util.c Tue Sep  8 16:10:21 2015
@@ -15,6 +15,7 @@
 
 #include "apr.h"
 #include "apr_pools.h"
+#include <apr_env.h>
 #include <apr_strings.h>
 
 #include <stdlib.h>
@@ -32,6 +33,18 @@
 #define HTTP_SERV_URL  "http://localhost:" SERV_PORT_STR
 #define HTTPS_SERV_URL "https://localhost:" SERV_PORT_STR
 
+const char * get_srcdir_file(apr_pool_t *pool, const char * file)
+{
+    char *srcdir = "";
+
+    if (apr_env_get(&srcdir, "srcdir", pool) == APR_SUCCESS) {
+        return apr_pstrcat(pool, srcdir, "/", file, NULL);
+    }
+    else {
+        return file;
+    }
+}
+
 /* cleanup for conn */
 static apr_status_t cleanup_conn(void *baton)
 {



Mime
View raw message