Skip to content

Commit

Permalink
Add certutil Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Mar 27, 2022
1 parent 32ab130 commit b7e165b
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ task:
depends_on:
- "Compile Go latest linux amd64"

task:
name: "certutil windows"
windows_container:
image: cirrusci/windowsservercore:2019
cpu: 1
memory: 1G
install_script:
- SET PATH=%PATH%;%cd%
- powershell -ExecutionPolicy Unrestricted -File "testdata/download-certutil.ps1"
- 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-certutil-tests.ps1"
env:
GOARCH: "amd64"
depends_on:
- "Compile Go latest windows amd64"

task:
name: "chromium $CI_DISTRO"
matrix:
Expand Down
68 changes: 68 additions & 0 deletions testdata/ci-certutil-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
$ErrorActionPreference = "Stop"

Write-Host "===== init DB ====="

& "./certutil.exe" -N -d .

Write-Host "===== Default System CKBI ====="

& "./certutil.exe" -L -d . -h all | Tee-Object -FilePath "list-all-default.txt"
If (!$?) {
exit 222
}

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "missing"
If (!$?) {
exit 222
}

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

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

& "./certutil.exe" -L -d . -h all | Tee-Object -FilePath "list-all-pkcs11proxy.txt"
If (!$?) {
exit 222
}

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

$pkcs11proxydiff = Compare-Object -CaseSensitive -SyncWindow 0 (Get-Content "list-all-default.txt") (Get-Content "list-all-pkcs11proxy.txt")
Write-Host $pkcs11proxydiff

if ($pkcs11proxydiff.Length -gt 0) {
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/dump-proxy-log-fail.ps1"
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"

& "./certutil.exe" -L -d . -h all | Tee-Object -FilePath "list-all-p11proxy.txt"
If (!$?) {
exit 222
}

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

$p11proxydiff = Compare-Object -CaseSensitive -SyncWindow 0 (Get-Content "list-all-default.txt") (Get-Content "list-all-p11proxy.txt")
Write-Host $p11proxydiff

if ($p11proxydiff.Length -gt 0) {
& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/dump-proxy-log-fail.ps1"
exit 222
}

& "powershell" "-ExecutionPolicy" "Unrestricted" "-File" "testdata/assert-proxy-log.ps1" -desired "present"
If (!$?) {
exit 222
}

6 changes: 6 additions & 0 deletions testdata/download-certutil.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ErrorActionPreference = "Stop"

$TBBVersion = ( ( Invoke-WebRequest -UseBasicParsing https://nightlies.tbb.torproject.org/nightly-builds/tor-browser-builds/ ).Links | Where-Object {$_.href -match 'tbb'} ).href

curl -o "mar-tools.zip" "https://nightlies.tbb.torproject.org/nightly-builds/tor-browser-builds/$TBBVersionnightly-windows-x86_64/mar-tools-win64.zip"
tar -xf "mar-tools.zip"

0 comments on commit b7e165b

Please sign in to comment.