improve tests

This commit is contained in:
olszomal 2022-07-20 15:09:43 +02:00 committed by Michał Trojnara
parent 99400d92d6
commit ac3e8e5221
7 changed files with 36 additions and 16 deletions

View File

@ -4,16 +4,21 @@
include(FindPython3) include(FindPython3)
enable_testing() enable_testing()
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests/tsa_server.py" set(FILES "${PROJECT_BINARY_DIR}/Testing/files")
DESTINATION "${PROJECT_BINARY_DIR}/Testing" 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/certs" 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" DESTINATION "${PROJECT_BINARY_DIR}/Testing"
) )
set(FILES "${PROJECT_BINARY_DIR}/Testing/files") file(COPY
set(CERTS "${PROJECT_BINARY_DIR}/Testing/certs") "${CMAKE_CURRENT_SOURCE_DIR}/tests/certs/ca-bundle.crt"
DESTINATION "${CONF}"
)
set(priv_p12 "-pkcs12" "${CERTS}/cert.p12" "-readpass" "${CERTS}/password.txt") set(priv_p12 "-pkcs12" "${CERTS}/cert.p12" "-readpass" "${CERTS}/password.txt")
set(priv_spc "-certs" "${CERTS}/cert.spc" "-key" "${CERTS}/key.pvk" "-pass" "passme") 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/" "-h" "sha512" "-i" "https://www.osslsigncode.com/"
"-n" "osslsigncode" "-ac" "${CERTS}/crosscert.pem" "-n" "osslsigncode" "-ac" "${CERTS}/crosscert.pem"
) )
execute_process(
COMMAND "${CERTS}/makecerts.sh" if(NOT CMAKE_HOST_WIN32)
WORKING_DIRECTORY ${CERTS} execute_process(
OUTPUT_VARIABLE makecerts COMMAND "${CONF}/makecerts.sh"
) WORKING_DIRECTORY ${CONF}
message(STATUS "makecerts.sh: ${makecerts}") 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( execute_process(
COMMAND ${CMAKE_COMMAND} -E sha256sum "${CERTS}/cert.der" COMMAND ${CMAKE_COMMAND} -E sha256sum "${CERTS}/cert.der"
OUTPUT_VARIABLE sha256sum OUTPUT_VARIABLE sha256sum

3
tests/certs/makecerts.sh → tests/conf/makecerts.sh Executable file → Normal file
View File

@ -251,8 +251,7 @@ if test -n "$(command -v faketime)"
make_certs "$1" make_certs "$1"
result=$? result=$?
else else
printf "%s\n" "faketime not found in \$PATH" printf "%s" "faketime not found in \$PATH, please install faketime package"
printf "%s\n" "tests skipped, please install faketime package"
result=1 result=1
fi fi

View File

@ -12,13 +12,14 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
RESULT_PATH = os.getcwd() RESULT_PATH = os.getcwd()
FILES_PATH = os.path.join(RESULT_PATH, "./Testing/files/") FILES_PATH = os.path.join(RESULT_PATH, "./Testing/files/")
CERTS_PATH = os.path.join(RESULT_PATH, "./Testing/certs/") 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_PATH = os.path.join(RESULT_PATH, "./osslsigncode")
DEFAULT_IN = os.path.join(FILES_PATH, "./unsigned.exe") DEFAULT_IN = os.path.join(FILES_PATH, "./unsigned.exe")
DEFAULT_OUT = os.path.join(FILES_PATH, "./ts.exe") DEFAULT_OUT = os.path.join(FILES_PATH, "./ts.exe")
DEFAULT_CERT = os.path.join(CERTS_PATH, "./cert.pem") DEFAULT_CERT = os.path.join(CERTS_PATH, "./cert.pem")
DEFAULT_KEY = os.path.join(CERTS_PATH, "./key.pem") DEFAULT_KEY = os.path.join(CERTS_PATH, "./key.pem")
DEFAULT_CROSSCERT = os.path.join(CERTS_PATH, "./crosscert.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") REQUEST = os.path.join(FILES_PATH, "./jreq.tsq")
RESPONS = os.path.join(FILES_PATH, "./jresp.tsr") RESPONS = os.path.join(FILES_PATH, "./jresp.tsr")