From f973f8ebd06c94caea1d0a5b898685cfb9bc3d5e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Jul 2026 15:43:34 +0000 Subject: [PATCH 1/2] Initial plan From 5e7cd65988924c717370999f17bf4a677e7b5422 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Jul 2026 16:02:47 +0000 Subject: [PATCH 2/2] Fix flaky pull-request workflow test failure --- src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs | 4 ++-- tests/NetDevPack.Security.Jwt.Tests/JwtTests/JweTests.cs | 1 + .../JwtTests/JwtServiceTest.cs | 4 +++- tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtTests.cs | 1 + .../StoreTests/GenericStoreServiceTest.cs | 1 + .../StoreTests/InMemoryStoreTests.cs | 1 + .../Warmups/InMemoryStoreCollection.cs | 9 +++++++++ 7 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tests/NetDevPack.Security.Jwt.Tests/Warmups/InMemoryStoreCollection.cs diff --git a/src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs b/src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs index 56c89c2..6ea1f2a 100644 --- a/src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs +++ b/src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs @@ -61,12 +61,12 @@ public async Task GetCurrentEncryptingCredentials() public Task> GetLastKeys(int? i = null) { - return _store.GetLastKeys(_options.Value.AlgorithmsToKeep, null); + return _store.GetLastKeys(i ?? _options.Value.AlgorithmsToKeep, null); } public Task> GetLastKeys(int i, JwtKeyType jwtKeyType) { - return _store.GetLastKeys(_options.Value.AlgorithmsToKeep, jwtKeyType); + return _store.GetLastKeys(i, jwtKeyType); } private async Task CheckCompatibility(KeyMaterial currentKey, JwtKeyType jwtKeyType) diff --git a/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JweTests.cs b/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JweTests.cs index 17b5101..c036833 100644 --- a/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JweTests.cs +++ b/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JweTests.cs @@ -17,6 +17,7 @@ namespace NetDevPack.Security.Jwt.Tests.JwtTests { + [Collection(InMemoryStoreCollection.Name)] public class JweTests : IClassFixture { private readonly IJwtService _jwksService; diff --git a/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtServiceTest.cs b/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtServiceTest.cs index fd7fc2e..2811162 100644 --- a/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtServiceTest.cs +++ b/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtServiceTest.cs @@ -13,6 +13,7 @@ namespace NetDevPack.Security.Jwt.Tests.JwtTests { + [Collection(InMemoryStoreCollection.Name)] public class JwtServiceTest : IClassFixture { private readonly IJwtService _jwksService; @@ -80,7 +81,8 @@ public async Task ShouldGenerateFiveKeys() keysGenerated.Add(sign); } - var current = await _jwksService.GetLastKeys(5); + var current = await _jwksService.GetLastKeys(5, NetDevPack.Security.Jwt.Core.Jwa.JwtKeyType.Jws); + current.Should().HaveCount(5); foreach (var securityKey in current) { keysGenerated.Should().Contain(s => s.KeyId == securityKey.KeyId); diff --git a/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtTests.cs b/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtTests.cs index 7a7aad9..c088ca6 100644 --- a/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtTests.cs +++ b/tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtTests.cs @@ -14,6 +14,7 @@ namespace NetDevPack.Security.Jwt.Tests.JwtTests { + [Collection(InMemoryStoreCollection.Name)] public class JwsTests : IClassFixture { private readonly IJwtService _service; diff --git a/tests/NetDevPack.Security.Jwt.Tests/StoreTests/GenericStoreServiceTest.cs b/tests/NetDevPack.Security.Jwt.Tests/StoreTests/GenericStoreServiceTest.cs index 88b910c..cc4d999 100644 --- a/tests/NetDevPack.Security.Jwt.Tests/StoreTests/GenericStoreServiceTest.cs +++ b/tests/NetDevPack.Security.Jwt.Tests/StoreTests/GenericStoreServiceTest.cs @@ -533,6 +533,7 @@ public async Task Should_Generate_Different_Keys_For_JWS_And_JWE_And_Retrieve_Th var getLastJwe = (await _jwtService.GetLastKeys(1, JwtKeyType.Jwe)).First(); var getLastJws = (await _jwtService.GetLastKeys(1, JwtKeyType.Jws)).First(); + getLast2DefaultVal.Should().HaveCount(2); jws.KeyId.Should().NotBe(jwe.KeyId); getLastJws.KeyId.Should().NotBe(getLastJwe.KeyId); defaultVal.KeyId.Should().Be(jws.KeyId); diff --git a/tests/NetDevPack.Security.Jwt.Tests/StoreTests/InMemoryStoreTests.cs b/tests/NetDevPack.Security.Jwt.Tests/StoreTests/InMemoryStoreTests.cs index abf4d3b..edb1a95 100644 --- a/tests/NetDevPack.Security.Jwt.Tests/StoreTests/InMemoryStoreTests.cs +++ b/tests/NetDevPack.Security.Jwt.Tests/StoreTests/InMemoryStoreTests.cs @@ -3,6 +3,7 @@ namespace NetDevPack.Security.Jwt.Tests.StoreTests; +[Collection(InMemoryStoreCollection.Name)] [Trait("Category", "InMemory Tests")] public class InMemoryStoreTests : GenericStoreServiceTest { diff --git a/tests/NetDevPack.Security.Jwt.Tests/Warmups/InMemoryStoreCollection.cs b/tests/NetDevPack.Security.Jwt.Tests/Warmups/InMemoryStoreCollection.cs new file mode 100644 index 0000000..8567d2f --- /dev/null +++ b/tests/NetDevPack.Security.Jwt.Tests/Warmups/InMemoryStoreCollection.cs @@ -0,0 +1,9 @@ +using Xunit; + +namespace NetDevPack.Security.Jwt.Tests.Warmups; + +[CollectionDefinition(Name)] +public class InMemoryStoreCollection +{ + public const string Name = "InMemory Store"; +}