Add mutual tls unit test
Mutual TLS paths were not tested. Add some unit tests.
Because CI doesn't actually compile dependent libraries with ASAN
enabled, and these tests call into openssl, we need to add a check for
if we're compiling with asan enabled.
Tested: unit tests pass.
Change-Id: I02dcb69708619cc00fffd840738c608db3ae8bdf
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/meson.build b/meson.build
index 002b949..26e8fda 100644
--- a/meson.build
+++ b/meson.build
@@ -136,7 +136,6 @@
'-Wcast-align',
'-Wconversion',
'-Wformat=2',
- '-Wold-style-cast',
'-Woverloaded-virtual',
'-Wsign-conversion',
'-Wunused',
@@ -260,8 +259,24 @@
pam = cxx.find_library('pam', required: true)
atomic = cxx.find_library('atomic', required: true)
-openssl = dependency('openssl', required : true)
-bmcweb_dependencies += [pam, atomic, openssl]
+bmcweb_dependencies += [pam, atomic]
+
+openssl = dependency('openssl', required : false, version: '>=3.0.0')
+if not openssl.found() or get_option('b_sanitize') != 'none'
+ openssl_proj = subproject(
+ 'openssl',
+ required: true,
+ default_options: ['warning_level=0', 'werror=false']
+ )
+ openssl = openssl_proj.get_variable('openssl_dep')
+ openssl = openssl.as_system('system')
+else
+ # When we build openssl as a subproject, the warnings analyzer starts
+ # flagging all the C macros as old style casts, so only enable the
+ # warning for non subprojects.
+ add_project_arguments('-Wold-style-cast', language: 'cpp')
+endif
+bmcweb_dependencies += [openssl]
nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required : false)
if not nghttp2.found()
@@ -408,6 +423,7 @@
srcfiles_unittest = files(
'test/http/crow_getroutes_test.cpp',
'test/http/http_connection_test.cpp',
+ 'test/http/mutual_tls.cpp',
'test/http/router_test.cpp',
'test/http/http_response_test.cpp',
'test/http/utility_test.cpp',
@@ -442,6 +458,7 @@
'test/redfish-core/lib/power_subsystem_test.cpp',
)
+
if(get_option('tests').allowed())
# generate the test executable
foreach test_src : srcfiles_unittest