Я обновляю IdentityServer4 до версии 3.1, и у меня возникла проблема с модульным тестом после обновления. IdentityServer4.EntityFramework.Stores.ClientStore
было расширено, как мы видим ниже:
public class IfloClientStore : ClientStore
{
private const string Saml2BearerClientSuffix = "_saml2bearer";
public IfloClientStore(IConfigurationDbContext context, ILogger<ClientStore> logger) : base(context, logger)
{
}
public override async Task<Client> FindClientByIdAsync(string clientId)
{
if(string.IsNullOrWhiteSpace(clientId))
throw new ArgumentException(nameof(clientId) +" is null or empty");
clientId = clientId.ToLowerInvariant();
var result = await base.FindClientByIdAsync(MapClientId(clientId));
if (result == null)
throw new ResourceNotFoundException(clientId);
if (IsSamlClient(clientId))
AllowSamlFlow(result);
return result;
}
private void AllowSamlFlow(Client client)
{
client.AllowedGrantTypes.Add(Constants.GrantTypes.Saml2BearerGrant);
}
private bool IsSamlClient(string clientId)
{
return clientId.EndsWith(Saml2BearerClientSuffix);
}
private string MapClientId(string clientId)
{
if (IsSamlClient(clientId))
return clientId.Substring(0, clientId.Length - Saml2BearerClientSuffix.Length);
return clientId;
}
}
Мой модульный тест:
[Test]
public async Task FindClientByIdAsync_Given_PFP_Saml2Bearer_Client_Return_PFP_SamlAllowed_Client()
{
var client = await underTest.FindClientByIdAsync(PfpWebClientIdForSaml);
client.ClientId.Should().Be(PfpWebClientId);
client.AllowedGrantTypes.Single().Should().Be("urn:ietf:params:oauth:grant-type:saml2-bearer");
}
Это исключение выдается при выполнении FindClientByIdAsync
:
Message:
System.InvalidOperationException : The provider for the source IQueryable doesn't implement IAsyncQueryProvider. Only providers that implement IAsyncQueryProvider can be used for Entity Framework asynchronous operations.
Трассировка стека: EntityFrameworkQueryableExtensions.ExecuteAsync [TSource, TResult] (метод MethodInfo, операторMethodInfo, IQueryable 1 source, Expression expression, CancellationToken cancellationToken)
EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable
1 источник, CancellationToken cancellationToken) EntityFrameworkQueryableExtensions.FirstOrynSecync () `1 invoke) TestMethodCommand.RunTestMethod (контекст TestExecutionContext) TestMethodCommand.Execute (контекст TestExecutionContext) <> c__DisplayClass1_0.b__0 () это работает просто отлично. Но я хочу убедиться, что в IDS4 есть ошибка или я должен что-то изменить из-за обновления. Может кто-нибудь мне помочь?