Skip to content

Commit d20232b

Browse files
committed
chore: restore integration.ps1
1 parent e6eb83b commit d20232b

File tree

1 file changed

+10
-42
lines changed

1 file changed

+10
-42
lines changed

ci/kokoro/windows/lib/integration.ps1

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# you may not use this file except in compliance with the License.
55
# You may obtain a copy of the License at
66
#
7-
# https://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
88
#
99
# Unless required by applicable law or agreed to in writing, software
1010
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,64 +14,32 @@
1414

1515
# Helper functions to run the minimal integration tests
1616

17-
$PROJECT_ROOT = (Get-Item -Path ".\").FullName
17+
$PROJECT_ROOT = (Get-Item -Path ".\" -Verbose).FullName
1818
$integration_tests_config="${PROJECT_ROOT}/ci/etc/integration-tests-config.ps1"
1919
. "${integration_tests_config}"
2020

2121
function Test-Integration-Enabled {
2222
if ((Test-Path env:KOKORO_GFILE_DIR) -and
2323
(Test-Path "${env:KOKORO_GFILE_DIR}/kokoro-run-key.json")) {
24-
return $True
24+
return $True
2525
}
2626
return $False
2727
}
2828

2929
function Install-Roots-Pem {
30-
$RootsPath = "${env:KOKORO_GFILE_DIR}/roots.pem"
31-
30+
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) " `
31+
"Downloading roots.pem [$_]"
3232
ForEach($attempt in (1, 2, 3)) {
33-
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) " `
34-
"Downloading roots.pem [$attempt]"
3533
try {
36-
# 1. Download the Mozilla Bundle
37-
$WebClient = New-Object System.Net.WebClient
38-
$MozillaCerts = $WebClient.DownloadString('https://curl.se/ca/cacert.pem')
39-
40-
# 2. Gather Windows System Root Certificates
41-
# This is required because some corporate/cloud environments inspect traffic
42-
# using an intermediate CA present in the system store but not in Mozilla's bundle.
43-
Write-Host "Gathering Windows System Root Certificates..."
44-
$WindowsCerts = ""
45-
$storesToCheck = @("Root", "CA")
46-
47-
foreach ($storeName in $storesToCheck) {
48-
$certStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $storeName, "LocalMachine"
49-
$certStore.Open('ReadOnly')
50-
51-
$certStore.Certificates | ForEach-Object {
52-
$cert = $_
53-
$b64 = [Convert]::ToBase64String($cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert), 'InsertLineBreaks')
54-
$header = "-----BEGIN CERTIFICATE-----"
55-
$footer = "-----END CERTIFICATE-----"
56-
$WindowsCerts += "$header`n$b64`n$footer`n"
57-
}
58-
$certStore.Close()
59-
}
60-
61-
# 3. Write Combined File with strict Unix Line Endings (\n)
62-
# BoringSSL/gRPC can sometimes have issues with Windows CRLF.
63-
Write-Host "Writing combined roots.pem with Unix LF line endings..."
64-
$FinalContent = $MozillaCerts + "`n" + $WindowsCerts
65-
$FinalContent = $FinalContent -replace "`r`n", "`n"
66-
67-
[System.IO.File]::WriteAllText($RootsPath, $FinalContent, [System.Text.Encoding]::ASCII)
68-
34+
(New-Object System.Net.WebClient).Downloadfile(
35+
'https://pki.google.com/roots.pem',
36+
"${env:KOKORO_GFILE_DIR}/roots.pem")
6937
return
7038
} catch {
71-
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) download/setup error: $_"
39+
Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) download error"
7240
}
7341
Start-Sleep -Seconds (60 * $attempt)
7442
}
75-
Write-Host -ForegroundColor Red "cannot setup roots.pem file."
43+
Write-Host -ForegroundColor Red "cannot download roots.pem file."
7644
Exit 1
7745
}

0 commit comments

Comments
 (0)