Browse Source

identityserver remove old sync api usage

pull/2464/head
Halil İbrahim Kalkan 7 years ago
parent
commit
2527faaa37
  1. 37
      modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  2. 5
      modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs
  3. 5
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestBaseModule.cs
  4. 49
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

37
modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -1,4 +1,5 @@
using IdentityServer4.Models;
using System.Threading.Tasks;
using IdentityServer4.Models;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.IdentityServer.ApiResources;
@ -12,7 +13,7 @@ using PersistedGrant = Volo.Abp.IdentityServer.Grants.PersistedGrant;
namespace Volo.Abp.IdentityServer
{
//TODO: There are two data builders (ses AbpIdentityServerTestDataBuilder in Volo.Abp.IdentityServer.TestBase). It should be somehow unified!
//TODO: There are two data builders (see AbpIdentityServerTestDataBuilder in Volo.Abp.IdentityServer.TestBase). It should be somehow unified!
public class AbpIdentityServerTestDataBuilder : ITransientDependency
{
@ -36,15 +37,15 @@ namespace Volo.Abp.IdentityServer
_identityResourceRepository = identityResourceRepository;
}
public void Build()
public async Task BuildAsync()
{
AddClients();
AddPersistentGrants();
AddApiResources();
AddIdentityResources();
await AddClients();
await AddPersistentGrants();
await AddApiResources();
await AddIdentityResources();
}
private void AddClients()
private async Task AddClients()
{
var client42 = new Client(_guidGenerator.Create(), "42")
{
@ -55,12 +56,12 @@ namespace Volo.Abp.IdentityServer
client42.AddScope("api1");
_clientRepository.Insert(client42);
await _clientRepository.InsertAsync(client42);
}
private void AddPersistentGrants()
private async Task AddPersistentGrants()
{
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "38",
ClientId = "TestClientId-38",
@ -69,7 +70,7 @@ namespace Volo.Abp.IdentityServer
Data = "TestData-38"
});
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "37",
ClientId = "TestClientId-37",
@ -78,7 +79,7 @@ namespace Volo.Abp.IdentityServer
Data = "TestData-37"
});
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "36",
ClientId = "TestClientId-X",
@ -87,7 +88,7 @@ namespace Volo.Abp.IdentityServer
Data = "TestData-36"
});
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "35",
ClientId = "TestClientId-X",
@ -97,7 +98,7 @@ namespace Volo.Abp.IdentityServer
});
}
private void AddApiResources()
private async Task AddApiResources()
{
var apiResource = new ApiResource(_guidGenerator.Create(), "Test-ApiResource-Name-1")
{
@ -110,10 +111,10 @@ namespace Volo.Abp.IdentityServer
apiResource.AddScope("Test-ApiResource-ApiScope-Name-1", "Test-ApiResource-ApiScope-DisplayName-1");
apiResource.AddUserClaim("Test-ApiResource-Claim-Type-1");
_apiResourceRepository.Insert(apiResource);
await _apiResourceRepository.InsertAsync(apiResource);
}
private void AddIdentityResources()
private async Task AddIdentityResources()
{
var identityResource = new IdentityResource(_guidGenerator.Create(), "Test-Identity-Resource-Name-1")
{
@ -125,7 +126,7 @@ namespace Volo.Abp.IdentityServer
identityResource.AddUserClaim("Test-Identity-Resource-1-IdentityClaim-Type-1");
_identityResourceRepository.Insert(identityResource);
await _identityResourceRepository.InsertAsync(identityResource);
}
}
}

5
modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs

@ -7,6 +7,7 @@ using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace Volo.Abp.IdentityServer
{
@ -55,9 +56,9 @@ namespace Volo.Abp.IdentityServer
{
using (var scope = context.ServiceProvider.CreateScope())
{
scope.ServiceProvider
AsyncHelper.RunSync(() => scope.ServiceProvider
.GetRequiredService<AbpIdentityServerTestDataBuilder>()
.Build();
.BuildAsync());
}
}
}

5
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestBaseModule.cs

@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace Volo.Abp.IdentityServer
{
@ -25,9 +26,9 @@ namespace Volo.Abp.IdentityServer
{
using (var scope = context.ServiceProvider.CreateScope())
{
scope.ServiceProvider
AsyncHelper.RunSync(() => scope.ServiceProvider
.GetRequiredService<AbpIdentityServerTestDataBuilder>()
.Build();
.BuildAsync());
}
}
}

49
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
@ -38,18 +39,18 @@ namespace Volo.Abp.IdentityServer
_persistentGrantRepository = persistentGrantRepository;
}
public void Build()
public async Task BuildAsync()
{
AddPersistedGrants();
AddIdentityResources();
AddApiResources();
AddClients();
AddClaimTypes();
await AddPersistedGrants();
await AddIdentityResources();
await AddApiResources();
await AddClients();
await AddClaimTypes();
}
private void AddPersistedGrants()
private async Task AddPersistedGrants()
{
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "PersistedGrantKey1",
SubjectId = "PersistedGrantSubjectId1",
@ -58,7 +59,7 @@ namespace Volo.Abp.IdentityServer
Data = ""
});
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "PersistedGrantKey2",
SubjectId = "PersistedGrantSubjectId2",
@ -67,7 +68,7 @@ namespace Volo.Abp.IdentityServer
Data = ""
});
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
await _persistentGrantRepository.InsertAsync(new PersistedGrant(_guidGenerator.Create())
{
Key = "PersistedGrantKey3",
SubjectId = "PersistedGrantSubjectId3",
@ -77,7 +78,7 @@ namespace Volo.Abp.IdentityServer
});
}
private void AddIdentityResources()
private async Task AddIdentityResources()
{
var identityResource = new IdentityResource(_testData.IdentityResource1Id, "NewIdentityResource1")
{
@ -87,12 +88,12 @@ namespace Volo.Abp.IdentityServer
identityResource.AddUserClaim(nameof(ApiResourceClaim.Type));
_identityResourceRepository.Insert(identityResource);
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2"));
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3"));
await _identityResourceRepository.InsertAsync(identityResource);
await _identityResourceRepository.InsertAsync(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2"));
await _identityResourceRepository.InsertAsync(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3"));
}
private void AddApiResources()
private async Task AddApiResources()
{
var apiResource = new ApiResource(_testData.ApiResource1Id, "NewApiResource1");
apiResource.Description = nameof(apiResource.Description);
@ -102,12 +103,12 @@ namespace Volo.Abp.IdentityServer
apiResource.AddUserClaim(nameof(ApiResourceClaim.Type));
apiResource.AddSecret(nameof(ApiSecret.Value));
_apiResourceRepository.Insert(apiResource);
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource2"));
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource3"));
await _apiResourceRepository.InsertAsync(apiResource);
await _apiResourceRepository.InsertAsync(new ApiResource(_guidGenerator.Create(), "NewApiResource2"));
await _apiResourceRepository.InsertAsync(new ApiResource(_guidGenerator.Create(), "NewApiResource3"));
}
private void AddClients()
private async Task AddClients()
{
var client = new Client(_testData.Client1Id, "ClientId1")
{
@ -129,17 +130,17 @@ namespace Volo.Abp.IdentityServer
client.AddScope(nameof(ClientScope.Scope));
client.AddSecret(nameof(ClientSecret.Value));
_clientRepository.Insert(client);
await _clientRepository.InsertAsync(client);
_clientRepository.Insert(new Client(_guidGenerator.Create(), "ClientId2"));
_clientRepository.Insert(new Client(_guidGenerator.Create(), "ClientId3"));
await _clientRepository.InsertAsync(new Client(_guidGenerator.Create(), "ClientId2"));
await _clientRepository.InsertAsync(new Client(_guidGenerator.Create(), "ClientId3"));
}
private void AddClaimTypes()
private async Task AddClaimTypes()
{
var ageClaim = new IdentityClaimType(Guid.NewGuid(), "Age", false, false, null, null, null,
IdentityClaimValueType.Int);
_identityClaimTypeRepository.Insert(ageClaim);
await _identityClaimTypeRepository.InsertAsync(ageClaim);
}
}
}

Loading…
Cancel
Save