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

Fix all download failures claiming that the download was disabled by x-block-origin. #1513

Merged
merged 25 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion azure-pipelines/end-to-end-tests-dir/asset-caching.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ if (-not ($actual.Contains("[DEBUG] External asset downloads are blocked (x-bloc

# Testing asset caching && x-block-orgin promises when --debug is passed (disabled)
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
JavierMatosD marked this conversation as resolved.
Show resolved Hide resolved
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("install", "vcpkg-internal-e2e-test-port", "--overlay-ports=$PSScriptRoot/../e2e-ports", "--x-asset-sources=clear", "--downloads-root=$DownloadsRoot", "--debug"))
if (-not ($actual.Contains("[DEBUG] External asset downloads are allowed (x-block-origin is disabled)") -and $actual.Contains("[DEBUG] Asset cache is not configured"))) {
JavierMatosD marked this conversation as resolved.
Show resolved Hide resolved
throw "Failure: couldn't find expected debug promises (asset caching disabled + x-block-origin disabled)"
Expand All @@ -98,14 +99,16 @@ if (-not ($actual.Contains("[DEBUG] External asset downloads are allowed (x-bloc
# azurl (no), x-block-origin (no), asset-cache (n/a), download (fail)
# Expected: Download failure message, nothing about asset caching
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://localhost:1234/foobar.html"))
if (-not ($actual.Contains("error: https://localhost:1234/foobar.html: curl failed to download with exit code 7"))) {
throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (fail)"
}

#azurl (no), x-block-origin (no), asset-cache (n/a), download (sha-mismatch)
#Expected: Download message with "you might need to configure a proxy" and expected/actual sha
#Expected: Download message with expected/actual sha
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b", "--url", "https://example.com"))
if (-not ($actual.Contains("error: File does not have the expected hash:") -and
$actual.Contains("url: https://example.com") -and
Expand All @@ -117,6 +120,7 @@ if (-not ($actual.Contains("error: File does not have the expected hash:") -and
# azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed)
# Expected: Download success message, nothing about asset caching
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com"))
if (-not ($actual.Contains("Downloading example3.html") -and
$actual.Contains("Successfully downloaded example3.html."))) {
Expand All @@ -126,6 +130,7 @@ if (-not ($actual.Contains("Downloading example3.html") -and
# azurl (no), x-block-origin (yes), asset-cache (n/a), download (n/a)
# Expected: Download failure message, nothing about asset caching, x-block-origin complaint
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=clear;x-block-origin"))
if (-not ($actual.Contains("error: Missing example3.html and downloads are blocked by x-block-origin."))) {
throw "Failure: azurl (no), x-block-origin (yes), asset-cache (n/a), download (n/a)"
Expand All @@ -134,6 +139,7 @@ if (-not ($actual.Contains("error: Missing example3.html and downloads are block
# azurl (yes), x-block-origin (no), asset-cache (miss), download (fail)
# Expected: Download failure message, asset cache named, nothing about x-block-origin
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://localhost:1234/foobar.html", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"))
if (-not ($actual.Contains("Asset cache miss; downloading from https://localhost:1234/foobar.html") -and
$actual.Contains("Downloading example3.html") -and
Expand All @@ -145,6 +151,7 @@ if (-not ($actual.Contains("Asset cache miss; downloading from https://localhost
# azurl (yes), x-block-origin (no), asset-cache (hit), download (n/a)
# Expected: Download success message, asset cache named, nothing about x-block-origin
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"))
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"))
if (-not ($actual.Contains("Asset cache hit for example3.html; downloaded from: file://$AssetCache"))) {
Expand All @@ -154,6 +161,7 @@ if (-not ($actual.Contains("Asset cache hit for example3.html; downloaded from:
# azurl (yes), x-block-origin (no), asset-cache (miss), download (sha-mismatch)
# Expected: Download message with "you might need to configure a proxy" and expected/actual sha
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"))
if (-not ($actual.Contains("Asset cache miss; downloading from https://example.com") -and
$actual.Contains("Downloading example3.html") -and
Expand All @@ -169,6 +177,7 @@ if (-not ($actual.Contains("Asset cache miss; downloading from https://example.c
# azurl (yes), x-block-origin (no), asset-cache (miss), download (succeed)
# Expected: Download success message, asset cache upload, nothing about x-block-origin
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"))
if (-not ($actual.Contains("Asset cache miss; downloading from https://example.com") -and
$actual.Contains("Downloading example3.html") -and
Expand All @@ -180,6 +189,7 @@ if (-not ($actual.Contains("Asset cache miss; downloading from https://example.c
# azurl (yes), x-block-origin (yes), asset-cache (miss), download (n/a)
# Expected: Download failure message, which asset cache was tried, x-block-origin complaint
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite;x-block-origin"))
if (-not ($actual.Contains("Asset cache miss for example3.html and downloads are blocked by x-block-origin.") -and
$actual.Contains("error: Missing example3.html and downloads are blocked by x-block-origin."))) {
Expand All @@ -189,6 +199,7 @@ if (-not ($actual.Contains("Asset cache miss for example3.html and downloads are
# azurl (yes), x-block-origin (yes), asset-cache (hit), download (n/a)
# Expected: Download success message, asset cache named, nothing about x-block-origin
Refresh-TestRoot
$actual = $actual -replace "`r`n", "`n"
Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite"))
$actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a", "--url", "https://example.com", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite;x-block-origin"))
if (-not ($actual.Contains("Asset cache hit for example3.html; downloaded from: file://$AssetCache"))) {
Expand Down
10 changes: 5 additions & 5 deletions src/vcpkg/base/downloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,11 @@ namespace vcpkg
}
}

if (!block_origin_enabled)
if (block_origin_enabled)
{
msg::println_error(msgMissingAssetBlockOrigin, msg::path = download_path.filename());
}
else
{
if (urls.size() != 0)
{
Expand All @@ -1022,10 +1026,6 @@ namespace vcpkg
}
}
}
else
{
msg::println_error(msgMissingAssetBlockOrigin, msg::path = download_path.filename());
}

for (LocalizedString& error : errors)
{
Expand Down
Loading