Fix Identity Server unit tests.

pull/14019/head
maliming 2 years ago
parent 3d6e312fde
commit 62165449dd
No known key found for this signature in database
GPG Key ID: 096224957E51C89E

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using IdentityServer4.Models;
using IdentityServer4.Services;
using IdentityServer4.Stores;
@ -28,6 +29,7 @@ public class IdentityServerCacheItemInvalidator_Tests : AbpIdentityServerTestBas
private readonly IDistributedCache<Client> _clientCache;
private readonly IDistributedCache<IdentityResource> _identityResourceCache;
private readonly IDistributedCache<IEnumerable<ApiResource>> _apiResourcesCache;
private readonly IDistributedCache<ApiResource> _apiResourceCache;
private readonly IDistributedCache<ApiScope> _apiScopeCache;
private readonly IDistributedCache<Resources> _resourceCache;
@ -46,6 +48,7 @@ public class IdentityServerCacheItemInvalidator_Tests : AbpIdentityServerTestBas
_clientCache = GetRequiredService<IDistributedCache<Client>>();
_identityResourceCache = GetRequiredService<IDistributedCache<IdentityResource>>();
_apiResourcesCache = GetRequiredService<IDistributedCache<IEnumerable<ApiResource>>>();
_apiResourceCache = GetRequiredService<IDistributedCache<ApiResource>>();
_apiScopeCache = GetRequiredService<IDistributedCache<ApiScope>>();
_resourceCache = GetRequiredService<IDistributedCache<Resources>>();
@ -93,9 +96,9 @@ public class IdentityServerCacheItemInvalidator_Tests : AbpIdentityServerTestBas
(await _apiResourceCache.GetAsync(newApiResource2)).ShouldBeNull();
//FindApiResourcesByScopeNameAsync
(await _apiResourceCache.GetAsync(ResourceStore.ApiResourceScopeNameCacheKeyPrefix + testApiResourceApiScopeName1)).ShouldBeNull();
(await _apiResourcesCache.GetAsync(ResourceStore.ApiResourceScopeNameCacheKeyPrefix + testApiResourceApiScopeName1)).ShouldBeNull();
await _resourceStore.FindApiResourcesByScopeNameAsync(new[] { testApiResourceApiScopeName1 });
(await _apiResourceCache.GetAsync(ResourceStore.ApiResourceScopeNameCacheKeyPrefix + testApiResourceApiScopeName1)).ShouldNotBeNull();
(await _apiResourcesCache.GetAsync(ResourceStore.ApiResourceScopeNameCacheKeyPrefix + testApiResourceApiScopeName1)).ShouldNotBeNull();
var testApiResource1 = await _apiResourceRepository.FindByNameAsync(testApiResourceName1);
await _apiResourceRepository.DeleteAsync(testApiResource1);

@ -51,9 +51,9 @@ public class IdentityResourceStore_Tests : AbpIdentityServerTestBase
})).ToList();
//Assert
apiResources.ShouldNotBe(null);
apiResources.ShouldNotBeNull();
apiResources[0].Scopes.Count.ShouldBe(4);
apiResources.ShouldContain(x => x.Scopes.Contains("Test-ApiResource-ApiScope-Name-1"));
}
[Fact]

Loading…
Cancel
Save