public static IIdentityServerBuilder AddIntegrationTestConfiguration(this IIdentityServerBuilder builder) { builder.AddInMemoryClients(ClientSeedData.GetClients(SeedingType.IntegrationTest)); builder.AddInMemoryApiResources(ApiResourceSeedData.GetApiResources(SeedingType.IntegrationTest)); builder.AddInMemoryUsers(IdentityUserSeedData.GetIdentityUsers(SeedingType.IntegrationTest)); builder.AddInMemoryRoles(RoleSeedData.GetIdentityRoles(SeedingType.IntegrationTest)); builder.AddInMemoryUserRoles(IdentityUserRoleSeedData.GetIdentityUserRoles(SeedingType.IntegrationTest)); builder.AddInMemoryIdentityResources(IdentityResourceSeedData.GetIdentityResources(SeedingType.IntegrationTest)); builder.AddInMemoryPersistedGrants(); return(builder); }
/// <summary> /// Adds the API resources. /// </summary> /// <param name="context">The context.</param> /// <param name="seedingType">Type of the seeding.</param> private static void AddApiResources(ConfigurationDbContext context, SeedingType seedingType) { List <ApiResource> apiResources = ApiResourceSeedData.GetApiResources(seedingType); foreach (ApiResource apiResource in apiResources) { Boolean foundResource = context.ApiResources.Any(a => a.Name == apiResource.Name); if (!foundResource) { context.ApiResources.Add(apiResource.ToEntity()); context.SaveChanges(); } } }