@@ -292,6 +292,130 @@ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, single_resource_not_default_resource)
292292 ws.stop();
293293LT_END_AUTO_TEST (single_resource_not_default_resource)
294294
295+ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, thread_per_connection_fails_with_max_threads)
296+ {
297+ webserver ws = create_webserver (8080 )
298+ .start_method (http::http_utils::THREAD_PER_CONNECTION)
299+ .max_threads (5 );
300+ LT_CHECK_THROW (ws.start (false ));
301+ }
302+ LT_END_AUTO_TEST (thread_per_connection_fails_with_max_threads)
303+
304+ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, tuning_options)
305+ webserver ws = create_webserver(8080 )
306+ .max_connections(10 )
307+ .max_threads(10 )
308+ .memory_limit(10000 )
309+ .per_IP_connection_limit(10 )
310+ .max_thread_stack_size(10 )
311+ .nonce_nc_size(10 );
312+
313+ ok_resource* ok = new ok_resource();
314+ ws.register_resource(" base" , ok);
315+ ws.start(false );
316+
317+ curl_global_init (CURL_GLOBAL_ALL);
318+ std::string s;
319+ CURL *curl = curl_easy_init();
320+ CURLcode res;
321+ curl_easy_setopt (curl, CURLOPT_URL, " localhost:8080/base" );
322+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
323+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
324+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
325+ res = curl_easy_perform(curl);
326+ LT_ASSERT_EQ (res, 0 );
327+ LT_CHECK_EQ (s, " OK" );
328+ curl_easy_cleanup (curl);
329+
330+ ws.stop();
331+ LT_END_AUTO_TEST (tuning_options)
332+
333+ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, ssl_base)
334+ webserver ws = create_webserver(8080 )
335+ .use_ssl()
336+ .https_mem_key(" key.pem" )
337+ .https_mem_cert(" cert.pem" );
338+
339+ ok_resource* ok = new ok_resource();
340+ ws.register_resource(" base" , ok);
341+ ws.start(false );
342+
343+ curl_global_init (CURL_GLOBAL_ALL);
344+ std::string s;
345+ CURL *curl = curl_easy_init();
346+ CURLcode res;
347+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L ); // avoid verifying ssl
348+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L ); // avoid verifying ssl
349+ curl_easy_setopt (curl, CURLOPT_URL, " https://localhost:8080/base" );
350+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
351+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
352+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
353+ res = curl_easy_perform(curl);
354+ LT_ASSERT_EQ (res, 0 );
355+ LT_CHECK_EQ (s, " OK" );
356+ curl_easy_cleanup (curl);
357+
358+ ws.stop();
359+ LT_END_AUTO_TEST (ssl_base)
360+
361+ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, ssl_with_protocol_priorities)
362+ webserver ws = create_webserver(8080 )
363+ .use_ssl()
364+ .https_mem_key(" key.pem" )
365+ .https_mem_cert(" cert.pem" )
366+ .https_priorities(" TLS1.0-AES-SHA1" );
367+
368+ ok_resource* ok = new ok_resource();
369+ ws.register_resource(" base" , ok);
370+ ws.start(false );
371+
372+ curl_global_init (CURL_GLOBAL_ALL);
373+ std::string s;
374+ CURL *curl = curl_easy_init();
375+ CURLcode res;
376+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L ); // avoid verifying ssl
377+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L ); // avoid verifying ssl
378+ curl_easy_setopt (curl, CURLOPT_URL, " https://localhost:8080/base" );
379+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
380+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
381+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
382+ res = curl_easy_perform(curl);
383+ LT_ASSERT_EQ (res, 0 );
384+ LT_CHECK_EQ (s, " OK" );
385+ curl_easy_cleanup (curl);
386+
387+ ws.stop();
388+ LT_END_AUTO_TEST (ssl_with_protocol_priorities)
389+
390+ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, ssl_with_trust)
391+ webserver ws = create_webserver(8080 )
392+ .use_ssl()
393+ .https_mem_key(" key.pem" )
394+ .https_mem_cert(" cert.pem" )
395+ .https_mem_trust(" test_root_ca.pem" );
396+
397+ ok_resource* ok = new ok_resource();
398+ ws.register_resource(" base" , ok);
399+ ws.start(false );
400+
401+ curl_global_init (CURL_GLOBAL_ALL);
402+ std::string s;
403+ CURL *curl = curl_easy_init();
404+ CURLcode res;
405+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L ); // avoid verifying ssl
406+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L ); // avoid verifying ssl
407+ curl_easy_setopt (curl, CURLOPT_URL, " https://localhost:8080/base" );
408+ curl_easy_setopt (curl, CURLOPT_HTTPGET, 1L );
409+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, writefunc);
410+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, &s);
411+ res = curl_easy_perform(curl);
412+ LT_ASSERT_EQ (res, 0 );
413+ LT_CHECK_EQ (s, " OK" );
414+ curl_easy_cleanup (curl);
415+
416+ ws.stop();
417+ LT_END_AUTO_TEST (ssl_with_trust)
418+
295419LT_BEGIN_AUTO_TEST_ENV()
296420 AUTORUN_TESTS()
297421LT_END_AUTO_TEST_ENV()
0 commit comments