From b01415235edc3398d9783cd36f94a7f64d12ef13 Mon Sep 17 00:00:00 2001 From: Noah Gilson Date: Thu, 30 Jul 2026 10:52:34 -0700 Subject: [PATCH 1/2] Fix DownloadBlobAsync_RetriesOnFailure: use real content digest The blob digest-validation feature (CopyToAndVerifyAsync) is flowing into release/10.0.3xx from the VMR, but this test uses the placeholder digest 'sha256:testdigest1234'. That value is not valid hex, so once verification is enabled GetEncodedValue -> Convert.FromHexString throws FormatException when the retried download 'succeeds', failing the test on every leg. Use the actual SHA-256 of the mock content { 1, 2, 3 } (039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81) so digest verification passes, matching the fix already on main (b525d46). Landing this on release/10.0.3xx forward-flows the correction so codeflow PRs stop regressing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6267ed77-eef8-42c1-8799-1b107460fc61 --- test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs b/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs index 5ee29863abe7..ad781815a9f7 100644 --- a/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs +++ b/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs @@ -553,7 +553,7 @@ public async Task DownloadBlobAsync_RetriesOnFailure() var logger = _loggerFactory.CreateLogger(nameof(DownloadBlobAsync_RetriesOnFailure)); var repoName = "testRepo"; - var descriptor = new Descriptor(SchemaTypes.OciLayerGzipV1, "sha256:testdigest1234", 1234); + var descriptor = new Descriptor(SchemaTypes.OciLayerGzipV1, "sha256:039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81", 1234); var cancellationToken = CancellationToken.None; var mockRegistryAPI = new Mock(MockBehavior.Strict); From 6bfb3e4b558b789467a80834468881b2d6506def Mon Sep 17 00:00:00 2001 From: Noah Gilson Date: Thu, 30 Jul 2026 14:51:03 -0700 Subject: [PATCH 2/2] Align container digest tests with backflow fix Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9e4ad2d8-eae4-4af7-a524-6ad60a95f070 --- .../RegistryTests.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs b/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs index ad781815a9f7..737f646b8be4 100644 --- a/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs +++ b/test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs @@ -553,6 +553,9 @@ public async Task DownloadBlobAsync_RetriesOnFailure() var logger = _loggerFactory.CreateLogger(nameof(DownloadBlobAsync_RetriesOnFailure)); var repoName = "testRepo"; + // The digest must be the actual SHA-256 of the response bytes so that the internal + // branch's CopyToAndVerifyAsync digest validation passes after the download succeeds. + var responseBytes = new byte[] { 1, 2, 3 }; var descriptor = new Descriptor(SchemaTypes.OciLayerGzipV1, "sha256:039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81", 1234); var cancellationToken = CancellationToken.None; @@ -561,7 +564,7 @@ public async Task DownloadBlobAsync_RetriesOnFailure() .SetupSequence(api => api.Blob.GetStreamAsync(repoName, descriptor.Digest, cancellationToken)) .ThrowsAsync(new Exception("Simulated failure 1")) // First attempt fails .ThrowsAsync(new Exception("Simulated failure 2")) // Second attempt fails - .ReturnsAsync(new MemoryStream(new byte[] { 1, 2, 3 })); // Third attempt succeeds + .ReturnsAsync(new MemoryStream(responseBytes)); // Third attempt succeeds Registry registry = new(repoName, logger, mockRegistryAPI.Object, null, () => TimeSpan.Zero); @@ -593,7 +596,7 @@ public async Task DownloadBlobAsync_ThrowsAfterMaxRetries() var logger = _loggerFactory.CreateLogger(nameof(DownloadBlobAsync_ThrowsAfterMaxRetries)); var repoName = "testRepo"; - var descriptor = new Descriptor(SchemaTypes.OciLayerGzipV1, "sha256:testdigest1234", 1234); + var descriptor = new Descriptor(SchemaTypes.OciLayerGzipV1, "sha256:a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2", 1234); var cancellationToken = CancellationToken.None; var mockRegistryAPI = new Mock(MockBehavior.Strict);