diff options
Diffstat (limited to 'src/testcurl/https/tls_test_common.h')
-rw-r--r-- | src/testcurl/https/tls_test_common.h | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h new file mode 100644 index 00000000..75c4361d --- /dev/null +++ b/src/testcurl/https/tls_test_common.h | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | This file is part of libmicrohttpd | ||
3 | (C) 2007 Christian Grothoff | ||
4 | |||
5 | libmicrohttpd is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | libmicrohttpd is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with libmicrohttpd; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef TLS_TEST_COMMON_H_ | ||
22 | #define TLS_TEST_COMMON_H_ | ||
23 | |||
24 | #include "platform.h" | ||
25 | #include "microhttpd.h" | ||
26 | #include <curl/curl.h> | ||
27 | #include <sys/stat.h> | ||
28 | #include <limits.h> | ||
29 | #include "gnutls.h" | ||
30 | |||
31 | /* this enables verbos CURL version checking */ | ||
32 | #define DEBUG_HTTPS_TEST 1 | ||
33 | #define CURL_VERBOS_LEVEL 1 | ||
34 | |||
35 | #define DEAMON_TEST_PORT 42433 | ||
36 | |||
37 | #define TEST_FILE_NAME "https_test_file" | ||
38 | |||
39 | #define EMPTY_PAGE "<html><head><title>Empty page</title></head><body>Empty page</body></html>" | ||
40 | #define PAGE_NOT_FOUND "<html><head><title>File not found</title></head><body>File not found</body></html>" | ||
41 | |||
42 | #define MHD_E_MEM "Error: memory error\n" | ||
43 | #define MHD_E_SERVER_INIT "Error: failed to start server\n" | ||
44 | #define MHD_E_TEST_FILE_CREAT "Error: failed to setup test file\n" | ||
45 | #define MHD_E_CERT_FILE_CREAT "Error: failed to setup test certificate\n" | ||
46 | #define MHD_E_KEY_FILE_CREAT "Error: failed to setup test certificate\n" | ||
47 | #define MHD_E_FAILED_TO_CONNECT "Error: server connection could not be established\n" | ||
48 | |||
49 | /* TODO rm if unused */ | ||
50 | struct https_test_data | ||
51 | { | ||
52 | FILE *test_fd; | ||
53 | char *cipher_suite; | ||
54 | int proto_version; | ||
55 | }; | ||
56 | |||
57 | struct CBC | ||
58 | { | ||
59 | char *buf; | ||
60 | size_t pos; | ||
61 | size_t size; | ||
62 | }; | ||
63 | |||
64 | struct CipherDef | ||
65 | { | ||
66 | int options[2]; | ||
67 | char *curlname; | ||
68 | }; | ||
69 | |||
70 | void print_test_result (int test_outcome, char *test_name); | ||
71 | |||
72 | size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx); | ||
73 | |||
74 | int | ||
75 | http_ahc (void *cls, struct MHD_Connection *connection, | ||
76 | const char *url, const char *method, const char *upload_data, | ||
77 | const char *version, unsigned int *upload_data_size, void **ptr); | ||
78 | |||
79 | int | ||
80 | http_dummy_ahc (void *cls, struct MHD_Connection *connection, | ||
81 | const char *url, const char *method, const char *upload_data, | ||
82 | const char *version, unsigned int *upload_data_size, | ||
83 | void **ptr); | ||
84 | |||
85 | int gen_test_file_url (char *url, int port); | ||
86 | |||
87 | int | ||
88 | send_curl_req (char *url, struct CBC *cbc, char *cipher_suite, | ||
89 | int proto_version); | ||
90 | |||
91 | int | ||
92 | test_https_transfer (FILE * test_fd, char *cipher_suite, int proto_version); | ||
93 | |||
94 | FILE *setup_test_file (); | ||
95 | |||
96 | int | ||
97 | setup_testcase (struct MHD_Daemon **d, int daemon_flags, va_list arg_list); | ||
98 | |||
99 | void teardown_testcase (struct MHD_Daemon *d); | ||
100 | |||
101 | int | ||
102 | setup_session (MHD_gtls_session_t * session, | ||
103 | MHD_gnutls_datum_t * key, | ||
104 | MHD_gnutls_datum_t * cert, | ||
105 | MHD_gtls_cert_credentials_t * xcred); | ||
106 | |||
107 | int | ||
108 | teardown_session (MHD_gtls_session_t session, | ||
109 | MHD_gnutls_datum_t * key, | ||
110 | MHD_gnutls_datum_t * cert, | ||
111 | MHD_gtls_cert_credentials_t xcred); | ||
112 | |||
113 | int | ||
114 | test_wrap (char *test_name, int | ||
115 | (*test_function) (FILE * test_fd, char *cipher_suite, | ||
116 | int proto_version), FILE * test_fd, | ||
117 | int daemon_flags, char *cipher_suite, int proto_version, ...); | ||
118 | #endif /* TLS_TEST_COMMON_H_ */ | ||