Changed the UmbracoIntegrationTest setup to be sync, to avoid issue with AsyncLocal
Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -20,7 +20,15 @@ namespace Umbraco.Core.Scoping
|
||||
/// <param name="name">The name with which to associate the new item in the call context.</param>
|
||||
/// <param name="data">The object to store in the call context.</param>
|
||||
public static void SetData(string name, T data) => _state.GetOrAdd(name, _ => new AsyncLocal<T>()).Value = data;
|
||||
|
||||
|
||||
//Replace the SetData with the following when you need to debug AsyncLocal. The args.ThreadContextChanged can be usefull
|
||||
//public static void SetData(string name, T data) => _state.GetOrAdd(name, _ => new AsyncLocal<T>(OnValueChanged)).Value = data;
|
||||
// public static void OnValueChanged(AsyncLocalValueChangedArgs<T> args)
|
||||
// {
|
||||
// var typeName = typeof(T).ToString();
|
||||
// Console.WriteLine($"OnValueChanged!, Type: {typeName} Prev: #{args.PreviousValue} Current: #{args.CurrentValue}");
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an object with the specified name from the <see cref="CallContext{T}"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -998,7 +998,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="groupPermissions"></param>
|
||||
/// <param name="pathIds"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityPermissionSet CalculatePermissionsForPathForUser(
|
||||
internal static EntityPermissionSet CalculatePermissionsForPathForUser(
|
||||
EntityPermission[] groupPermissions,
|
||||
int[] pathIds)
|
||||
{
|
||||
@@ -1075,7 +1075,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public static EntityPermission GetPermissionsForPathForGroup(
|
||||
internal static EntityPermission GetPermissionsForPathForGroup(
|
||||
IEnumerable<EntityPermission> pathPermissions,
|
||||
int[] pathIds,
|
||||
bool fallbackToDefaultPermissions = false)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Tests.Integration.TestServerTest
|
||||
public abstract class UmbracoTestServerTestBase : UmbracoIntegrationTest
|
||||
{
|
||||
[SetUp]
|
||||
public override Task Setup()
|
||||
public override void Setup()
|
||||
{
|
||||
InMemoryConfiguration["ConnectionStrings:" + Constants.System.UmbracoConnectionName] = null;
|
||||
InMemoryConfiguration["Umbraco:CMS:Hosting:Debug"] = "true";
|
||||
@@ -55,8 +55,6 @@ namespace Umbraco.Tests.Integration.TestServerTest
|
||||
});
|
||||
|
||||
LinkGenerator = Factory.Services.GetRequiredService<LinkGenerator>();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override IHostBuilder CreateHostBuilder()
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
[NonParallelizable]
|
||||
public abstract class UmbracoIntegrationTest
|
||||
{
|
||||
|
||||
public static LightInjectContainer CreateUmbracoContainer(out UmbracoServiceProviderFactory serviceProviderFactory)
|
||||
{
|
||||
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
|
||||
@@ -80,10 +81,10 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public virtual async Task Setup()
|
||||
public virtual void Setup()
|
||||
{
|
||||
var hostBuilder = CreateHostBuilder();
|
||||
var host = await hostBuilder.StartAsync();
|
||||
var host = hostBuilder.StartAsync().GetAwaiter().GetResult();
|
||||
Services = host.Services;
|
||||
var app = new ApplicationBuilder(host.Services);
|
||||
Configure(app);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Web.Common.Security
|
||||
/// <inheritdoc />
|
||||
public Attempt<int> GetUserId()
|
||||
{
|
||||
var identity = _httpContextAccessor.GetRequiredHttpContext().GetCurrentIdentity();
|
||||
var identity = _httpContextAccessor.HttpContext?.GetCurrentIdentity();
|
||||
return identity == null ? Attempt.Fail<int>() : Attempt.Succeed(identity.Id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user