Skip to content

Commit

Permalink
Add Firefox Nightly Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Mar 15, 2022
1 parent b857159 commit 8d7f53a
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,43 @@ task:
depends_on:
- "Compile Go latest linux amd64"

task:
name: "firefox $CI_CHANNEL windows"
compute_engine_instance:
image_project: windows-cloud
image: family/windows-2022
platform: windows
choco_script:
- powershell -ExecutionPolicy Unrestricted -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin\\"
install_script:
- SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin\\"
- choco install %CI_PACKAGE% --yes --debug --verbose --pre
- curl -o pkcs11mod.tar.gz --location https://api.cirrus-ci.com/v1/artifact/build/%CIRRUS_BUILD_ID%/Compile%%%%20Go%%%%20latest%%%%20windows%%%%20%GOARCH%/binaries/dist/pkcs11mod.tar.gz
- tar -xf pkcs11mod.tar.gz
test_script:
- SET PATH=%PATH%;%cd%
- powershell -ExecutionPolicy Unrestricted -File "testdata/ci-firefox-tests.ps1"
matrix:
- env:
GOARCH: "amd64"
CI_CHANNEL: "Nightly"
CI_PACKAGE: "firefox-nightly"
CI_MAIN_MODULE: "C:\\Program Files\\Firefox Nightly\\nssckbi.dll"
CI_BAK_MODULE: "C:\\Program Files\\Firefox Nightly\\nssckbi.orig.dll"
CI_MAIN_EXE: "C:\\Program Files\\Firefox Nightly\\firefox.exe"
NSPR_LOG_MODULES: "all:3"
- env:
GOARCH: "amd64"
CI_CHANNEL: "ESR"
CI_PACKAGE: "firefoxesr"
CI_MAIN_MODULE: "C:\\Program Files\\Mozilla Firefox\\nssckbi.dll"
CI_BAK_MODULE: "C:\\Program Files\\Mozilla Firefox\\nssckbi.orig.dll"
CI_MAIN_EXE: "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
NSPR_LOG_MODULES: "all:3"
MOZ_WEBRENDER: "0"
depends_on:
- "Compile Go latest windows amd64"

task:
name: "gnutls-cli"
container:
Expand Down
27 changes: 27 additions & 0 deletions testdata/assert-proxy-log.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
param (
$desired
)

if ( ("$desired" -ne "present" ) -and ( "$desired" -ne "missing" ) ) {
Write-Host "Invalid DESIRED value; should be present or missing"
exit 1
}

if ( ( Test-Path -Path "$Env:USERPROFILE/pkcs11mod.log" ) -Or ( Test-Path -Path "./pkcs11mod.log" ) -Or ( Test-Path -Path "$Env:APPDATA/pkcs11mod.log" ) ) {
$result="present"
}
else {
$result="missing"
}

Remove-Item -Force "$Env:USERPROFILE/pkcs11mod.log"
Remove-Item -Force "./pkcs11mod.log"
Remove-Item -Force "$Env:APPDATA/pkcs11mod.log"

if ( "$result" -ne "$desired" ) {
Write-Host "Log test failed"
Write-Host "Got $result, wanted $desired"
exit 1
}

exit 0
91 changes: 91 additions & 0 deletions testdata/ci-firefox-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Write-Host "===== Default System CKBI ====="

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "www.namecoin.org" -desired "success"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "missing"
If (!$?) {
exit 222
}

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "untrusted-root.badssl.com" -desired "fail"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "missing"
If (!$?) {
exit 222
}

Write-Host "===== Deleted System CKBI ====="

Move-Item -Path "$Env:CI_MAIN_MODULE" -Destination "$Env:CI_BAK_MODULE"

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "www.namecoin.org" -desired "fail"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "missing"
If (!$?) {
exit 222
}

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "untrusted-root.badssl.com" -desired "fail"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "missing"
If (!$?) {
exit 222
}

# TODO: No env var, -desired "missing" default target

# TODO: Env var pointing to -desired "missing" target

Write-Host "===== System CKBI via pkcs11proxy ====="

$Env:PKCS11PROXY_CKBI_TARGET = "$Env:CI_BAK_MODULE"
Copy-Item pkcs11proxy.dll -Destination "$Env:CI_MAIN_MODULE"

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "www.namecoin.org" -desired "success"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "present"
If (!$?) {
exit 222
}

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "untrusted-root.badssl.com" -desired "fail"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "present"
If (!$?) {
exit 222
}

Write-Host "===== System CKBI via p11proxy ====="

$Env:P11PROXY_CKBI_TARGET = "$Env:CI_BAK_MODULE"
Copy-Item p11proxy.dll -Destination "$Env:CI_MAIN_MODULE"

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "www.namecoin.org" -desired "success"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "present"
If (!$?) {
exit 222
}

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/try-firefox-connect.ps1" -server_host "untrusted-root.badssl.com" -desired "fail"
If (!$?) {
exit 222
}
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "present"
If (!$?) {
exit 222
}
35 changes: 35 additions & 0 deletions testdata/try-firefox-connect.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
param (
$server_host,
$desired
)

Write-Host "$server_host"

if ( ("$desired" -ne "success" ) -and ( "$desired" -ne "fail" ) ) {
Write-Host "Invalid DESIRED value; should be success or fail"
exit 1
}

# Nuke whatever cached state might exist...
Remove-Item -Recurse -Force "$Env:APPDATA/Mozilla"

& "$Env:CI_MAIN_EXE" --screenshot "https://$server_host"
Start-Sleep -seconds 10
Stop-Process -Name "firefox"

if ( Test-Path -Path "screenshot.png" ) {
$result = "success"
}
else {
$result = "fail"
}

Remove-Item -Force "screenshot.png"

if ( "$result" -ne "$desired" ) {
Write-Host "TLS test failed"
Write-Host "Got $result, wanted $desired"
exit 1
}

exit 0

0 comments on commit 8d7f53a

Please sign in to comment.