summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/file-DOWNLOAD
diff options
context:
space:
mode:
authorscivision <scivision@users.noreply.github.com>2023-02-10 02:53:02 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-10 17:22:00 (GMT)
commit17b47da3d8988c5723fb6083e48ed94080442e1d (patch)
treeb4e22396e46dbd2b06446a1471eddf737f974b4f /Tests/RunCMake/file-DOWNLOAD
parent9b7d086220928cd6106ee2d220ab26deef5ba2a8 (diff)
downloadCMake-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
Diffstat (limited to 'Tests/RunCMake/file-DOWNLOAD')
-rw-r--r--Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt1
-rw-r--r--Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake6
-rw-r--r--Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good-stdout.txt1
-rw-r--r--Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-good.cmake6
5 files changed, 19 insertions, 0 deletions
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()