-
Notifications
You must be signed in to change notification settings - Fork 335
Fix all download failures claiming that the download was disabled by x-block-origin. #1513
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d269012
stop saying x-block-origin enabled when it is not
8f9ade9
remove unused message
1d44ff4
regen message map
fb140fa
fix test
1f2787f
format:
2202f1e
format
29c815c
show x-block-origin is set
220e737
undo debug change to test
02fb23b
format
0ab5003
add test cases for smoke tests
ba76a76
generate mesages
160463e
change to macos-13
505e8dd
fix unrecognized escape sequence
e8399d6
Merge remote-tracking branch 'upstream/main' into fix_asset_cache_bug
188d7b8
use .Contains instead of regex pattern matching
c9af32b
Accidentally removed a bit of test code that shouldn't have been
fec25ee
update test case to match new output
a92df59
respond to Billy Review
f91cbcc
add newlines
9be6a3a
add proxy message
d2fe966
remove newline replacements
a8741ff
modify proxy message
c513777
generate message map
d5f72ac
remove newline replacement
e93ce22
Format and regenerate messages
JavierMatosD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,8 @@ $actual = $actual -replace "`r`n", "`n" | |
| $expected = @( | ||
| "A suitable version of .* was not found \(required v[0-9\.]+\)." | ||
| "Asset cache miss; downloading from .*" | ||
| "Downloading .*" | ||
| "Successfully downloaded .*." | ||
| "Successfully stored .* to .*." | ||
| ) -join "`n" | ||
|
|
||
|
|
@@ -82,26 +84,116 @@ if (-not ($actual -match $expected)) { | |
| # Testing asset caching && x-block-orgin promises when --debug is passed (enabled) | ||
| Refresh-TestRoot | ||
| $actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("install", "vcpkg-internal-e2e-test-port", "--overlay-ports=$PSScriptRoot/../e2e-ports", "--x-asset-sources=x-azurl,file://$AssetCache,,readwrite;x-block-origin", "--downloads-root=$DownloadsRoot", "--debug")) | ||
| $actual = $actual -replace "`r`n", "`n" | ||
|
|
||
| # Define the regex pattern that accounts for multiline input | ||
| $expectedPattern = "(?s)" + | ||
| ".*\[DEBUG\] External asset downloads are blocked \(x-block-origin is enabled\)\.\.\.?" + | ||
| ".*\[DEBUG\] Asset caching is enabled\..*" | ||
|
|
||
| if (-not ($actual -match $expectedPattern)) { | ||
| if (-not ($actual.Contains("[DEBUG] External asset downloads are blocked (x-block-origin is enabled)") -and $actual.Contains("[DEBUG] Asset caching is enabled."))) { | ||
| throw "Failure: couldn't find expected debug promises (asset caching enabled + x-block-origin enabled)" | ||
| } | ||
|
|
||
| # Testing asset caching && x-block-orgin promises when --debug is passed (disabled) | ||
| Refresh-TestRoot | ||
| $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)" | ||
| } | ||
|
|
||
| # azurl (no), x-block-origin (no), asset-cache (n/a), download (fail) | ||
| # Expected: Download failure message, nothing about asset caching | ||
| Refresh-TestRoot | ||
| $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 the "you might need to configure a proxy" message and with expected/actual sha | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Refresh-TestRoot | ||
| $actual = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("x-download", "$downloadsRoot/example3.html", "--sha512", "d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b", "--url", "https://example.com")) | ||
| if (-not ($actual.Contains("Failed to download example3.html.") -and | ||
| $actual.Contains("If you are using a proxy, please ensure your proxy settings are correct.") -and | ||
| $actual.Contains("error: File does not have the expected hash:") -and | ||
| $actual.Contains("url: https://example.com") -and | ||
| $actual.Contains("Expected hash: d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b") -and | ||
| $actual.Contains("Actual hash: d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a"))) { | ||
| throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (sha-mismatch)" | ||
| } | ||
|
|
||
| # azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed) | ||
| # Expected: Download success message, nothing about asset caching | ||
| Refresh-TestRoot | ||
| $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."))) { | ||
| throw "Failure: azurl (no), x-block-origin (no), asset-cache (n/a), download (succeed)" | ||
| } | ||
|
|
||
| # 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 = 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)" | ||
| } | ||
|
|
||
| # 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 = 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 | ||
| $actual.Contains("error: file://$AssetCache") -and | ||
| $actual.Contains("curl failed to download with exit code 37"))) { | ||
| throw "Failure: azurl (yes), x-block-origin (no), asset-cache (miss), download (fail)" | ||
| } | ||
|
|
||
| # 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"))) { | ||
| throw "Failure: azurl (yes), x-block-origin (no), asset-cache (hit), download (n/a)" | ||
| } | ||
|
|
||
| # 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 = 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 | ||
| $actual.Contains("error: file://$AssetCache") -and | ||
| $actual.Contains("curl failed to download with exit code 37") -and | ||
| $actual.Contains("error: File does not have the expected hash:") -and | ||
| $actual.Contains("url: https://example.com") -and | ||
| $actual.Contains("Expected hash: d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73b") -and | ||
| $actual.Contains("Actual hash: d06b93c883f8126a04589937a884032df031b05518eed9d433efb6447834df2596aebd500d69b8283e5702d988ed49655ae654c1683c7a4ae58bfa6b92f2b73a"))) { | ||
| throw "Failure: azurl (yes), x-block-origin (no), asset-cache (miss), download (sha-mismatch)" | ||
| } | ||
|
|
||
| $expectedPattern = "(?s)" + | ||
| ".*\[DEBUG\] External asset downloads are allowed \(x-block-origin is disabled\)\.\.\.?" + | ||
| ".*\[DEBUG\] Asset cache is not configured.*" | ||
| # 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 = 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 | ||
| $actual.Contains("Successfully downloaded example3.html.") -and | ||
| $actual.Contains("Successfully stored example3.html to file://$AssetCache"))) { | ||
| throw "Failure: azurl (yes), x-block-origin (no), asset-cache (miss), download (succeed)" | ||
| } | ||
|
|
||
| if (-not ($actual -match $expectedPattern)) { | ||
| throw "Failure: couldn't find expected debug promises (asset caching disabled + x-block-origin disabled)" | ||
| # 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 = 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."))) { | ||
| throw "Failure: azurl (yes), x-block-origin (yes), asset-cache (miss), download (n/a)" | ||
| } | ||
|
|
||
| # 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 | ||
| 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"))) { | ||
| throw "Failure: azurl (yes), x-block-origin (yes), asset-cache (hit), download (n/a)" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.