diff --git a/cmake/CMakeTest.cmake b/cmake/CMakeTest.cmake index 8830c64..7e8a664 100644 --- a/cmake/CMakeTest.cmake +++ b/cmake/CMakeTest.cmake @@ -4,16 +4,21 @@ include(FindPython3) enable_testing() -file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests/tsa_server.py" - DESTINATION "${PROJECT_BINARY_DIR}/Testing" -) -file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests/files" - "${CMAKE_CURRENT_SOURCE_DIR}/tests/certs" +set(FILES "${PROJECT_BINARY_DIR}/Testing/files") +set(CERTS "${PROJECT_BINARY_DIR}/Testing/certs") +set(CONF "${PROJECT_BINARY_DIR}/Testing/conf") + +file(COPY + "${CMAKE_CURRENT_SOURCE_DIR}/tests/files" + "${CMAKE_CURRENT_SOURCE_DIR}/tests/conf" + "${CMAKE_CURRENT_SOURCE_DIR}/tests/tsa_server.py" DESTINATION "${PROJECT_BINARY_DIR}/Testing" ) -set(FILES "${PROJECT_BINARY_DIR}/Testing/files") -set(CERTS "${PROJECT_BINARY_DIR}/Testing/certs") +file(COPY + "${CMAKE_CURRENT_SOURCE_DIR}/tests/certs/ca-bundle.crt" + DESTINATION "${CONF}" +) set(priv_p12 "-pkcs12" "${CERTS}/cert.p12" "-readpass" "${CERTS}/password.txt") set(priv_spc "-certs" "${CERTS}/cert.spc" "-key" "${CERTS}/key.pvk" "-pass" "passme") @@ -24,12 +29,27 @@ set(sign_opt "-time" "1556708400" "-h" "sha512" "-i" "https://www.osslsigncode.com/" "-n" "osslsigncode" "-ac" "${CERTS}/crosscert.pem" ) -execute_process( - COMMAND "${CERTS}/makecerts.sh" - WORKING_DIRECTORY ${CERTS} - OUTPUT_VARIABLE makecerts -) -message(STATUS "makecerts.sh: ${makecerts}") + +if(NOT CMAKE_HOST_WIN32) + execute_process( + COMMAND "${CONF}/makecerts.sh" + WORKING_DIRECTORY ${CONF} + OUTPUT_VARIABLE makecerts_output + RESULT_VARIABLE makecerts_result + ) +else() + set(makecerts_result 1) +endif() + +if(makecerts_result) + if(makecerts_output) + message(STATUS "makecerts.sh failed: ${makecerts_output}") + endif() + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests/certs" + DESTINATION "${PROJECT_BINARY_DIR}/Testing" + ) +endif() + execute_process( COMMAND ${CMAKE_COMMAND} -E sha256sum "${CERTS}/cert.der" OUTPUT_VARIABLE sha256sum diff --git a/tests/certs/makecerts.sh b/tests/conf/makecerts.sh old mode 100755 new mode 100644 similarity index 98% rename from tests/certs/makecerts.sh rename to tests/conf/makecerts.sh index 457f0e0..fb19b0b --- a/tests/certs/makecerts.sh +++ b/tests/conf/makecerts.sh @@ -251,8 +251,7 @@ if test -n "$(command -v faketime)" make_certs "$1" result=$? else - printf "%s\n" "faketime not found in \$PATH" - printf "%s\n" "tests skipped, please install faketime package" + printf "%s" "faketime not found in \$PATH, please install faketime package" result=1 fi diff --git a/tests/certs/openssl_intermediate.cnf b/tests/conf/openssl_intermediate.cnf similarity index 100% rename from tests/certs/openssl_intermediate.cnf rename to tests/conf/openssl_intermediate.cnf diff --git a/tests/certs/openssl_root.cnf b/tests/conf/openssl_root.cnf similarity index 100% rename from tests/certs/openssl_root.cnf rename to tests/conf/openssl_root.cnf diff --git a/tests/certs/openssl_tsa.cnf b/tests/conf/openssl_tsa.cnf similarity index 100% rename from tests/certs/openssl_tsa.cnf rename to tests/conf/openssl_tsa.cnf diff --git a/tests/certs/openssl_tsa_root.cnf b/tests/conf/openssl_tsa_root.cnf similarity index 100% rename from tests/certs/openssl_tsa_root.cnf rename to tests/conf/openssl_tsa_root.cnf diff --git a/tests/tsa_server.py b/tests/tsa_server.py index 20fd326..3afabd6 100644 --- a/tests/tsa_server.py +++ b/tests/tsa_server.py @@ -12,13 +12,14 @@ from http.server import BaseHTTPRequestHandler, HTTPServer RESULT_PATH = os.getcwd() FILES_PATH = os.path.join(RESULT_PATH, "./Testing/files/") CERTS_PATH = os.path.join(RESULT_PATH, "./Testing/certs/") +CONF_PATH = os.path.join(RESULT_PATH, "./Testing/conf/") DEFAULT_PATH = os.path.join(RESULT_PATH, "./osslsigncode") DEFAULT_IN = os.path.join(FILES_PATH, "./unsigned.exe") DEFAULT_OUT = os.path.join(FILES_PATH, "./ts.exe") DEFAULT_CERT = os.path.join(CERTS_PATH, "./cert.pem") DEFAULT_KEY = os.path.join(CERTS_PATH, "./key.pem") DEFAULT_CROSSCERT = os.path.join(CERTS_PATH, "./crosscert.pem") -OPENSSL_CONF = os.path.join(CERTS_PATH, "./openssl_tsa.cnf") +OPENSSL_CONF = os.path.join(CONF_PATH, "./openssl_tsa.cnf") REQUEST = os.path.join(FILES_PATH, "./jreq.tsq") RESPONS = os.path.join(FILES_PATH, "./jresp.tsr")