Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@

public Task<ReadOnlyCollection<KeyMaterial>> GetLastKeys(int? i = null)
{
return _store.GetLastKeys(_options.Value.AlgorithmsToKeep, null);
return _store.GetLastKeys(i ?? _options.Value.AlgorithmsToKeep, null);
}

public Task<ReadOnlyCollection<KeyMaterial>> GetLastKeys(int i, JwtKeyType jwtKeyType)
{
return _store.GetLastKeys(_options.Value.AlgorithmsToKeep, jwtKeyType);
return _store.GetLastKeys(i, jwtKeyType);
}

private async Task<bool> CheckCompatibility(KeyMaterial currentKey, JwtKeyType jwtKeyType)
Expand All @@ -80,7 +80,7 @@
return true;
}

public async Task RevokeKey(string keyId, string reason = null)

Check warning on line 83 in src/NetDevPack.Security.Jwt.Core/Jwt/JwtService.cs

View workflow job for this annotation

GitHub Actions / pull-request

Cannot convert null literal to non-nullable reference type.
{
var key = await _store.Get(keyId);

Expand Down
1 change: 1 addition & 0 deletions tests/NetDevPack.Security.Jwt.Tests/JwtTests/JweTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace NetDevPack.Security.Jwt.Tests.JwtTests
{
[Collection(InMemoryStoreCollection.Name)]
public class JweTests : IClassFixture<WarmupInMemoryStore>
{
private readonly IJwtService _jwksService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace NetDevPack.Security.Jwt.Tests.JwtTests
{
[Collection(InMemoryStoreCollection.Name)]
public class JwtServiceTest : IClassFixture<WarmupInMemoryStore>
{
private readonly IJwtService _jwksService;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/NetDevPack.Security.Jwt.Tests/JwtTests/JwtTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace NetDevPack.Security.Jwt.Tests.JwtTests
{
[Collection(InMemoryStoreCollection.Name)]
public class JwsTests : IClassFixture<WarmupInMemoryStore>
{
private readonly IJwtService _service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace NetDevPack.Security.Jwt.Tests.StoreTests;

[Collection(InMemoryStoreCollection.Name)]
[Trait("Category", "InMemory Tests")]
public class InMemoryStoreTests : GenericStoreServiceTest<WarmupInMemoryStore>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Xunit;

namespace NetDevPack.Security.Jwt.Tests.Warmups;

[CollectionDefinition(Name)]
public class InMemoryStoreCollection
{
public const string Name = "InMemory Store";
}
Loading