Skip to content

Replace nuget.org feed URLs with packagefeedproxy in tests - #55463

Open
marcpopMSFT wants to merge 14 commits into
mainfrom
marcpopmsft-nuget-org-test-dependency-audit
Open

Replace nuget.org feed URLs with packagefeedproxy in tests#55463
marcpopMSFT wants to merge 14 commits into
mainfrom
marcpopmsft-nuget-org-test-dependency-audit

Conversation

@marcpopMSFT

Copy link
Copy Markdown
Member

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 - central NuGetOrgFeed constant used by many template integration tests
  • NuGetApiPackageManagerTests.cs - additional sources array
  • TemplatePackagesTests.cs - install request source URL and its assertion
  • DotnetNewInstallTests.cs - --nuget-source / --add-source parameters (3 occurrences)
  • DotnetNewDetailsTest.Approval.cs - inline NuGet.config and --nuget-source parameter
  • NuGetTests.cs (TemplateDiscovery) - feed URL constant
  • analyzer_project/NuGet.config - dotnet-format test asset
  • Two .verified.txt approval files updated to match new expected output

Protocol-compliant rewrite for GetLatestVersion() which previously hardcoded the api.nuget.org/v3-flatcontainer endpoint directly. It now resolves the PackageBaseAddress resource 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 calls
  • AllCommonItemsCreate approval files - these verify template OUTPUT (what users get from dotnet new nugetconfig), not test feeds
  • NugetSearchApiRequestTests.cs - URL construction tests with no network calls
  • DotnetNewDetailsTest.CanDisplayDetails_RemotePackage_NuGetFeedWithVersion - test is [Ignore]d

Notes for reviewers

  • The .verified.txt approval 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.
  • The GetLatestVersion rewrite uses StartsWith("PackageBaseAddress") to match the resource type, handling versioned type strings like PackageBaseAddress/3.0.0.

marcpopMSFT and others added 2 commits July 24, 2026 12:46
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>
Copilot AI review requested due to automatic review settings July 24, 2026 20:01
@marcpopMSFT
marcpopMSFT requested review from a team as code owners July 24, 2026 20:01
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json across multiple test suites and a dotnet-format test asset.
  • Updated approval .verified.txt snapshots that include the feed URL in output.
  • Rewrote GetLatestVersion() in DotnetNewDetailsTest.Approval.cs to resolve PackageBaseAddress from 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.

Comment thread test/dotnet-new.IntegrationTests/DotnetNewDetailsTest.Approval.cs Outdated
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
@marcpopMSFT

Copy link
Copy Markdown
Member Author

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
@marcpopMSFT
marcpopMSFT requested a review from a team as a code owner July 27, 2026 23:20

@JoeRobich JoeRobich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet-format change looks good.

marcpopMSFT and others added 10 commits July 28, 2026 11:13
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants