Working installation. Use of Thread.CurrentPrincipal removed for now
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Threading;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Identity
|
||||
namespace Umbraco.Core.BackOffice
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is used by events raised from the BackofficeUserManager
|
||||
@@ -108,9 +108,9 @@ namespace Umbraco.Web.BackOffice.Identity
|
||||
protected int GetCurrentRequestBackofficeUserId()
|
||||
{
|
||||
var userId = -1;
|
||||
var backOfficeIdentity = Thread.CurrentPrincipal.GetUmbracoIdentity();
|
||||
/*var backOfficeIdentity = Thread.CurrentPrincipal.GetUmbracoIdentity();
|
||||
if (backOfficeIdentity != null)
|
||||
int.TryParse(backOfficeIdentity.Id.ToString(), out userId);
|
||||
int.TryParse(backOfficeIdentity.Id.ToString(), out userId);*/
|
||||
return userId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,8 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
// Add it!
|
||||
services.AddUmbracoConfiguration(hostContext.Configuration);
|
||||
services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly, NoAppCache.Instance, testHelper.GetLoggingConfiguration(), out _);
|
||||
|
||||
CustomTestSetup(services);
|
||||
});
|
||||
|
||||
var host = await hostBuilder.StartAsync();
|
||||
@@ -123,6 +125,8 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
|
||||
#region Common services
|
||||
|
||||
protected virtual Action<IServiceCollection> CustomTestSetup => services => { };
|
||||
|
||||
/// <summary>
|
||||
/// Returns the DI container
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Extensions;
|
||||
using Umbraco.Core.BackOffice;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Tests.Integration.Extensions;
|
||||
using Umbraco.Tests.Integration.Implementations;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Web.BackOffice.Extensions
|
||||
{
|
||||
[TestFixture]
|
||||
public class UmbracoBackOfficeServiceCollectionExtensionsTests : UmbracoIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public void AddUmbracoBackOfficeIdentity_ExpectBackOfficeUserStoreResolvable()
|
||||
{
|
||||
var userStore = Services.GetService<IUserStore<BackOfficeIdentityUser>>();
|
||||
|
||||
Assert.IsNotNull(userStore);
|
||||
Assert.AreEqual(typeof(BackOfficeUserStore), userStore.GetType());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddUmbracoBackOfficeIdentity_ExpectBackOfficeUserManagerResolvable()
|
||||
{
|
||||
var userManager = Services.GetService<BackOfficeUserManager>();
|
||||
|
||||
Assert.NotNull(userManager);
|
||||
}
|
||||
|
||||
protected override Action<IServiceCollection> CustomTestSetup => (services) => services.AddUmbracoBackOfficeIdentity();
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Extensions;
|
||||
using Umbraco.Core.BackOffice;
|
||||
|
||||
namespace Umbraco.Tests.UnitTests.Umbraco.Web.BackOffice.Extensions
|
||||
{
|
||||
[TestFixture]
|
||||
public class UmbracoBackOfficeServiceCollectionExtensionsTests
|
||||
{
|
||||
/*[Test]
|
||||
public void AddUmbracoBackOfficeIdentity_ExpectBackOfficeUserStoreResolvable()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
var mockEnvironment = new Mock<IWebHostEnvironment>();
|
||||
|
||||
services.AddUmbracoCore(mockEnvironment.Object);
|
||||
services.AddUmbracoBackOfficeIdentity();
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
var userStore = serviceProvider.GetService<IUserStore<BackOfficeIdentityUser>>();
|
||||
Assert.AreEqual(typeof(BackOfficeUserStore), userStore.GetType());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.BackOffice;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web.Common.AspNetCore;
|
||||
@@ -13,7 +12,7 @@ namespace Umbraco.Extensions
|
||||
{
|
||||
public static class UmbracoBackOfficeServiceCollectionExtensions
|
||||
{
|
||||
public static void AddUmbracoBackOfficeIdentity(this IServiceCollection services, IFactory factory)
|
||||
public static void AddUmbracoBackOfficeIdentity(this IServiceCollection services)
|
||||
{
|
||||
// UmbracoMapper - hack?
|
||||
services.AddSingleton<IdentityMapDefinition>();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Web.UI.BackOffice
|
||||
services.AddUmbracoCore(_env, out var factory);
|
||||
services.AddUmbracoWebComponents();
|
||||
services.AddUmbracoRuntimeMinifier(_config);
|
||||
services.AddUmbracoBackOfficeIdentity(factory);
|
||||
services.AddUmbracoBackOfficeIdentity();
|
||||
|
||||
services.AddMvc();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user