libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit acb3ed7e80ff0c6a8dd3b5dde7c09334302fb664
parent 9ff6d494fa12d1d68ffe8670c31d1e27009bc71a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 16 Nov 2008 07:34:53 +0000

making tests compile

Diffstat:
Msrc/testcurl/https/tls_alert_test.c | 66+++++++++++++++++++++++++++++++++---------------------------------
Msrc/testcurl/https/tls_cipher_change_test.c | 72+++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/testcurl/https/tls_session_time_out_test.c | 54+++++++++++++++++++++++++++---------------------------
3 files changed, 97 insertions(+), 95 deletions(-)

diff --git a/src/testcurl/https/tls_alert_test.c b/src/testcurl/https/tls_alert_test.c @@ -57,45 +57,45 @@ http_ahc (void *cls, struct MHD_Connection *connection, } static int -setup (mhd_gtls_session_t * session, - gnutls_datum_t * key, - gnutls_datum_t * cert, mhd_gtls_cert_credentials_t * xcred) +setup (MHD_gtls_session_t * session, + MHD_gnutls_datum_t * key, + MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred) { int ret; const char **err_pos; - MHD_gnutls_certificate_allocate_credentials (xcred); + MHD__gnutls_certificate_allocate_credentials (xcred); - mhd_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); - mhd_gtls_set_datum_m (cert, srv_self_signed_cert_pem, + MHD_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); + MHD_gtls_set_datum_m (cert, srv_self_signed_cert_pem, strlen (srv_self_signed_cert_pem), &malloc); - MHD_gnutls_certificate_set_x509_key_mem (*xcred, cert, key, + MHD__gnutls_certificate_set_x509_key_mem (*xcred, cert, key, GNUTLS_X509_FMT_PEM); - MHD_gnutls_init (session, GNUTLS_CLIENT); - ret = MHD_gnutls_priority_set_direct (*session, "NORMAL", err_pos); + MHD__gnutls_init (session, GNUTLS_CLIENT); + ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos); if (ret < 0) { return -1; } - MHD_gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); + MHD__gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); return 0; } static int -teardown (mhd_gtls_session_t session, - gnutls_datum_t * key, - gnutls_datum_t * cert, mhd_gtls_cert_credentials_t xcred) +teardown (MHD_gtls_session_t session, + MHD_gnutls_datum_t * key, + MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t xcred) { - mhd_gtls_free_datum_m (key, free); - mhd_gtls_free_datum_m (cert, free); + MHD_gtls_free_datum_m (key, free); + MHD_gtls_free_datum_m (cert, free); - MHD_gnutls_deinit (session); + MHD__gnutls_deinit (session); - MHD_gnutls_certificate_free_credentials (xcred); + MHD__gnutls_certificate_free_credentials (xcred); return 0; } @@ -106,7 +106,7 @@ teardown (mhd_gtls_session_t session, * @param session: an initialized TLS session */ static int -test_alert_close_notify (mhd_gtls_session_t session) +test_alert_close_notify (MHD_gtls_session_t session) { int sd, ret; struct sockaddr_in sa; @@ -117,7 +117,7 @@ test_alert_close_notify (mhd_gtls_session_t session) sa.sin_port = htons (42433); inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); - MHD_gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd); + MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) sd); ret = connect (sd, &sa, sizeof (struct sockaddr_in)); @@ -127,16 +127,16 @@ test_alert_close_notify (mhd_gtls_session_t session) return -1; } - ret = MHD_gnutls_handshake (session); + ret = MHD__gnutls_handshake (session); if (ret < 0) { return -1; } - MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_CLOSE_NOTIFY); + MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_CLOSE_NOTIFY); /* check server responds with a 'close-notify' */ - mhd_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0); + MHD_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0); close (sd); /* CLOSE_NOTIFY */ @@ -155,7 +155,7 @@ test_alert_close_notify (mhd_gtls_session_t session) * @param session: an initialized TLS session */ static int -test_alert_unexpected_message (mhd_gtls_session_t session) +test_alert_unexpected_message (MHD_gtls_session_t session) { int sd, ret; struct sockaddr_in sa; @@ -166,8 +166,8 @@ test_alert_unexpected_message (mhd_gtls_session_t session) sa.sin_port = htons (42433); inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); - MHD_gnutls_transport_set_ptr (session, - (gnutls_transport_ptr_t) ((void *) sd)); + MHD__gnutls_transport_set_ptr (session, + (MHD_gnutls_transport_ptr_t) ((void *) sd)); ret = connect (sd, &sa, sizeof (struct sockaddr_in)); @@ -177,13 +177,13 @@ test_alert_unexpected_message (mhd_gtls_session_t session) return -1; } - ret = MHD_gnutls_handshake (session); + ret = MHD__gnutls_handshake (session); if (ret < 0) { return -1; } - MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL, + MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL, GNUTLS_A_UNEXPECTED_MESSAGE); usleep (100); @@ -202,12 +202,12 @@ main (int argc, char *const *argv) { int errorCount = 0;; struct MHD_Daemon *d; - mhd_gtls_session_t session; - gnutls_datum_t key; - gnutls_datum_t cert; - mhd_gtls_cert_credentials_t xcred; + MHD_gtls_session_t session; + MHD_gnutls_datum_t key; + MHD_gnutls_datum_t cert; + MHD_gtls_cert_credentials_t xcred; - MHD_gnutls_global_init (); + MHD__gnutls_global_init (); MHD_gtls_global_set_log_level (11); d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | @@ -235,7 +235,7 @@ main (int argc, char *const *argv) fprintf (stderr, "Failed test: %s.\n", argv[0]); MHD_stop_daemon (d); - MHD_gnutls_global_deinit (); + MHD__gnutls_global_deinit (); return errorCount != 0; } diff --git a/src/testcurl/https/tls_cipher_change_test.c b/src/testcurl/https/tls_cipher_change_test.c @@ -47,7 +47,7 @@ rehandshake_ahc (void *cls, struct MHD_Connection *connection, { int ret; /* server side re-handshake request */ - ret = MHD_gnutls_rehandshake (connection->tls_session); + ret = MHD__gnutls_rehandshake (connection->tls_session); if (ret < 0) { @@ -59,45 +59,46 @@ rehandshake_ahc (void *cls, struct MHD_Connection *connection, } static int -setup (mhd_gtls_session_t * session, - gnutls_datum_t * key, - gnutls_datum_t * cert, mhd_gtls_cert_credentials_t * xcred) +setup (MHD_gtls_session_t * session, + MHD_gnutls_datum_t * key, + MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred) { int ret; const char **err_pos; - MHD_gnutls_certificate_allocate_credentials (xcred); + MHD__gnutls_certificate_allocate_credentials (xcred); - mhd_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); - mhd_gtls_set_datum_m (cert, srv_self_signed_cert_pem, + MHD_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); + MHD_gtls_set_datum_m (cert, srv_self_signed_cert_pem, strlen (srv_self_signed_cert_pem), &malloc); - MHD_gnutls_certificate_set_x509_key_mem (*xcred, cert, key, + MHD__gnutls_certificate_set_x509_key_mem (*xcred, cert, key, GNUTLS_X509_FMT_PEM); - MHD_gnutls_init (session, GNUTLS_CLIENT); - ret = MHD_gnutls_priority_set_direct (*session, "NORMAL", err_pos); + MHD__gnutls_init (session, GNUTLS_CLIENT); + ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos); if (ret < 0) { return -1; } - MHD_gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); + MHD__gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); return 0; } static int -teardown (mhd_gtls_session_t session, - gnutls_datum_t * key, - gnutls_datum_t * cert, mhd_gtls_cert_credentials_t xcred) +teardown (MHD_gtls_session_t session, + MHD_gnutls_datum_t * key, + MHD_gnutls_datum_t * cert, + MHD_gtls_cert_credentials_t xcred) { - mhd_gtls_free_datum_m (key, free); - mhd_gtls_free_datum_m (cert, free); + MHD_gtls_free_datum_m (key, free); + MHD_gtls_free_datum_m (cert, free); - MHD_gnutls_deinit (session); + MHD__gnutls_deinit (session); - MHD_gnutls_certificate_free_credentials (xcred); + MHD__gnutls_certificate_free_credentials (xcred); return 0; } @@ -110,7 +111,7 @@ teardown (mhd_gtls_session_t session, * @param session: initiallized TLS session */ static int -test_out_of_context_cipher_change (mhd_gtls_session_t session) +test_out_of_context_cipher_change (MHD_gtls_session_t session) { int sd, ret; struct sockaddr_in sa; @@ -121,7 +122,7 @@ test_out_of_context_cipher_change (mhd_gtls_session_t session) sa.sin_port = htons (42433); inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); - MHD_gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd); + MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) sd); ret = connect (sd, &sa, sizeof (struct sockaddr_in)); @@ -131,14 +132,14 @@ test_out_of_context_cipher_change (mhd_gtls_session_t session) return -1; } - ret = MHD_gnutls_handshake (session); + ret = MHD__gnutls_handshake (session); if (ret < 0) { return -1; } /* send an out of context cipher change spec */ - mhd_gtls_send_change_cipher_spec (session, 0); + MHD_gtls_send_change_cipher_spec (session, 0); /* assert server has closed connection */ @@ -155,7 +156,7 @@ test_out_of_context_cipher_change (mhd_gtls_session_t session) /* */ static int -test_rehandshake (mhd_gtls_session_t session) +test_rehandshake (MHD_gtls_session_t session) { int sd, ret; struct sockaddr_in sa; @@ -166,7 +167,7 @@ test_rehandshake (mhd_gtls_session_t session) sa.sin_port = htons (42433); inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); - MHD_gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd); + MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) sd); ret = connect (sd, &sa, sizeof (struct sockaddr_in)); @@ -176,22 +177,22 @@ test_rehandshake (mhd_gtls_session_t session) return -1; } - ret = MHD_gnutls_handshake (session); + ret = MHD__gnutls_handshake (session); if (ret < 0) { - return -1; + return 1; } - ret = MHD_gnutls_record_send (session, http_get_req, strlen (http_get_req)); + ret = MHD__gnutls_record_send (session, http_get_req, strlen (http_get_req)); /* check server responds with a 'close-notify' */ - mhd_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0); + MHD_gtls_recv_int (session, GNUTLS_ALERT, GNUTLS_HANDSHAKE_FINISHED, 0, 0); /* CLOSE_NOTIFY */ if (session->internals.last_alert != GNUTLS_A_CLOSE_NOTIFY) { - return -1; + return 1; } close (sd); @@ -203,12 +204,12 @@ main (int argc, char *const *argv) { int errorCount = 0;; struct MHD_Daemon *d; - mhd_gtls_session_t session; - gnutls_datum_t key; - gnutls_datum_t cert; - mhd_gtls_cert_credentials_t xcred; + MHD_gtls_session_t session; + MHD_gnutls_datum_t key; + MHD_gnutls_datum_t cert; + MHD_gtls_cert_credentials_t xcred; - MHD_gnutls_global_init (); + MHD__gnutls_global_init (); MHD_gtls_global_set_log_level (11); d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | @@ -226,13 +227,14 @@ main (int argc, char *const *argv) setup (&session, &key, &cert, &xcred); errorCount += test_out_of_context_cipher_change (session); + errorCount += test_rehandshake (session); teardown (session, &key, &cert, xcred); if (errorCount != 0) fprintf (stderr, "Failed test: %s.\n", argv[0]); MHD_stop_daemon (d); - MHD_gnutls_global_deinit (); + MHD__gnutls_global_deinit (); return errorCount != 0; } diff --git a/src/testcurl/https/tls_session_time_out_test.c b/src/testcurl/https/tls_session_time_out_test.c @@ -55,50 +55,50 @@ http_ahc (void *cls, struct MHD_Connection *connection, } static int -setup (mhd_gtls_session_t * session, - gnutls_datum_t * key, - gnutls_datum_t * cert, mhd_gtls_cert_credentials_t * xcred) +setup (MHD_gtls_session_t * session, + MHD_gnutls_datum_t * key, + MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred) { int ret; const char **err_pos; - MHD_gnutls_certificate_allocate_credentials (xcred); - - mhd_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); - mhd_gtls_set_datum_m (cert, srv_self_signed_cert_pem, + MHD__gnutls_certificate_allocate_credentials (xcred); + + MHD_gtls_set_datum_m (key, srv_key_pem, strlen (srv_key_pem), &malloc); + MHD_gtls_set_datum_m (cert, srv_self_signed_cert_pem, strlen (srv_self_signed_cert_pem), &malloc); - MHD_gnutls_certificate_set_x509_key_mem (*xcred, cert, key, + MHD__gnutls_certificate_set_x509_key_mem (*xcred, cert, key, GNUTLS_X509_FMT_PEM); - MHD_gnutls_init (session, GNUTLS_CLIENT); - ret = MHD_gnutls_priority_set_direct (*session, "NORMAL", err_pos); + MHD__gnutls_init (session, GNUTLS_CLIENT); + ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos); if (ret < 0) { return -1; } - MHD_gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); + MHD__gnutls_credentials_set (*session, MHD_GNUTLS_CRD_CERTIFICATE, xcred); return 0; } static int -teardown (mhd_gtls_session_t session, - gnutls_datum_t * key, - gnutls_datum_t * cert, mhd_gtls_cert_credentials_t xcred) +teardown (MHD_gtls_session_t session, + MHD_gnutls_datum_t * key, + MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t xcred) { - mhd_gtls_free_datum_m (key, free); - mhd_gtls_free_datum_m (cert, free); + MHD_gtls_free_datum_m (key, free); + MHD_gtls_free_datum_m (cert, free); - MHD_gnutls_deinit (session); + MHD__gnutls_deinit (session); - MHD_gnutls_certificate_free_credentials (xcred); + MHD__gnutls_certificate_free_credentials (xcred); return 0; } static int -test_tls_session_time_out (mhd_gtls_session_t session) +test_tls_session_time_out (MHD_gtls_session_t session) { int sd, ret; struct sockaddr_in sa; @@ -109,7 +109,7 @@ test_tls_session_time_out (mhd_gtls_session_t session) sa.sin_port = htons (42433); inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); - MHD_gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd); + MHD__gnutls_transport_set_ptr (session, (MHD_gnutls_transport_ptr_t) sd); ret = connect (sd, &sa, sizeof (struct sockaddr_in)); @@ -119,7 +119,7 @@ test_tls_session_time_out (mhd_gtls_session_t session) return -1; } - ret = MHD_gnutls_handshake (session); + ret = MHD__gnutls_handshake (session); if (ret < 0) { return -1; @@ -144,12 +144,12 @@ main (int argc, char *const *argv) { int errorCount = 0;; struct MHD_Daemon *d; - mhd_gtls_session_t session; - gnutls_datum_t key; - gnutls_datum_t cert; - mhd_gtls_cert_credentials_t xcred; + MHD_gtls_session_t session; + MHD_gnutls_datum_t key; + MHD_gnutls_datum_t cert; + MHD_gtls_cert_credentials_t xcred; - MHD_gnutls_global_init (); + MHD__gnutls_global_init (); MHD_gtls_global_set_log_level (11); d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | @@ -174,7 +174,7 @@ main (int argc, char *const *argv) fprintf (stderr, "Failed test: %s.\n", argv[0]); MHD_stop_daemon (d); - MHD_gnutls_global_deinit (); + MHD__gnutls_global_deinit (); return errorCount != 0; }