Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Add TLS integration tests #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@ task:
upload_script:
- curl -s -X POST --data-binary @build64/bin/ncdns-v0.0.10.3-win64-install.exe http://$CIRRUS_HTTP_CACHE_HOST/cross_compile_bin

# TODO: functional/integration tests
task:
name: TLS Handshake Tests
windows_container:
image: cirrusci/windowsservercore:2019
depends_on:
- "Cross-Compile"
install_script:
- curl -o ncdns-v0.0.10.3-win64-install.exe http://%CIRRUS_HTTP_CACHE_HOST%/cross_compile_bin
- ncdns-v0.0.10.3-win64-install.exe /S
test_script:
- SET PATH=%PATH%;%cd%
- powershell -ExecutionPolicy Unrestricted -File "testdata/ci-all-tests.ps1"
env:
GOX_TAGS: ""
GO_VERSION: latest

task:
# Cirrus Artifact Upload
Expand Down
21 changes: 21 additions & 0 deletions testdata/all-tls-handshake-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Write-Host "----- Running TLS handshake tests -----"

Write-Host "----- DNS website -----"

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-tls-handshake.ps1" "-url" "https://www.namecoin.org/"
If (!$?) {
exit 222
}

Write-Host "----- Namecoin website, valid dehydrated certificate -----"

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-tls-handshake.ps1" "-url" "https://namecoin.bit/"
If (!$?) {
exit 222
}

# TODO: test DNS and Namecoin websites with invalid certs.

# all done
Write-Host "----- All TLS handshake tests passed -----"
exit 0
32 changes: 32 additions & 0 deletions testdata/try-tls-handshake.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Warning! This script must be run in a fresh PowerShell process. Otherwise,
# PowerShell will cache any successful cert validation results, so you'll be
# getting fictitious results.

param (
$url,
[switch] $fail
)

$should_succeed = -not $fail

try {
Invoke-WebRequest -Uri "$url" -Method GET -UseBasicParsing
$success = $?
if ( ( $success ) -ne ( $should_succeed ) ) {
Write-Host "TLS test failed"
exit 111
}
}
catch {
if ( $should_succeed ) {
Write-Host "TLS test failed: $Error"
exit 111
}
else {
Write-Host "Good, TLS handshake rejected: $Error"
exit 0
}
}

Write-Host "Good; TLS test passed."
exit 0