Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit cb186cd

Browse files
authored
[Repository Signing] Order owners metadata lexicographically (#513)
Part of NuGet/NuGetGallery#6258
1 parent ff0e2cb commit cb186cd

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/NuGet.Services.Revalidate/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ are installed by .NET SDK and Visual Studio
88
2. Initialization phase - the job determines which packages should be revalidated.
99
3. Revalidation phase - packages are enqueued for revalidations
1010

11-
These phase MUST be completed in order.
11+
These phases MUST be completed in order.
1212

1313
# The Build Preinstalled Packages phase
1414

src/NuGet.Services.Validation.Orchestrator/PackageSigning/ScanAndSign/ScanAndSignProcessor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ private List<string> FindPackageOwners(IValidationRequest request)
246246
return registration
247247
.Owners
248248
.Select(o => o.Username)
249+
.ToList()
250+
.OrderBy(u => u, StringComparer.InvariantCultureIgnoreCase)
249251
.ToList();
250252
}
251253
}

tests/Validation.PackageSigning.ScanAndSign.Tests/ScanAndSignProcessorFacts.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,12 @@ public async Task EnqueuesScanAndSignIfPackageHasNoRepositorySignature()
251251
_request.NupkgUrl,
252252
_config.V3ServiceIndexUrl,
253253
It.Is<List<string>>(l =>
254-
l.Count() == 2 &&
255-
l.Contains("Billy") &&
256-
l.Contains("Bob"))),
254+
// Ensure that the owners are lexicographically ordered.
255+
l.Count() == 4 &&
256+
l[0] == "Annie" &&
257+
l[1] == "Bob" &&
258+
l[2] == "zack" &&
259+
l[3] == "Zorro")),
257260
Times.Once);
258261

259262
_validatorStateServiceMock
@@ -441,8 +444,10 @@ public async Task WhenPackageFitsCriteriaAndIsNotRepositorySigned_DoesNotSkipSca
441444
{
442445
Owners = new List<User>
443446
{
444-
new User("Billy"),
447+
new User("Zorro"),
445448
new User("Bob"),
449+
new User("Annie"),
450+
new User("zack")
446451
}
447452
};
448453

0 commit comments

Comments
 (0)