/ GUNRPG.Tests / IdentityServiceExtensionsTests.cs
IdentityServiceExtensionsTests.cs
 1  using Fido2NetLib;
 2  using GUNRPG.Application.Identity;
 3  using GUNRPG.Infrastructure;
 4  using Microsoft.Extensions.DependencyInjection;
 5  using Microsoft.Extensions.Options;
 6  
 7  namespace GUNRPG.Tests;
 8  
 9  public class IdentityServiceExtensionsTests
10  {
11      [Fact]
12      public void AddGunRpgIdentity_RegistersIdentityServicesAsScoped()
13      {
14          var services = new ServiceCollection();
15  
16          services.AddGunRpgIdentity("https://localhost/auth/device/verify");
17  
18          var webAuthnDescriptor = Assert.Single(services, d => d.ServiceType == typeof(IWebAuthnService));
19          var deviceCodeDescriptor = Assert.Single(services, d => d.ServiceType == typeof(IDeviceCodeService));
20          var fido2ValidationDescriptor = Assert.Single(services, d =>
21              d.ServiceType == typeof(IValidateOptions<Fido2Configuration>));
22  
23          Assert.Equal(ServiceLifetime.Scoped, webAuthnDescriptor.Lifetime);
24          Assert.Equal(ServiceLifetime.Scoped, deviceCodeDescriptor.Lifetime);
25          Assert.Equal(ServiceLifetime.Singleton, fido2ValidationDescriptor.Lifetime);
26      }
27  }