|  |  |  | @ -2,11 +2,13 @@ | 
			
		
	
		
			
				
					|  |  |  |  | using IdentityServer4.Models; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.DependencyInjection; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.Guids; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.IdentityServer.ApiResources; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.IdentityServer.ApiScopes; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.IdentityServer.Clients; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.IdentityServer.Grants; | 
			
		
	
		
			
				
					|  |  |  |  | using Volo.Abp.IdentityServer.IdentityResources; | 
			
		
	
		
			
				
					|  |  |  |  | using ApiResource = Volo.Abp.IdentityServer.ApiScopes.ApiResource; | 
			
		
	
		
			
				
					|  |  |  |  | using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; | 
			
		
	
		
			
				
					|  |  |  |  | using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; | 
			
		
	
		
			
				
					|  |  |  |  | using Client = Volo.Abp.IdentityServer.Clients.Client; | 
			
		
	
		
			
				
					|  |  |  |  | using IdentityResource = Volo.Abp.IdentityServer.IdentityResources.IdentityResource; | 
			
		
	
		
			
				
					|  |  |  |  | using PersistedGrant = Volo.Abp.IdentityServer.Grants.PersistedGrant; | 
			
		
	
	
		
			
				
					|  |  |  | @ -21,6 +23,7 @@ namespace Volo.Abp.IdentityServer | 
			
		
	
		
			
				
					|  |  |  |  |         private readonly IClientRepository _clientRepository; | 
			
		
	
		
			
				
					|  |  |  |  |         private readonly IPersistentGrantRepository _persistentGrantRepository; | 
			
		
	
		
			
				
					|  |  |  |  |         private readonly IApiResourceRepository _apiResourceRepository; | 
			
		
	
		
			
				
					|  |  |  |  |         private readonly IApiScopeRepository _apiScopeRepository; | 
			
		
	
		
			
				
					|  |  |  |  |         private readonly IIdentityResourceRepository _identityResourceRepository; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         public AbpIdentityServerTestDataBuilder( | 
			
		
	
	
		
			
				
					|  |  |  | @ -28,21 +31,64 @@ namespace Volo.Abp.IdentityServer | 
			
		
	
		
			
				
					|  |  |  |  |             IGuidGenerator guidGenerator, | 
			
		
	
		
			
				
					|  |  |  |  |             IPersistentGrantRepository persistentGrantRepository, | 
			
		
	
		
			
				
					|  |  |  |  |             IApiResourceRepository apiResourceRepository, | 
			
		
	
		
			
				
					|  |  |  |  |             IIdentityResourceRepository identityResourceRepository) | 
			
		
	
		
			
				
					|  |  |  |  |             IIdentityResourceRepository identityResourceRepository, | 
			
		
	
		
			
				
					|  |  |  |  |             IApiScopeRepository apiScopeRepository) | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             _clientRepository = clientRepository; | 
			
		
	
		
			
				
					|  |  |  |  |             _guidGenerator = guidGenerator; | 
			
		
	
		
			
				
					|  |  |  |  |             _persistentGrantRepository = persistentGrantRepository; | 
			
		
	
		
			
				
					|  |  |  |  |             _apiResourceRepository = apiResourceRepository; | 
			
		
	
		
			
				
					|  |  |  |  |             _identityResourceRepository = identityResourceRepository; | 
			
		
	
		
			
				
					|  |  |  |  |             _apiScopeRepository = apiScopeRepository; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         public async Task BuildAsync() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             await AddClients(); | 
			
		
	
		
			
				
					|  |  |  |  |             await AddPersistentGrants(); | 
			
		
	
		
			
				
					|  |  |  |  |             await AddApiResources(); | 
			
		
	
		
			
				
					|  |  |  |  |             await AddApiScopes(); | 
			
		
	
		
			
				
					|  |  |  |  |             await AddIdentityResources(); | 
			
		
	
		
			
				
					|  |  |  |  |             await AddClients(); | 
			
		
	
		
			
				
					|  |  |  |  |             await AddPersistentGrants(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private async Task AddApiResources() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             var apiResource = new ApiResource(_guidGenerator.Create(), "Test-ApiResource-Name-1") | 
			
		
	
		
			
				
					|  |  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  |  |                 Enabled = true, | 
			
		
	
		
			
				
					|  |  |  |  |                 Description = "Test-ApiResource-Description-1", | 
			
		
	
		
			
				
					|  |  |  |  |                 DisplayName = "Test-ApiResource-DisplayName-1" | 
			
		
	
		
			
				
					|  |  |  |  |             }; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddSecret("secret".Sha256()); | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddScope("Test-ApiResource-ApiScope-Name-1"); | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddScope("Test-ApiResource-ApiScope-DisplayName-1"); | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddUserClaim("Test-ApiResource-Claim-Type-1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             await _apiResourceRepository.InsertAsync(apiResource); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private async Task AddApiScopes() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             var apiScope = new ApiScope(_guidGenerator.Create(), "Test-ApiScope-Name-1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             apiScope.AddUserClaim("Test-ApiScope-Claim-Type-1"); | 
			
		
	
		
			
				
					|  |  |  |  |             await _apiScopeRepository.InsertAsync(apiScope); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private async Task AddIdentityResources() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             var identityResource = new IdentityResource(_guidGenerator.Create(), "Test-Identity-Resource-Name-1") | 
			
		
	
		
			
				
					|  |  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  |  |                 Description = "Test-Identity-Resource-Description-1", | 
			
		
	
		
			
				
					|  |  |  |  |                 DisplayName = "Test-Identity-Resource-DisplayName-1", | 
			
		
	
		
			
				
					|  |  |  |  |                 Required = true, | 
			
		
	
		
			
				
					|  |  |  |  |                 Emphasize = true | 
			
		
	
		
			
				
					|  |  |  |  |             }; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             identityResource.AddUserClaim("Test-Identity-Resource-1-IdentityClaim-Type-1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             await _identityResourceRepository.InsertAsync(identityResource); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private async Task AddClients() | 
			
		
	
	
		
			
				
					|  |  |  | @ -54,7 +100,7 @@ namespace Volo.Abp.IdentityServer | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             client42.AddCorsOrigin("Origin1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             client42.AddScope("api1"); | 
			
		
	
		
			
				
					|  |  |  |  |             client42.AddScope("Test-ApiScope-Name-1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             await _clientRepository.InsertAsync(client42); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -98,36 +144,5 @@ namespace Volo.Abp.IdentityServer | 
			
		
	
		
			
				
					|  |  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private async Task AddApiResources() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             var apiResource = new ApiResource(_guidGenerator.Create(), "Test-ApiResource-Name-1") | 
			
		
	
		
			
				
					|  |  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  |  |                 Enabled = true, | 
			
		
	
		
			
				
					|  |  |  |  |                 Description = "Test-ApiResource-Description-1", | 
			
		
	
		
			
				
					|  |  |  |  |                 DisplayName = "Test-ApiResource-DisplayName-1" | 
			
		
	
		
			
				
					|  |  |  |  |             }; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddSecret("secret".Sha256()); | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddScope("Test-ApiResource-ApiScope-Name-1"); | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddScope("Test-ApiResource-ApiScope-DisplayName-1"); | 
			
		
	
		
			
				
					|  |  |  |  |             apiResource.AddUserClaim("Test-ApiResource-Claim-Type-1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             await _apiResourceRepository.InsertAsync(apiResource); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private async Task AddIdentityResources() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             var identityResource = new IdentityResource(_guidGenerator.Create(), "Test-Identity-Resource-Name-1") | 
			
		
	
		
			
				
					|  |  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  |  |                 Description = "Test-Identity-Resource-Description-1", | 
			
		
	
		
			
				
					|  |  |  |  |                 DisplayName = "Test-Identity-Resource-DisplayName-1", | 
			
		
	
		
			
				
					|  |  |  |  |                 Required = true, | 
			
		
	
		
			
				
					|  |  |  |  |                 Emphasize = true | 
			
		
	
		
			
				
					|  |  |  |  |             }; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             identityResource.AddUserClaim("Test-Identity-Resource-1-IdentityClaim-Type-1"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             await _identityResourceRepository.InsertAsync(identityResource); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |