|
Packit |
875988 |
/*
|
|
Packit |
875988 |
This file is part of libmicrohttpd
|
|
Packit |
875988 |
Copyright (C) 2007 Christian Grothoff
|
|
Packit |
875988 |
|
|
Packit |
875988 |
libmicrohttpd is free software; you can redistribute it and/or modify
|
|
Packit |
875988 |
it under the terms of the GNU General Public License as published
|
|
Packit |
875988 |
by the Free Software Foundation; either version 2, or (at your
|
|
Packit |
875988 |
option) any later version.
|
|
Packit |
875988 |
|
|
Packit |
875988 |
libmicrohttpd is distributed in the hope that it will be useful, but
|
|
Packit |
875988 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
875988 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
875988 |
General Public License for more details.
|
|
Packit |
875988 |
|
|
Packit |
875988 |
You should have received a copy of the GNU General Public License
|
|
Packit |
875988 |
along with libmicrohttpd; see the file COPYING. If not, write to the
|
|
Packit |
875988 |
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit |
875988 |
Boston, MA 02110-1301, USA.
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#ifndef TLS_TEST_COMMON_H_
|
|
Packit |
875988 |
#define TLS_TEST_COMMON_H_
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#include "platform.h"
|
|
Packit |
875988 |
#include "microhttpd.h"
|
|
Packit |
875988 |
#include <curl/curl.h>
|
|
Packit |
875988 |
#include <sys/stat.h>
|
|
Packit |
875988 |
#include <limits.h>
|
|
Packit |
875988 |
#include <gnutls/gnutls.h>
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/* this enables verbos CURL version checking */
|
|
Packit |
875988 |
#define DEBUG_HTTPS_TEST 0
|
|
Packit |
875988 |
#define CURL_VERBOS_LEVEL 0
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#define test_data "Hello World\n"
|
|
Packit |
875988 |
#define ca_cert_file_name "tmp_ca_cert.pem"
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#define EMPTY_PAGE "<html><head><title>Empty page</title></head><body>Empty page</body></html>"
|
|
Packit |
875988 |
#define PAGE_NOT_FOUND "<html><head><title>File not found</title></head><body>File not found</body></html>"
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#define MHD_E_MEM "Error: memory error\n"
|
|
Packit |
875988 |
#define MHD_E_SERVER_INIT "Error: failed to start server\n"
|
|
Packit |
875988 |
#define MHD_E_TEST_FILE_CREAT "Error: failed to setup test file\n"
|
|
Packit |
875988 |
#define MHD_E_CERT_FILE_CREAT "Error: failed to setup test certificate\n"
|
|
Packit |
875988 |
#define MHD_E_KEY_FILE_CREAT "Error: failed to setup test certificate\n"
|
|
Packit |
875988 |
#define MHD_E_FAILED_TO_CONNECT "Error: server connection could not be established\n"
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/* TODO rm if unused */
|
|
Packit |
875988 |
struct https_test_data
|
|
Packit |
875988 |
{
|
|
Packit |
875988 |
void *cls;
|
|
Packit |
875988 |
int port;
|
|
Packit |
875988 |
const char *cipher_suite;
|
|
Packit |
875988 |
int proto_version;
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
struct CBC
|
|
Packit |
875988 |
{
|
|
Packit |
875988 |
char *buf;
|
|
Packit |
875988 |
size_t pos;
|
|
Packit |
875988 |
size_t size;
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
struct CipherDef
|
|
Packit |
875988 |
{
|
|
Packit |
875988 |
int options[2];
|
|
Packit |
875988 |
char *curlname;
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
curl_check_version (const char *req_version, ...);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
curl_uses_nss_ssl (void);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
FILE *
|
|
Packit |
875988 |
setup_ca_cert (void);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* perform cURL request for file
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
test_daemon_get (void * cls,
|
|
Packit |
875988 |
const char *cipher_suite, int proto_version,
|
|
Packit |
875988 |
int port, int ver_peer);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
print_test_result (int test_outcome, char *test_name);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
size_t
|
|
Packit |
875988 |
copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
http_ahc (void *cls, struct MHD_Connection *connection,
|
|
Packit |
875988 |
const char *url, const char *method, const char *upload_data,
|
|
Packit |
875988 |
const char *version, size_t *upload_data_size, void **ptr);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
http_dummy_ahc (void *cls, struct MHD_Connection *connection,
|
|
Packit |
875988 |
const char *url, const char *method, const char *upload_data,
|
|
Packit |
875988 |
const char *version, size_t *upload_data_size,
|
|
Packit |
875988 |
void **ptr);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* compile test file url pointing to the current running directory path
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param[out] url - char buffer into which the url is compiled
|
|
Packit |
875988 |
* @param url_len number of bytes available in @a url
|
|
Packit |
875988 |
* @param port port to use for the test
|
|
Packit |
875988 |
* @return -1 on error
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
gen_test_file_url (char *url,
|
|
Packit |
875988 |
size_t url_len,
|
|
Packit |
875988 |
int port);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite,
|
|
Packit |
875988 |
int proto_version);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
test_https_transfer (void *cls, int port, const char *cipher_suite, int proto_version);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list arg_list);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
teardown_testcase (struct MHD_Daemon *d);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
setup_session (gnutls_session_t * session,
|
|
Packit |
875988 |
gnutls_datum_t * key,
|
|
Packit |
875988 |
gnutls_datum_t * cert,
|
|
Packit |
875988 |
gnutls_certificate_credentials_t * xcred);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
teardown_session (gnutls_session_t session,
|
|
Packit |
875988 |
gnutls_datum_t * key,
|
|
Packit |
875988 |
gnutls_datum_t * cert,
|
|
Packit |
875988 |
gnutls_certificate_credentials_t xcred);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
test_wrap (const char *test_name, int
|
|
Packit |
875988 |
(*test_function) (void * cls, int port, const char *cipher_suite,
|
|
Packit |
875988 |
int proto_version), void * cls,
|
|
Packit |
875988 |
int port,
|
|
Packit |
875988 |
int daemon_flags, const char *cipher_suite, int proto_version, ...);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
int testsuite_curl_global_init (void);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#endif /* TLS_TEST_COMMON_H_ */
|