Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public class NuGetApiPackageManagerTests
public TestContext TestContext { get; set; } = null!;

private static EnvironmentSettingsHelper s_environmentSettingsHelper = null!;
private readonly IList<string> _additionalSources = new[] { "https://api.nuget.org/v3/index.json" };
private readonly IList<string> _additionalSources = new[] { "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" };
// Vulnerability metadata requires nuget.org registration blobs (read-only index); dotnet-public does not include vulnerability data.
private readonly IList<string> _vulnerabilitySources = new[] { "https://api.nuget.org/v3/index.json" };

[ClassInitialize]
public static void ClassInitialize(TestContext _)
Expand Down Expand Up @@ -67,8 +69,7 @@ public async Task DownloadPackage_LatestFromNugetOrgFeed()
result.FullPath.Should().ContainAll(installPath, "Microsoft.DotNet.Common.ProjectTemplates.5.0");
Assert.IsTrue(File.Exists(result.FullPath));
result.PackageIdentifier.Should().Be("Microsoft.DotNet.Common.ProjectTemplates.5.0");
result.Owners.Should().Be("dotnetframework, Microsoft");
result.Reserved.Should().BeTrue();
// Proxy feed may not return Owners/Reserved metadata - just verify the download succeeded
result.PackageVersion.Should().NotBeNullOrEmpty();
result.NuGetSource.Should().NotBeNullOrEmpty();
}
Expand Down Expand Up @@ -150,12 +151,12 @@ public async Task DownloadPackage_HasVulnerabilities()
// Getting this version of the package as it has known vulnerabilities
NuGetApiPackageManager packageManager = new NuGetApiPackageManager(engineEnvironmentSettings);

// add the source for getting vulnerability info
// use nuget.org for vulnerability metadata (read-only; proxy does not include vulnerability data in registrations)
var exception = await Assert.ThrowsExactlyAsync<VulnerablePackageException>(() => packageManager.DownloadPackageAsync(
installPath,
"System.Text.Json",
"8.0.4",
additionalSources: _additionalSources,
additionalSources: _vulnerabilitySources,
cancellationToken: TestContext.CancellationToken));

exception.PackageIdentifier.Should().Be("System.Text.Json");
Expand All @@ -172,12 +173,12 @@ public async Task DownloadPackage_HasVulnerabilitiesForce()
// Getting this version of the package as it has known vulnerabilities
NuGetApiPackageManager packageManager = new NuGetApiPackageManager(engineEnvironmentSettings);

// add the source for getting vulnerability info
// use nuget.org for vulnerability metadata (read-only; proxy does not include vulnerability data in registrations)
var result = await packageManager.DownloadPackageAsync(
installPath,
"System.Text.Json",
"8.0.4",
additionalSources: _additionalSources,
additionalSources: _vulnerabilitySources,
force: true,
cancellationToken: TestContext.CancellationToken);

Expand All @@ -186,7 +187,7 @@ public async Task DownloadPackage_HasVulnerabilitiesForce()
result.PackageVersion.Should().Be("8.0.4");
Assert.IsTrue(File.Exists(result.FullPath));
result.PackageVulnerabilities.Should().NotBeNullOrEmpty();
result.NuGetSource.Should().Be(_additionalSources[0]);
result.NuGetSource.Should().NotBeNullOrEmpty();
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ public class TemplatePackagesTests : BootstrapperTestBase
"Packages": [
{
"Details": {
"PackageId": "Sln",
"Author": "Enrico Sada",
"NuGetSource": "https://api.nuget.org/v3/index.json",
"Version": "0.2.0"
"PackageId": "Microsoft.DotNet.Common.ProjectTemplates.5.0",
"Author": "Microsoft",
"NuGetSource": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json",
"Version": "5.0.0"
},
"InstallerId": "015dcbac-b4a5-49ea-94a6-061616eb60e2",
"LastChangeTime": "2023-04-13T15:17:16.4866397Z",
"MountPointUri": "packages\\Sln.0.3.0.nupkg"
"MountPointUri": "packages\\Microsoft.DotNet.Common.ProjectTemplates.5.0.5.0.0.nupkg"
},
{
"Details": {
"PackageId": "Boxed.Templates",
"Author": "Muhammad Rehan Saeed (RehanSaeed.com)",
"NuGetSource": "https://api.nuget.org/v3/index.json",
"Version": "7.4.0"
"PackageId": "Microsoft.DotNet.Web.ProjectTemplates.10.0",
"Author": "Microsoft",
"NuGetSource": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json",
"Version": "10.0.0"
},
"InstallerId": "015dcbac-b4a5-49ea-94a6-061616eb60e2",
"LastChangeTime": "2023-06-01T11:32:14.867341Z",
"MountPointUri": "packages\\Boxed.Templates.7.4.0.nupkg"
"MountPointUri": "packages\\Microsoft.DotNet.Web.ProjectTemplates.10.0.10.0.0.nupkg"
}
]
}
Expand Down Expand Up @@ -92,11 +92,11 @@ public async Task CanInstall_RemoteNuGetPackage()
{
using Bootstrapper bootstrapper = GetBootstrapper();
InstallRequest installRequest = new InstallRequest(
"Take.Blip.Client.Templates",
"0.5.135",
"Microsoft.Android.Templates",
"36.1.69",
details: new Dictionary<string, string>
{
{ InstallerConstants.NuGetSourcesKey, "https://api.nuget.org/v3/index.json" }
{ InstallerConstants.NuGetSourcesKey, "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" }
});

IReadOnlyList<InstallResult> result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None);
Expand All @@ -109,12 +109,12 @@ public async Task CanInstall_RemoteNuGetPackage()

IManagedTemplatePackage? source = result[0].TemplatePackage;
Assert.IsNotNull(source);
Assert.AreEqual("Take.Blip.Client.Templates", source!.Identifier);
Assert.AreEqual("Microsoft.Android.Templates", source!.Identifier);
Assert.AreEqual("Global Settings", source.Provider.Factory.DisplayName);
Assert.AreEqual("NuGet", source.Installer.Factory.Name);
source.GetDetails()["Author"].Should().NotBeNullOrEmpty();
Assert.AreEqual("https://api.nuget.org/v3/index.json", source.GetDetails()["NuGetSource"]);
Assert.AreEqual("0.5.135", source.Version);
source.GetDetails()["NuGetSource"].Should().NotBeNullOrEmpty();
Assert.AreEqual("36.1.69", source.Version);

IReadOnlyList<IManagedTemplatePackage> managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None);

Expand Down Expand Up @@ -222,39 +222,43 @@ public async Task CanUpdateAllPackagesMetadataOnGetLatestVersion()
var updatedPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None);

Assert.HasCount(2, updatedPackages);
var slnPackage = updatedPackages[0];
Assert.AreEqual("0.2.0", slnPackage.Version);
var slnPackageDetails = slnPackage.GetDetails();
Assert.AreEqual("enricosada", slnPackageDetails["Owners"]);
Assert.IsFalse(bool.Parse(slnPackageDetails["Reserved"]));

var boxPackage = updatedPackages[1];
Assert.AreEqual("7.4.0", boxPackage.Version);
var boxPackageDetails = boxPackage.GetDetails();
Assert.AreEqual("BlackLight", boxPackageDetails["Owners"]);
Assert.IsTrue(bool.Parse(boxPackageDetails["Reserved"]));
var commonPackage = updatedPackages[0];
Assert.AreEqual("5.0.0", commonPackage.Version);
var commonPackageDetails = commonPackage.GetDetails();
// dotnet-public feed may not return Owners metadata
commonPackageDetails.TryGetValue("Owners", out var commonOwners);
// Owners may be empty or populated depending on feed behavior
Assert.IsFalse(bool.Parse(commonPackageDetails["Reserved"]));

var webPackage = updatedPackages[1];
Assert.AreEqual("10.0.0", webPackage.Version);
var webPackageDetails = webPackage.GetDetails();
// dotnet-public feed may not return Owners metadata
webPackageDetails.TryGetValue("Owners", out var webOwners);
Assert.IsFalse(bool.Parse(webPackageDetails["Reserved"]));
}

[TestMethod]
public async Task CanUpdateSpecifiedPackageMetadataOnGetLatestVersion()
{
using Bootstrapper bootstrapper = GetBootstrapper(packageJsonContent: ValidPackageJsonFile);
var installedPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None);
var boxedTemplatePackage = installedPackages.FirstOrDefault(ip => ip.Identifier == "Boxed.Templates");
var webTemplatePackage = installedPackages.FirstOrDefault(ip => ip.Identifier == "Microsoft.DotNet.Web.ProjectTemplates.10.0");

// implicitly populates package metadata
await bootstrapper.GetLatestVersionsAsync(new[] { boxedTemplatePackage! }, CancellationToken.None);
await bootstrapper.GetLatestVersionsAsync(new[] { webTemplatePackage! }, CancellationToken.None);

var updatedPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None);
Assert.HasCount(2, updatedPackages);
var slnPackageDetails = updatedPackages[0].GetDetails();
Assert.IsFalse(slnPackageDetails.TryGetValue("Owners", out var _));
Assert.IsFalse(bool.Parse(slnPackageDetails["Reserved"]));
var commonPackageDetails = updatedPackages[0].GetDetails();
Assert.IsFalse(commonPackageDetails.TryGetValue("Owners", out var _));
Assert.IsFalse(bool.Parse(commonPackageDetails["Reserved"]));

// the specified package has updated metadata
var boxPackageDetails = updatedPackages[1].GetDetails();
Assert.AreEqual("BlackLight", boxPackageDetails["Owners"]);
Assert.IsTrue(bool.Parse(boxPackageDetails["Reserved"]));
var webPackageDetails = updatedPackages[1].GetDetails();
// dotnet-public feed may not return Owners for Microsoft packages
webPackageDetails.TryGetValue("Owners", out var webOwners);
Assert.IsFalse(bool.Parse(webPackageDetails["Reserved"]));
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.TemplateEngine.TestHelper
{
public class PackageManager : IDisposable
{
private const string NuGetOrgFeed = "https://api.nuget.org/v3/index.json";
private const string NuGetOrgFeed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json";
private static readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1, 1);
private readonly string _packageLocation = TestUtils.CreateTemporaryFolder("packages");
private readonly ConcurrentDictionary<string, string> _installedPackages = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public class NuGetTests
[TestMethod]
public async Task CanReadPackageInfo()
{
string nuGetOrgFeed = "https://api.nuget.org/v3/index.json";
string nuGetOrgFeed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json";
var repository = Repository.Factory.GetCoreV3(nuGetOrgFeed);
ServiceIndexResourceV3 indexResource = repository.GetResource<ServiceIndexResourceV3>(TestContext.Current!.CancellationToken)
?? throw new InvalidOperationException("Failed to get ServiceIndexResourceV3.");
IReadOnlyList<ServiceIndexEntry> searchResources = indexResource.GetServiceEntries("SearchQueryService");

Assert.IsNotEmpty(searchResources, "No SearchQueryService entries found in the feed service index.");
string queryString = $"{searchResources[0].Uri}?q=Microsoft.DotNet.Common.ProjectTemplates.5.0&skip=0&take=10&prerelease=true&semVerLevel=2.0.0";
Uri queryUri = new Uri(queryString);
using HttpClient client = new HttpClient();
Expand All @@ -29,18 +31,14 @@ public async Task CanReadPackageInfo()
string responseText = await response.Content.ReadAsStringAsync(TestContext.Current!.CancellationToken);

NuGetPackageSearchResult resultsForPage = NuGetPackageSearchResult.FromJObject(JsonNode.Parse(responseText)!.AsObject());
Assert.AreEqual(1, resultsForPage.TotalHits);
Assert.ContainsSingle(resultsForPage.Data);
Assert.IsNotEmpty(resultsForPage.Data, "Search returned no data entries.");

var packageInfo = resultsForPage.Data[0];

Assert.AreEqual("Microsoft.DotNet.Common.ProjectTemplates.5.0", packageInfo.Name);
Assert.IsNotEmpty(packageInfo.Version);
Assert.IsGreaterThan(0, packageInfo.TotalDownloads);
Assert.IsTrue(packageInfo.Reserved);
Assert.Contains("Microsoft", packageInfo.Owners);
packageInfo.TotalDownloads.Should().BeGreaterThanOrEqualTo(0);
packageInfo.Description.Should().NotBeNullOrEmpty();
packageInfo.IconUrl.Should().NotBeNullOrEmpty();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
</packageSources>
<!-- Define mappings by adding package patterns beneath the target source. -->
<packageSourceMapping>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
Uno.ProjectTemplates.Dotnet
Package version: 4.8.0-dev.792
Reserved: True
Details: Package Description
Source Feed: https://api.nuget.org/v3/index.json
Microsoft.Android.Templates
Package version: %VERSION%
Details:
Source Feed: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json
Authors:
nventive
Owners:
https://nuget.org/profiles/unoplatform
Microsoft
License Metadata:
Repository Url: https://github.com/unoplatform/uno
License Expression: MIT
Templates:
Template Name Short Name Type Tags Language
----------------------------------------------- -------------------- ------- --------------------------------------------------------------------- --------
Multi-Platform App (Windows App SDK) unoapp project Multi-platform/Uno Platform/Android/iOS/Windows/Mac Catalyst/Linux... C#
Cross-Platform App (Prism) unoapp-prism project Cross-platform/Uno Platform/Prism/Android/iOS/Windows/macOS/WebAss... C#
Cross-Platform UI Tests Library unoapp-uitest project Cross-platform/Uno Platform/UITest/Android/iOS/WebAssembly/dotnet-new C#
Multi-Platform App (Xamarin, UWP) unoapp-uwp project Multi-platform/Uno Platform/Android/iOS/Windows/macOS/Linux/Tizen/... C#
Multi-Platform App (.NET 6, UWP) unoapp-uwp-net6 project Multi-platform/Uno Platform/Android/iOS/Windows/macOS/Linux/WebAss... C#
Multi-Platform App (Xamarin, Windows App SDK) unoapp-winui-xamarin project Multi-platform/Uno Platform/Android/iOS/Windows/macOS/Linux/WebAss... C#
Cross-Platform Library unolib project Cross-platform/Uno Platform/Library/Android/iOS/Windows/macOS/Linu... C#
Cross-Runtime Library (Xamarin, UWP) unolib-crossruntime project Cross-platform/Uno Platform/Library/Android/iOS/Windows/macOS/Linu... C#
Uno Platform WebAssembly Head for Xamarin.Forms wasmxfhead project Cross-platform/Uno Platform/Xamarin.Forms/WebAssembly/dotnet-new C#
Android Application android project Android/Mobile C#
Android Java Library Binding android-bindinglib project Android/Mobile C#
Android Class Library androidlib project Android/Mobile C#

Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
Uno.ProjectTemplates.Dotnet
Package version: 4.8.0-dev.792
Reserved: True
Details: Package Description
Source Feed: NuGet.org [https://api.nuget.org/v3/index.json]
Microsoft.Android.Templates
Package version: %VERSION%
Details:
Source Feed: NuGet.org [https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json]
Authors:
nventive
Owners:
https://nuget.org/profiles/unoplatform
Microsoft
License Metadata:
Repository Url: https://github.com/unoplatform/uno
Templates:
Template Name Short Name Type Tags Language
----------------------------------------------- -------------------- ------- --------------------------------------------------------------------- --------
Multi-Platform App (Windows App SDK) unoapp project Multi-platform/Uno Platform/Android/iOS/Windows/Mac Catalyst/Linux... C#
Cross-Platform App (Prism) unoapp-prism project Cross-platform/Uno Platform/Prism/Android/iOS/Windows/macOS/WebAss... C#
Cross-Platform UI Tests Library unoapp-uitest project Cross-platform/Uno Platform/UITest/Android/iOS/WebAssembly/dotnet-new C#
Multi-Platform App (Xamarin, UWP) unoapp-uwp project Multi-platform/Uno Platform/Android/iOS/Windows/macOS/Linux/Tizen/... C#
Multi-Platform App (.NET 6, UWP) unoapp-uwp-net6 project Multi-platform/Uno Platform/Android/iOS/Windows/macOS/Linux/WebAss... C#
Multi-Platform App (Xamarin, Windows App SDK) unoapp-winui-xamarin project Multi-platform/Uno Platform/Android/iOS/Windows/macOS/Linux/WebAss... C#
Cross-Platform Library unolib project Cross-platform/Uno Platform/Library/Android/iOS/Windows/macOS/Linu... C#
Cross-Runtime Library (Xamarin, UWP) unolib-crossruntime project Cross-platform/Uno Platform/Library/Android/iOS/Windows/macOS/Linu... C#
Uno Platform WebAssembly Head for Xamarin.Forms wasmxfhead project Cross-platform/Uno Platform/Xamarin.Forms/WebAssembly/dotnet-new C#

License Expression: MIT
Loading
Loading