Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1393 from NuGet/anurse/fixgetupdatesagain

Fix GetUpdates case-sensitivity issue
  • Loading branch information...
commit 88e629ee6cfb05e2708831884d8a55a2de1b587e 2 parents 6722649 + 345e29d
claycompton claycompton authored
60 Facts/Services/FeedServiceFacts.cs
View
@@ -319,11 +319,11 @@ public void V2FeedGetUpdatesReturnsVersionsConformingToConstraints()
// Act
var result = v2Service.GetUpdates(
- "Foo|Qux",
- "1.0.0|0.9",
- includePrerelease: false,
- includeAllVersions: true,
- targetFrameworks: null,
+ "Foo|Qux",
+ "1.0.0|0.9",
+ includePrerelease: false,
+ includeAllVersions: true,
+ targetFrameworks: null,
versionConstraints: "(,1.2.0)|[2.0,2.3]")
.ToList();
@@ -444,6 +444,40 @@ public void V2FeedGetUpdatesReturnsEmptyPackagesIfNoPackageSatisfiesConstraints(
}
[Fact]
+ public void V2FeedGetUpdatesReturnsCaseInsensitiveMatches()
+ {
+ // Arrange
+ var packageRegistrationA = new PackageRegistration { Id = "Foo" };
+ var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict);
+ repo.Setup(r => r.GetAll()).Returns(
+ new[]
+ {
+ new Package { PackageRegistration = packageRegistrationA, Version = "1.0.0", IsPrerelease = false, Listed = true },
+ new Package { PackageRegistration = packageRegistrationA, Version = "1.1.0", IsPrerelease = false, Listed = true },
+ new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0-alpha", IsPrerelease = true, Listed = true },
+ new Package { PackageRegistration = packageRegistrationA, Version = "1.2.0", IsPrerelease = false, Listed = true },
+ }.AsQueryable());
+ var configuration = new Mock<ConfigurationService>(MockBehavior.Strict);
+ configuration.Setup(c => c.GetSiteRoot(false)).Returns("https://localhost:8081/");
+ var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null);
+
+ // Act
+ var result = v2Service.GetUpdates(
+ "foo",
+ "1.0.0",
+ includePrerelease: false,
+ includeAllVersions: false,
+ targetFrameworks: null,
+ versionConstraints: null)
+ .ToList();
+
+ // Assert
+ Assert.Equal(1, result.Count);
+ Assert.Equal("Foo", result[0].Id);
+ Assert.Equal("1.2.0", result[0].Version);
+ }
+
+ [Fact]
public void V2FeedGetUpdatesReturnsUpdateIfAnyOfTheProvidedVersionsIsOlder()
{
// Arrange
@@ -501,7 +535,13 @@ public void V2FeedGetUpdatesReturnsPrereleasePackages()
var v2Service = new TestableV2Feed(repo.Object, configuration.Object, null);
// Act
- var result = v2Service.GetUpdates("Foo|Qux", "1.1.0|0.9", includePrerelease: true, includeAllVersions: true, targetFrameworks: null, versionConstraints: null)
+ var result = v2Service.GetUpdates(
+ "Foo|Qux",
+ "1.1.0|0.9",
+ includePrerelease: true,
+ includeAllVersions: true,
+ targetFrameworks: null,
+ versionConstraints: null)
.ToList();
// Assert
@@ -533,7 +573,13 @@ public void V2FeedGetUpdatesReturnsResultsIfDuplicatesInPackageList()
// Act
var result =
- v2Service.GetUpdates("Foo|Qux|Foo", "0.9|1.5|1.1.2", includePrerelease: false, includeAllVersions: true, targetFrameworks: null, versionConstraints: null)
+ v2Service.GetUpdates(
+ "Foo|Qux|Foo",
+ "0.9|1.5|1.1.2",
+ includePrerelease: false,
+ includeAllVersions: true,
+ targetFrameworks: null,
+ versionConstraints: null)
.ToList();
// Assert
16 Website/DataServices/V2Feed.svc.cs
View
@@ -62,7 +62,12 @@ public IQueryable<V2FeedPackage> FindPackagesById(string id)
[WebGet]
public IQueryable<V2FeedPackage> GetUpdates(
- string packageIds, string versions, bool includePrerelease, bool includeAllVersions, string targetFrameworks, string versionConstraints)
+ string packageIds,
+ string versions,
+ bool includePrerelease,
+ bool includeAllVersions,
+ string targetFrameworks,
+ string versionConstraints)
{
if (String.IsNullOrEmpty(packageIds) || String.IsNullOrEmpty(versions))
{
@@ -77,7 +82,7 @@ public IQueryable<V2FeedPackage> FindPackagesById(string id)
targetFrameworks = targetFrameworks.Replace(' ', '+');
}
- var idValues = packageIds.Trim().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
+ var idValues = packageIds.Trim().ToLowerInvariant().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
var versionValues = versions.Trim().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
var targetFrameworkValues = String.IsNullOrEmpty(targetFrameworks)
? null
@@ -110,13 +115,16 @@ public IQueryable<V2FeedPackage> FindPackagesById(string id)
return null;
})
.Where(t => t != null)
- .ToLookup(t => t.Item1, t => t.Item2);
+ .ToLookup(t => t.Item1, t => t.Item2, StringComparer.OrdinalIgnoreCase);
var packages = PackageRepository.GetAll()
.Include(p => p.PackageRegistration)
.Include(p => p.SupportedFrameworks)
- .Where(p => p.Listed && (includePrerelease || !p.IsPrerelease) && idValues.Contains(p.PackageRegistration.Id))
+ .Where(p =>
+ p.Listed && (includePrerelease || !p.IsPrerelease) &&
+ idValues.Contains(p.PackageRegistration.Id.ToLower()))
.OrderBy(p => p.PackageRegistration.Id);
+
return GetUpdates(packages, versionLookup, targetFrameworkValues, includeAllVersions).AsQueryable()
.ToV2FeedPackageQuery(GetSiteRoot());
}
Please sign in to comment.
Something went wrong with that request. Please try again.