Fix test CheckJSContent

This commit is contained in:
nicolas.dorier 2024-04-01 12:11:00 +09:00
parent 9ac0e982d6
commit db73b1f268
No known key found for this signature in database
GPG key ID: 6618763EF09186FE

View file

@ -423,9 +423,11 @@ retry:
[Trait("Fast", "Fast")] [Trait("Fast", "Fast")]
public async Task CheckJsContent() public async Task CheckJsContent()
{ {
var handler = new HttpClientHandler();
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli;
// This test verify that no malicious js is added in the minified files. // This test verify that no malicious js is added in the minified files.
// We should extend the tests to other js files, but we can do as we go... // We should extend the tests to other js files, but we can do as we go...
using var client = new HttpClient(); using var client = new HttpClient(handler);
var actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "bootstrap", "bootstrap.bundle.min.js").Trim(); var actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "bootstrap", "bootstrap.bundle.min.js").Trim();
var version = Regex.Match(actual, "Bootstrap v([0-9]+.[0-9]+.[0-9]+)").Groups[1].Value; var version = Regex.Match(actual, "Bootstrap v([0-9]+.[0-9]+.[0-9]+)").Groups[1].Value;
var expected = (await (await client.GetAsync($"https://cdn.jsdelivr.net/npm/bootstrap@{version}/dist/js/bootstrap.bundle.min.js")).Content.ReadAsStringAsync()).Trim(); var expected = (await (await client.GetAsync($"https://cdn.jsdelivr.net/npm/bootstrap@{version}/dist/js/bootstrap.bundle.min.js")).Content.ReadAsStringAsync()).Trim();