public static async Task AddCustomSigningCredential_WithoutCertificate_SetsDeveloperCredentials()
        {
            // ReSharper disable once StringLiteralTypo
            const string expectedKeyId = "xEB-cwCvL4brqLxCMzkw3Q";

            WriteEmbeddedDeveloperCertificateToDisk();

            var services = new ServiceCollection();
            var builder  = new IdentityServerBuilder(services);

            builder.AddCustomSigningCredential(Mock.Of <ICertificate>(), Mock.Of <ILogger>());

            var provider = services.BuildServiceProvider();
            var signingCredentialStore = provider.GetService <ISigningCredentialStore>();
            var validationKeysStore    = provider.GetService <IValidationKeysStore>();

            Assert.NotNull(signingCredentialStore);
            Assert.NotNull(validationKeysStore);

            var signingCredentials = await signingCredentialStore.GetSigningCredentialsAsync();

            var validationKeys = (await validationKeysStore.GetValidationKeysAsync()).ToList();

            signingCredentials.Should().NotBeNull();
            signingCredentials.Kid.Should().Be(expectedKeyId);

            validationKeys.Should().NotBeNull();
            validationKeys.Should().HaveCount(1);

            var securityKey = validationKeys.First();

            securityKey.Key.KeyId.Should().Be(expectedKeyId);

            DeleteDeveloperCertificate();
        }
        public static async Task AddCustomSigningCredential_WithCertificate_SetsSigningCredentials()
        {
            using var x509 = CreateValidCertificate();

            var mockCertificate = new Mock <ICertificate>();

            mockCertificate.Setup(c => c.Instance).Returns(x509);
            mockCertificate.Setup(c => c.IsAvailable).Returns(true);

            var services = new ServiceCollection();
            var builder  = new IdentityServerBuilder(services);

            builder.AddCustomSigningCredential(mockCertificate.Object, Mock.Of <ILogger>());

            var provider = services.BuildServiceProvider();
            var signingCredentialStore = provider.GetService <ISigningCredentialStore>();
            var validationKeysStore    = provider.GetService <IValidationKeysStore>();

            Assert.NotNull(signingCredentialStore);
            Assert.NotNull(validationKeysStore);

            var signingCredentials = await signingCredentialStore.GetSigningCredentialsAsync();

            var validationKeys = (await validationKeysStore.GetValidationKeysAsync()).ToList();

            signingCredentials.Should().NotBeNull();
            signingCredentials.Kid.Should().Be(x509.Thumbprint);

            validationKeys.Should().NotBeNull();
            validationKeys.Should().HaveCount(1);

            var securityKey = validationKeys.First();

            securityKey.Key.KeyId.Should().Be(x509.Thumbprint);
        }