From 8b0169fe2b807204d606eeabb701e8f410944647 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 29 Mar 2024 12:41:10 -0400 Subject: file(DOWNLOAD|UPLOAD): Add test covering CMAKE_TLS_VERIFY cmake variable --- .../file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt | 6 ++++- Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake | 29 +++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt index 8f5d437..72ab8f4 100644 --- a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad-stdout.txt @@ -1 +1,5 @@ --- (60;"SSL peer certificate or SSH remote key was not OK"|35;"SSL connect error") +-- def-0: 0;"No error" +-- var-0: 0;"No error" +-- var-1: (60;"SSL peer certificate or SSH remote key was not OK"|35;"SSL connect error") +-- opt-0: 0;"No error" +-- opt-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 index 333f990..ed19bd6 100644 --- a/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERIFY-bad.cmake @@ -1,6 +1,23 @@ -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() +function(download case) + file(DOWNLOAD https://expired.badssl.com ${ARGN} STATUS status LOG log) + message(STATUS "${case}: ${status}") + if(case MATCHES "1$" AND NOT status MATCHES "^(35|60);") + message("${log}") + endif() +endfunction() + +# The default is OFF. +unset(CMAKE_TLS_VERIFY) +download(def-0) + +# The cmake variable overrides the default. +set(CMAKE_TLS_VERIFY 0) +download(var-0) +set(CMAKE_TLS_VERIFY 1) +download(var-1) + +# The explicit argument overrides the cmake variable. +set(CMAKE_TLS_VERIFY 1) +download(opt-0 TLS_VERIFY 0) +set(CMAKE_TLS_VERIFY 0) +download(opt-1 TLS_VERIFY 1) -- cgit v0.12