feat(AuthClientTests): StartAsync_ShouldUpdateAllPublicKey Testmethode hinzufügen, um zu testen, ob der öffentliche Schlüssel nach StartAsync aktualisiert wird

This commit is contained in:
Developer 02 2025-03-07 09:49:48 +01:00
parent e925c175a0
commit 4e941ed35f
2 changed files with 25 additions and 1 deletions

View File

@ -42,5 +42,5 @@ public class ClientParams
}); });
} }
public IEnumerable<AsymmetricPublicKey> PublicKeys { get; init; } = new List<AsymmetricPublicKey>(); public List<AsymmetricPublicKey> PublicKeys { get; init; } = new();
} }

View File

@ -185,4 +185,28 @@ public class AuthClientTests
Assert.That(publicKey, Is.EqualTo(expectedPublicKey)); Assert.That(publicKey, Is.EqualTo(expectedPublicKey));
}); });
} }
[Test]
public async Task StartAsync_ShouldUpdateAllPublicKey()
{
// Arrange
var publicKey = new AsymmetricPublicKey() { Issuer = "Foo", Audience = "Bar" };
var provider = Build(opt =>
{
opt.Url = _hubUrl;
opt.PublicKeys.Add(new AsymmetricPublicKey() { Issuer = "Foo", Audience = "Bar" });
});
var client = provider.GetRequiredService<IAuthClient>();
await client.StartAsync();
// wait for network
await Task.Delay(2000);
// Act
var expectedPublicKey = _tokenDescriptors.Get("Foo", "Bar").PublicKey;
await client.GetPublicKeyAsync("Foo", "Bar");
// Assert
Assert.That(publicKey.Content, Is.EqualTo(expectedPublicKey.Content));
}
} }