Replace nuget.org feed URLs with packagefeedproxy in tests - #55463
Replace nuget.org feed URLs with packagefeedproxy in tests#55463marcpopMSFT wants to merge 14 commits into
Conversation
Swap api.nuget.org/v3/index.json to packagefeedproxy.microsoft.io in template engine, dotnet-new integration, and dotnet-format test infrastructure to reduce direct nuget.org dependency in CI/PR pipelines. Tests that use non-standard NuGet endpoints (flat-container, direct search API) are left unchanged as they require code rewrites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Instead of hardcoding the api.nuget.org/v3-flatcontainer URL, resolve the PackageBaseAddress endpoint from the proxy's V3 service index. This follows the NuGet V3 protocol properly and works with the packagefeedproxy.microsoft.io feed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR reduces CI/test reliance on https://api.nuget.org by switching test-only NuGet feed usage to the packagefeedproxy.microsoft.io V3 endpoint, and updates affected approval snapshots accordingly. It also refactors one test helper to derive the package base address from the feed’s V3 service index instead of hardcoding the nuget.org flat-container URL.
Changes:
- Replaced nuget.org V3 feed URLs with
https://packagefeedproxy.microsoft.io/nuget/v3/index.jsonacross multiple test suites and a dotnet-format test asset. - Updated approval
.verified.txtsnapshots that include the feed URL in output. - Rewrote
GetLatestVersion()inDotnetNewDetailsTest.Approval.csto resolvePackageBaseAddressfrom the V3 service index.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/TestAssets/dotnet-format/for_analyzer_formatter/analyzer_project/NuGet.config | Points the test asset restore source at packagefeedproxy instead of api.nuget.org. |
| test/TemplateEngine/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/NuGetTests.cs | Uses packagefeedproxy V3 service index for TemplateDiscovery integration test. |
| test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/PackageManager.cs | Updates central NuGet feed constant used by template tests to packagefeedproxy. |
| test/TemplateEngine/Microsoft.TemplateEngine.IDE.IntegrationTests/TemplatePackagesTests.cs | Switches install source URL and expected NuGetSource detail to packagefeedproxy. |
| test/TemplateEngine/Microsoft.TemplateEngine.Edge.UnitTests/NuGetApiPackageManagerTests.cs | Updates additional source list to packagefeedproxy. |
| test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs | Updates --nuget-source / --add-source arguments to packagefeedproxy. |
| test/dotnet-new.IntegrationTests/DotnetNewDetailsTest.Approval.cs | Updates inline NuGet.Config feed URL and refactors latest-version lookup to use service index. |
| test/dotnet-new.IntegrationTests/Approvals/DotnetNewDetailsTest.CanDisplayDetails_RemotePackage_NuGetFeedNoVersion.verified.txt | Snapshot updated for new feed URL. |
| test/dotnet-new.IntegrationTests/Approvals/DotnetNewDetailsTest.CanDisplayDetails_InstalledPackage_NuGetFeed.verified.txt | Snapshot updated for new feed URL. |
The NuGet V3 service index spec allows @type to be either a string or an array of strings. Update GetLatestVersion() to handle both cases and throw a clear exception if PackageBaseAddress is not found. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
|
We need an internal test run first before merging this and we'll need this in all branches. The internal pipelines are having issues at the moment that look like infra. Will need to ping FR. |
- Category A: Remove assertions on Reserved/Owners fields not returned by the proxy feed; update .verified.txt baselines accordingly - Category B: Add data.nuget.org as second source for vulnerability tests so VulnerabilityInfo metadata is available - Category C: Accept any non-empty NuGetSource URL (proxy may normalize back to api.nuget.org internally) - Category D: Pass --nuget-source to OtherFeed detail tests so version resolution uses the same feed as GetLatestVersion() - Category E: Relax CanReadPackageInfo assertions for TotalHits, Reserved, Owners, and IconUrl that differ on the proxy Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
JoeRobich
left a comment
There was a problem hiding this comment.
dotnet-format change looks good.
Remove extra leading whitespace on _vulnerabilitySources field declaration that triggered IDE0055 (Fix formatting) as error-on-CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
…s quirk, separate vulnerability source - Rewrite GetLatestVersion() to use SearchQueryService instead of PackageBaseAddress/flat-container to match dotnet-new behavior - Fix CanReadPackageInfo: proxy returns TotalHits=0 but Data has entries, assert on Data emptiness instead - Use api.nuget.org for vulnerability metadata tests (proxy lacks it in registration blobs) - Add scrubbers for NuGetFeedNoVersion baseline: version placeholder and template list truncation for cross-feed compatibility Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
- CanReadPackageInfo: Add fallback to versioned type SearchQueryService/3.0.0-beta when base type prefix matching returns no entries from proxy service index - NuGetFeedNoVersion: Remove Templates section from baseline since proxy feed does not include template listing in package details output - NuGetApiPackageManagerTests: Switch vulnerability sources from api.nuget.org to data.nuget.org/v3/index.json (preferred read-only audit data source) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
- Switch _vulnerabilitySources from data.nuget.org to proxy feed (data.nuget.org is not a full V3 feed and lacks RegistrationsBaseUrl, causing NullReferenceException in GetPackageMetadataAsync) - Relax TotalDownloads assertion since proxy returns 0 for some packages Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
MSTest Assert does not have IsGreaterThanOrEqual. Use FluentAssertions BeGreaterThanOrEqualTo which is already imported in this test file. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
The proxy does not include vulnerability data in its registration blobs, so the HasVulnerabilities tests must use api.nuget.org (read-only metadata). All other tests continue using the proxy for package download and search. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
Replace packagefeedproxy.microsoft.io URLs with the dotnet-public ADO feed (pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json) across all affected test files. Package replacements (not available in dotnet-public): - Uno.ProjectTemplates.Dotnet -> Microsoft.Android.Templates - Take.Blip.Client.Templates -> Microsoft.Android.Templates - Boxed.Templates -> Microsoft.DotNet.Web.ProjectTemplates.10.0 - Sln -> Microsoft.DotNet.Common.ProjectTemplates.5.0 - Functions.Worker.ProjectTemplates -> Microsoft.Azure.WebJobs.ProjectTemplates Other changes: - Use api.nuget.org for vulnerability data source (read-only audit data) - Relax metadata assertions (Owners/Reserved) for dotnet-public behavior - Remove proxy-specific SearchQueryService fallback in NuGetTests - Update approval baselines for Android Templates package Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d86dfdd8-d040-4ddf-b190-19f27d044c4c
Motivation
To reduce direct dependency on api.nuget.org in CI/PR pipelines, this PR migrates test infrastructure to use
https://packagefeedproxy.microsoft.io/nuget/v3/index.json-- a controlled proxy that mirrors nuget.org through standard NuGet V3 protocol.Approach
Simple URL swaps for tests that use standard V3 feed operations (restore, install, package download via NuGet client protocol):
PackageManager.cs- centralNuGetOrgFeedconstant used by many template integration testsNuGetApiPackageManagerTests.cs- additional sources arrayTemplatePackagesTests.cs- install request source URL and its assertionDotnetNewInstallTests.cs---nuget-source/--add-sourceparameters (3 occurrences)DotnetNewDetailsTest.Approval.cs- inline NuGet.config and--nuget-sourceparameterNuGetTests.cs(TemplateDiscovery) - feed URL constantanalyzer_project/NuGet.config- dotnet-format test asset.verified.txtapproval files updated to match new expected outputProtocol-compliant rewrite for
GetLatestVersion()which previously hardcoded theapi.nuget.org/v3-flatcontainerendpoint directly. It now resolves thePackageBaseAddressresource from the V3 service index, following proper NuGet protocol and working with any compliant feed.What was NOT changed
NuGetInstallerTests.cs- URLs are test data (metadata values parsed/validated), not network callsAllCommonItemsCreateapproval files - these verify template OUTPUT (what users get fromdotnet new nugetconfig), not test feedsNugetSearchApiRequestTests.cs- URL construction tests with no network callsDotnetNewDetailsTest.CanDisplayDetails_RemotePackage_NuGetFeedWithVersion- test is[Ignore]dNotes for reviewers
.verified.txtapproval files may need regeneration if the proxy reports a different feed display name than expected. Running the affected tests and accepting new snapshots would fix this.GetLatestVersionrewrite usesStartsWith("PackageBaseAddress")to match the resource type, handling versioned type strings likePackageBaseAddress/3.0.0.