diff options
author | scivision <scivision@users.noreply.github.com> | 2023-02-10 02:53:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-02-10 17:22:00 (GMT) |
commit | 17b47da3d8988c5723fb6083e48ed94080442e1d (patch) | |
tree | b4e22396e46dbd2b06446a1471eddf737f974b4f | |
parent | 9b7d086220928cd6106ee2d220ab26deef5ba2a8 (diff) | |
download | CMake-17b47da3d8988c5723fb6083e48ed94080442e1d.zip CMake-17b47da3d8988c5723fb6083e48ed94080442e1d.tar.gz CMake-17b47da3d8988c5723fb6083e48ed94080442e1d.tar.bz2 |
Tests: Add test for file(DOWNLOAD) with TLS_VERIFY
Occasionally curl updates introduce errors in https verification.
Add an explicit test for this capability, activated by an undocumented
option that we can use in CI to specify a URL to test.
Co-authored-by: Brad King <brad.king@kitware.com>
Fixes: #24405
Issue: #24147
Issue: #24398
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good.cmake | 6 |
6 files changed, 28 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a7a8295..930122c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -469,7 +469,15 @@ add_RunCMake_test(ctest_fixtures) add_RunCMake_test(define_property) add_RunCMake_test(file -DCYGWIN=${CYGWIN} -DMSYS=${MSYS}) add_RunCMake_test(file-CHMOD -DMSYS=${MSYS}) -add_RunCMake_test(file-DOWNLOAD -DCMake_TEST_NO_NETWORK=${CMake_TEST_NO_NETWORK}) +foreach(var + CMake_TEST_NO_NETWORK + CMake_TEST_TLS_VERIFY_URL + ) + if(DEFINED ${var}) + list(APPEND file-DOWNLOAD_ARGS -D${var}=${${var}}) + endif() +endforeach() +add_RunCMake_test(file-DOWNLOAD) add_RunCMake_test(file-RPATH -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(find_file) add_RunCMake_test(find_library -DCYGWIN=${CYGWIN} -DMSYS=${MSYS}) diff --git a/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake b/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake index 565f440..d757eea 100644 --- a/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake @@ -24,3 +24,8 @@ run_cmake(SHOW_PROGRESS) if(NOT CMake_TEST_NO_NETWORK) run_cmake(bad-hostname) endif() + +if(CMake_TEST_TLS_VERIFY_URL) + run_cmake(TLS_VERIFY-bad) + run_cmake_with_options(TLS_VERIFY-good -Durl=${CMake_TEST_TLS_VERIFY_URL}) +endif() diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt new file mode 100644 index 0000000..8f5d437 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt @@ -0,0 +1 @@ +-- (60;"SSL peer certificate or SSH remote key was not OK"|35;"SSL connect error") diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake new file mode 100644 index 0000000..333f990 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake @@ -0,0 +1,6 @@ +file(DOWNLOAD https://expired.badssl.com TLS_VERIFY 1 STATUS status LOG log) +message(STATUS "${status}") +list(GET status 0 code) +if(NOT code MATCHES "^(35|60)$") + message("${log}") +endif() diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good-stdout.txt new file mode 100644 index 0000000..348bb17 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good-stdout.txt @@ -0,0 +1 @@ +-- 0;"No error" diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good.cmake b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good.cmake new file mode 100644 index 0000000..279eb69 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good.cmake @@ -0,0 +1,6 @@ +file(DOWNLOAD ${url} TLS_VERIFY 1 STATUS status LOG log) +message(STATUS "${status}") +list(GET status 0 code) +if(NOT code EQUAL 0) + message("${log}") +endif() |