Merge pull request #40 from d-barker/netcoreapp3.1
Remove AspNet 2.2 dependencies
This commit is contained in:
+6
-2
@@ -297,5 +297,9 @@ __pycache__/
|
|||||||
*.btm.cs
|
*.btm.cs
|
||||||
*.odx.cs
|
*.odx.cs
|
||||||
*.xsd.cs
|
*.xsd.cs
|
||||||
sample/MongoIdentitySample.Mvc/appsettings.local.json
|
|
||||||
test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.local.json
|
# Local app settings for development
|
||||||
|
**/**/appsettings.local.json
|
||||||
|
|
||||||
|
# Output from the code coverage analysis
|
||||||
|
**/**/coverage.json
|
||||||
@@ -8,20 +8,15 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.Identity.MongoDbCore" Version="2.1.1" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.17.0" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.13.0-beta1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.12" Condition="'$(Configuration)' == 'Debug'" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.0" Condition="'$(Configuration)' == 'Debug'" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -35,5 +30,10 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<!-- Select one of the following to build this solution -->
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- <PackageReference Include="AspNetCore.Identity.MongoDbCore" Version="3.1.0" /> -->
|
||||||
|
<ProjectReference Include="..\..\src\AspNetCore.Identity.MongoDbCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
using AspNetCore.Identity.MongoDbCore.Infrastructure;
|
using System;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.Infrastructure;
|
||||||
using AspNetCore.Identity.MongoDbCore.Models;
|
using AspNetCore.Identity.MongoDbCore.Models;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using MongoIdentitySample.Mvc.Models;
|
using MongoIdentitySample.Mvc.Models;
|
||||||
using MongoIdentitySample.Mvc.Services;
|
using MongoIdentitySample.Mvc.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace MongoIdentitySample.Mvc
|
namespace MongoIdentitySample.Mvc
|
||||||
{
|
{
|
||||||
@@ -49,15 +49,14 @@ namespace MongoIdentitySample.Mvc
|
|||||||
|
|
||||||
var builder = services.AddRazorPages();
|
var builder = services.AddRazorPages();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(_env.IsDevelopment())
|
if (_env.IsDevelopment())
|
||||||
{
|
{
|
||||||
builder.AddRazorRuntimeCompilation();
|
builder.AddRazorRuntimeCompilation();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
|
|
||||||
services.AddApplicationInsightsTelemetry();
|
services.AddApplicationInsightsTelemetry();
|
||||||
|
|
||||||
// Add application services.
|
// Add application services.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"DatabaseName": "MongoDbTests"
|
"DatabaseName": "MongoDbTests"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"IncludeScopes": false,
|
"IncludeScopes": {},
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning"
|
"Default": "Warning"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp3.1;netstandard2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1;netstandard2.1</TargetFrameworks>
|
||||||
|
<Version>3.1.0</Version>
|
||||||
|
<FileVersion>3.1.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
@@ -13,8 +15,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.12" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
|
||||||
<PackageReference Include="MongoDB.Driver" Version="2.9.3" />
|
<PackageReference Include="MongoDB.Driver" Version="2.9.3" />
|
||||||
<PackageReference Include="MongoDbGenericRepository" Version="1.4.3" />
|
<PackageReference Include="MongoDbGenericRepository" Version="1.4.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -2,29 +2,29 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>AspNetCore.Identity.MongoDbCore</id>
|
<id>AspNetCore.Identity.MongoDbCore</id>
|
||||||
<version>2.1.1</version>
|
<version>3.1.0</version>
|
||||||
<title>AspNetCore.Identity.MongoDbCore</title>
|
<title>AspNetCore.Identity.MongoDbCore</title>
|
||||||
<authors>Alexandre Spieser</authors>
|
<authors>Alexandre Spieser</authors>
|
||||||
<owners>Alexandre Spieser</owners>
|
<owners>Alexandre Spieser</owners>
|
||||||
<license type="expression">MIT</license>
|
<license type="expression">MIT</license>
|
||||||
<projectUrl>https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore</projectUrl>
|
<projectUrl>https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore</projectUrl>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
<description>A MongoDb UserStore and RoleStore adapter for Microsoft.AspNetCore.Identity 2.2.</description>
|
<description>A MongoDb UserStore and RoleStore adapter for Microsoft.Extensions.Identity.Core 3.1.</description>
|
||||||
<releaseNotes>Release notes are at https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore/releases</releaseNotes>
|
<releaseNotes>Release notes are at https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore/releases</releaseNotes>
|
||||||
<copyright>Copyright 2020 (c) Alexandre Spieser. All rights reserved.</copyright>
|
<copyright>Copyright 2020 (c) Alexandre Spieser. All rights reserved.</copyright>
|
||||||
<tags>aspnetcore mongo mongodb identity membership</tags>
|
<tags>aspnetcore mongo mongodb identity membership</tags>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<group targetFramework="netstandard2.1">
|
<group targetFramework="netstandard2.1">
|
||||||
<dependency id="Microsoft.AspNetCore.Identity" version="2.2.0" />
|
<dependency id="Microsoft.Extensions.Identity.Core" version="3.1.8" />
|
||||||
<dependency id="Microsoft.Extensions.Identity.Stores" version="3.1.1" />
|
<dependency id="Microsoft.Extensions.Identity.Stores" version="3.1.8" />
|
||||||
<dependency id="MongoDB.Driver" version="2.9.3" />
|
<dependency id="MongoDB.Driver" version="2.9.3" />
|
||||||
<dependency id="MongoDbGenericRepository" version="1.4.1" />
|
<dependency id="MongoDbGenericRepository" version="1.4.5" />
|
||||||
</group>
|
</group>
|
||||||
<group targetFramework="netcoreapp3.1">
|
<group targetFramework="netcoreapp3.1">
|
||||||
<dependency id="Microsoft.AspNetCore.Identity" version="2.2" />
|
<dependency id="Microsoft.Extensions.Identity.Core" version="3.1.8" />
|
||||||
<dependency id="Microsoft.Extensions.Identity.Stores" version="3.1.1" />
|
<dependency id="Microsoft.Extensions.Identity.Stores" version="3.1.8" />
|
||||||
<dependency id="MongoDB.Driver" version="2.9.3" />
|
<dependency id="MongoDB.Driver" version="2.9.3" />
|
||||||
<dependency id="MongoDbGenericRepository" version="1.4.3" />
|
<dependency id="MongoDbGenericRepository" version="1.4.5" />
|
||||||
</group>
|
</group>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using AspNetCore.Identity.MongoDbCore.Infrastructure;
|
using System;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.Infrastructure;
|
||||||
using AspNetCore.Identity.MongoDbCore.Models;
|
using AspNetCore.Identity.MongoDbCore.Models;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Identity.Core;
|
||||||
using MongoDbGenericRepository;
|
using MongoDbGenericRepository;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace AspNetCore.Identity.MongoDbCore.Extensions
|
namespace AspNetCore.Identity.MongoDbCore.Extensions
|
||||||
{
|
{
|
||||||
@@ -19,14 +20,15 @@ namespace AspNetCore.Identity.MongoDbCore.Extensions
|
|||||||
/// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam>
|
/// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam>
|
||||||
/// <param name="services">The collection of service descriptors.</param>
|
/// <param name="services">The collection of service descriptors.</param>
|
||||||
/// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param>
|
/// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param>
|
||||||
public static void ConfigureMongoDbIdentityUserOnly<TUser, TKey>(
|
public static IdentityBuilder ConfigureMongoDbIdentityUserOnly<TUser, TKey>(
|
||||||
this IServiceCollection services,
|
this IServiceCollection services,
|
||||||
MongoDbIdentityConfiguration mongoDbIdentityConfiguration)
|
MongoDbIdentityConfiguration mongoDbIdentityConfiguration)
|
||||||
where TUser : MongoIdentityUser<TKey>, new()
|
where TUser : MongoIdentityUser<TKey>, new()
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings);
|
ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings);
|
||||||
CommonMongoDbSetup<TUser, MongoIdentityRole<TKey>, TKey>(services, mongoDbIdentityConfiguration);
|
|
||||||
|
return CommonMongoDbSetup<TUser, MongoIdentityRole<TKey>, TKey>(services, mongoDbIdentityConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -36,11 +38,12 @@ namespace AspNetCore.Identity.MongoDbCore.Extensions
|
|||||||
/// <typeparam name="TUser">The type representing a user.</typeparam>
|
/// <typeparam name="TUser">The type representing a user.</typeparam>
|
||||||
/// <param name="services">The collection of service descriptors.</param>
|
/// <param name="services">The collection of service descriptors.</param>
|
||||||
/// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param>
|
/// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param>
|
||||||
public static void ConfigureMongoDbIdentity<TUser>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration)
|
public static IdentityBuilder ConfigureMongoDbIdentity<TUser>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration)
|
||||||
where TUser : MongoIdentityUser, new()
|
where TUser : MongoIdentityUser, new()
|
||||||
{
|
{
|
||||||
ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings);
|
ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings);
|
||||||
CommonMongoDbSetup<TUser, MongoIdentityRole, Guid>(services, mongoDbIdentityConfiguration);
|
|
||||||
|
return CommonMongoDbSetup<TUser, MongoIdentityRole, Guid>(services, mongoDbIdentityConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -74,51 +77,60 @@ namespace AspNetCore.Identity.MongoDbCore.Extensions
|
|||||||
/// <param name="services">The collection of service descriptors.</param>
|
/// <param name="services">The collection of service descriptors.</param>
|
||||||
/// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param>
|
/// <param name="mongoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.MongoDbCore package.</param>
|
||||||
/// <param name="mongoDbContext">An object representing a MongoDb connection.</param>
|
/// <param name="mongoDbContext">An object representing a MongoDb connection.</param>
|
||||||
public static void ConfigureMongoDbIdentity<TUser, TRole, TKey>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration,
|
public static IdentityBuilder ConfigureMongoDbIdentity<TUser, TRole, TKey>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration,
|
||||||
IMongoDbContext mongoDbContext = null)
|
IMongoDbContext mongoDbContext = null)
|
||||||
where TUser : MongoIdentityUser<TKey>, new()
|
where TUser : MongoIdentityUser<TKey>, new()
|
||||||
where TRole : MongoIdentityRole<TKey>, new()
|
where TRole : MongoIdentityRole<TKey>, new()
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
|
IdentityBuilder builder;
|
||||||
|
|
||||||
ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings);
|
ValidateMongoDbSettings(mongoDbIdentityConfiguration.MongoDbSettings);
|
||||||
|
|
||||||
if(mongoDbContext == null)
|
if (mongoDbContext == null)
|
||||||
{
|
{
|
||||||
services.AddIdentity<TUser, TRole>()
|
builder = services.AddIdentityCore<TUser>()
|
||||||
|
.AddRoles<TRole>()
|
||||||
.AddMongoDbStores<TUser, TRole, TKey>(
|
.AddMongoDbStores<TUser, TRole, TKey>(
|
||||||
mongoDbIdentityConfiguration.MongoDbSettings.ConnectionString,
|
mongoDbIdentityConfiguration.MongoDbSettings.ConnectionString,
|
||||||
mongoDbIdentityConfiguration.MongoDbSettings.DatabaseName)
|
mongoDbIdentityConfiguration.MongoDbSettings.DatabaseName);
|
||||||
.AddDefaultTokenProviders();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
services.AddIdentity<TUser, TRole>()
|
builder = services.AddIdentityCore<TUser>()
|
||||||
.AddMongoDbStores<IMongoDbContext>(mongoDbContext)
|
.AddRoles<TRole>()
|
||||||
.AddDefaultTokenProviders();
|
.AddMongoDbStores<IMongoDbContext>(mongoDbContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mongoDbIdentityConfiguration.IdentityOptionsAction != null)
|
if (mongoDbIdentityConfiguration.IdentityOptionsAction != null)
|
||||||
{
|
{
|
||||||
services.Configure(mongoDbIdentityConfiguration.IdentityOptionsAction);
|
services.Configure(mongoDbIdentityConfiguration.IdentityOptionsAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void CommonMongoDbSetup<TUser, TRole, TKey>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration)
|
private static IdentityBuilder CommonMongoDbSetup<TUser, TRole, TKey>(this IServiceCollection services, MongoDbIdentityConfiguration mongoDbIdentityConfiguration)
|
||||||
where TUser : MongoIdentityUser<TKey>, new()
|
where TUser : MongoIdentityUser<TKey>, new()
|
||||||
where TRole : MongoIdentityRole<TKey>, new()
|
where TRole : MongoIdentityRole<TKey>, new()
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
services.AddIdentity<TUser, TRole>()
|
|
||||||
|
IdentityBuilder builder;
|
||||||
|
|
||||||
|
builder = services.AddIdentityCore<TUser>()
|
||||||
|
.AddRoles<TRole>()
|
||||||
.AddMongoDbStores<TUser, TRole, TKey>(
|
.AddMongoDbStores<TUser, TRole, TKey>(
|
||||||
mongoDbIdentityConfiguration.MongoDbSettings.ConnectionString,
|
mongoDbIdentityConfiguration.MongoDbSettings.ConnectionString,
|
||||||
mongoDbIdentityConfiguration.MongoDbSettings.DatabaseName)
|
mongoDbIdentityConfiguration.MongoDbSettings.DatabaseName);
|
||||||
.AddDefaultTokenProviders();
|
|
||||||
|
|
||||||
if (mongoDbIdentityConfiguration.IdentityOptionsAction != null)
|
if (mongoDbIdentityConfiguration.IdentityOptionsAction != null)
|
||||||
{
|
{
|
||||||
services.Configure(mongoDbIdentityConfiguration.IdentityOptionsAction);
|
services.Configure(mongoDbIdentityConfiguration.IdentityOptionsAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
Write-Output "Package AspNetCore.Identity.MongoDbCore"
|
||||||
|
|
||||||
|
Remove-Item -Path "./bin/Release" -Force -Recurse
|
||||||
|
|
||||||
|
& dotnet pack -c Release -p:NuspecFile=AspNetCore.Identity.MongoDbCore.nuspec
|
||||||
+14
-12
@@ -7,23 +7,21 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.Identity.MongoDbCore" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.12" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||||
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
|
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
|
||||||
<PackageReference Include="MongoDbGenericRepository" Version="1.4.3" />
|
<PackageReference Include="MongoDbGenericRepository" Version="1.4.3" />
|
||||||
<PackageReference Include="Moq" Version="4.13.1" />
|
<PackageReference Include="Moq" Version="4.13.1" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="dotnet-reportgenerator-cli" Version="4.6.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
@@ -35,4 +33,8 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\AspNetCore.Identity.MongoDbCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+9
-6
@@ -6,17 +6,17 @@ using System.Linq;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.Extensions;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.Models;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity.Test;
|
using Microsoft.AspNetCore.Identity.Test;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Xunit;
|
|
||||||
using AspNetCore.Identity.MongoDbCore.Models;
|
|
||||||
using AspNetCore.Identity.MongoDbCore.Extensions;
|
|
||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
using AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure;
|
|
||||||
using MongoDbGenericRepository;
|
using MongoDbGenericRepository;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Xunit;
|
||||||
|
|
||||||
namespace AspNetCore.Identity.MongoDbCore.Test
|
namespace AspNetCore.Identity.MongoDbCore.Test
|
||||||
{
|
{
|
||||||
@@ -39,9 +39,12 @@ namespace AspNetCore.Identity.MongoDbCore.Test
|
|||||||
{
|
{
|
||||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
// configure the default type name
|
// configure the default type name
|
||||||
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.AddLogging();
|
||||||
|
|
||||||
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
||||||
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -4,13 +4,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure;
|
||||||
|
using AspNetCore.Identity.MongoDbCore.Models;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity.Test;
|
using Microsoft.AspNetCore.Identity.Test;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Xunit;
|
|
||||||
using AspNetCore.Identity.MongoDbCore.Models;
|
|
||||||
using AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure;
|
|
||||||
using MongoDbGenericRepository;
|
using MongoDbGenericRepository;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Xunit;
|
||||||
|
|
||||||
namespace AspNetCore.Identity.MongoDbCore.Test
|
namespace AspNetCore.Identity.MongoDbCore.Test
|
||||||
{
|
{
|
||||||
@@ -308,8 +308,8 @@ namespace AspNetCore.Identity.MongoDbCore.Test
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
const string originalEmail = "original@email.com";
|
const string originalEmail = "original@email.com";
|
||||||
const string newEmail1 = "new1@email.com";
|
string newEmail1 = $"new{DateTime.Now.Ticks}@email.com";
|
||||||
const string newEmail2 = "new2@email.com";
|
string newEmail2 = $"new{DateTime.Now.Ticks+1}@email.com";
|
||||||
var user = CreateTestUser();
|
var user = CreateTestUser();
|
||||||
user.Email = originalEmail;
|
user.Email = originalEmail;
|
||||||
var manager = CreateManager();
|
var manager = CreateManager();
|
||||||
|
|||||||
+14
-8
@@ -7,14 +7,14 @@ using System.Linq;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
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.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Xunit;
|
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
|
namespace Microsoft.AspNetCore.Identity.Test
|
||||||
{
|
{
|
||||||
@@ -48,7 +48,10 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||||||
protected override void SetupIdentityServices(IServiceCollection services)
|
protected override void SetupIdentityServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
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.AddLogging();
|
||||||
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
||||||
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
||||||
@@ -64,14 +67,17 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
if (concurrentSetup)
|
if (concurrentSetup)
|
||||||
{
|
{
|
||||||
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepositoryConcurrent.Context);
|
services.ConfigureMongoDbIdentity<TUser, TRole, TKey>(Container.MongoDbIdentityConfiguration, Container.MongoRepositoryConcurrent.Context)
|
||||||
|
.AddDefaultTokenProviders();
|
||||||
}
|
}
|
||||||
else
|
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.AddLogging();
|
||||||
|
services.AddAuthentication();
|
||||||
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
||||||
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
services.AddSingleton<ILogger<RoleManager<TRole>>>(new TestLogger<RoleManager<TRole>>());
|
||||||
}
|
}
|
||||||
@@ -104,7 +110,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||||||
services = new ServiceCollection();
|
services = new ServiceCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
SetupIdentityServices(services);
|
SetupIdentityServices(services);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"DatabaseName": "MongoDbTests"
|
"DatabaseName": "MongoDbTests"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"IncludeScopes": false,
|
"IncludeScopes": {},
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning"
|
"Default": "Warning"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
Write-Output ""
|
||||||
|
Write-Output "Running Tests with Code Coverage"
|
||||||
|
Write-Output ""
|
||||||
|
|
||||||
|
|
||||||
|
& 'dotnet' test /p:CollectCoverage=true
|
||||||
Reference in New Issue
Block a user