Updated tests based on changes to AspNet Identity Core
Added .AddDefaultTokenProviders() after the call to ConfigureMongoDbIdentity Note: There are four places in the test project Added .AddAuthentication() to register all the authentication types Fixed aspnetsettings.json IncludeScopes to empty object, not false Updated unit test packages to latest version Added project reference for unit test rather than package reference Removed all references to AspNet framework assemblies as these are now part of the netcoreapp3.1
This commit is contained in:
+14
-10
@@ -7,14 +7,14 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using AspNetCore.Identity.MongoDbCore.Extensions;
|
||||
using AspNetCore.Identity.MongoDbCore.Infrastructure;
|
||||
using AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure;
|
||||
using AspNetCore.Identity.MongoDbCore.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Xunit;
|
||||
using AspNetCore.Identity.MongoDbCore.Models;
|
||||
using AspNetCore.Identity.MongoDbCore.Extensions;
|
||||
using AspNetCore.Identity.MongoDbCore.Infrastructure;
|
||||
using AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.Test
|
||||
{
|
||||
@@ -48,7 +48,10 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||
protected override void SetupIdentityServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepository.Context);
|
||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepository.Context)
|
||||
.AddDefaultTokenProviders();
|
||||
services.AddAuthentication();
|
||||
|
||||
services.AddLogging();
|
||||
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
||||
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
||||
@@ -64,14 +67,15 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
if (concurrentSetup)
|
||||
{
|
||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepositoryConcurrent.Context);
|
||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepositoryConcurrent.Context).AddDefaultTokenProviders();
|
||||
}
|
||||
else
|
||||
{
|
||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepository.Context);
|
||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepository.Context).AddDefaultTokenProviders();
|
||||
}
|
||||
|
||||
|
||||
services.AddLogging();
|
||||
services.AddAuthentication();
|
||||
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
||||
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
||||
}
|
||||
@@ -104,7 +108,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||
services = new ServiceCollection();
|
||||
}
|
||||
|
||||
if(context == null)
|
||||
if (context == null)
|
||||
{
|
||||
SetupIdentityServices(services);
|
||||
}
|
||||
@@ -112,7 +116,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||
{
|
||||
SetupIdentityServices(services, true);
|
||||
}
|
||||
|
||||
|
||||
return services.BuildServiceProvider().GetService<RoleManager<TRole>>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user