From 141f3d8781bb286c8a88aa7c52ef03d9bafee066 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 28 Jan 2019 09:24:42 -0800 Subject: [PATCH] Reenable application initialization module tests (#7024) --- src/Servers/IIS/IIS/src/Core/IISHttpContext.cs | 11 +++++++++-- .../test/Common.FunctionalTests/Utilities/Helpers.cs | 5 +++++ .../test/IIS.Shared.FunctionalTests/ServicesTests.cs | 9 +++++---- src/Shared/HttpSys/NativeInterop/CookedUrl.cs | 4 ++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Servers/IIS/IIS/src/Core/IISHttpContext.cs b/src/Servers/IIS/IIS/src/Core/IISHttpContext.cs index 1e20316d27..750798aeec 100644 --- a/src/Servers/IIS/IIS/src/Core/IISHttpContext.cs +++ b/src/Servers/IIS/IIS/src/Core/IISHttpContext.cs @@ -182,9 +182,16 @@ namespace Microsoft.AspNetCore.Server.IIS.Core private string GetOriginalPath() { - // applicationInitialization request might have trailing \0 character included in the length - // check and skip it var rawUrlInBytes = GetRawUrlInBytes(); + + // Pre Windows 10 RS2 applicationInitialization request might not have pRawUrl set, fallback to cocked url + if (rawUrlInBytes == null) + { + return GetCookedUrl().GetAbsPath(); + } + + // ApplicationInitialization request might have trailing \0 character included in the length + // check and skip it if (rawUrlInBytes.Length > 0 && rawUrlInBytes[rawUrlInBytes.Length - 1] == 0) { var newRawUrlInBytes = new byte[rawUrlInBytes.Length - 1]; diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/Utilities/Helpers.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/Utilities/Helpers.cs index dde69b46e8..2f734ac909 100644 --- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/Utilities/Helpers.cs +++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/Utilities/Helpers.cs @@ -128,6 +128,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests return response; } + public static Task Retry(Func func, TimeSpan maxTime) + { + return Retry(func, (int)(maxTime.TotalMilliseconds / 200), 200); + } + public static async Task Retry(Func func, int attempts, int msDelay) { var exceptions = new List(); diff --git a/src/Servers/IIS/IIS/test/IIS.Shared.FunctionalTests/ServicesTests.cs b/src/Servers/IIS/IIS/test/IIS.Shared.FunctionalTests/ServicesTests.cs index 84ddd11b34..c4cc11637b 100644 --- a/src/Servers/IIS/IIS/test/IIS.Shared.FunctionalTests/ServicesTests.cs +++ b/src/Servers/IIS/IIS/test/IIS.Shared.FunctionalTests/ServicesTests.cs @@ -26,7 +26,7 @@ namespace IIS.FunctionalTests _fixture = fixture; } - [ConditionalTheory(Skip="https://github.com/aspnet/AspNetCore/issues/6752")] + [ConditionalTheory] [RequiresIIS(IISCapability.ApplicationInitialization)] [InlineData(HostingModel.InProcess)] [InlineData(HostingModel.OutOfProcess)] @@ -42,14 +42,15 @@ namespace IIS.FunctionalTests var result = await DeployAsync(baseDeploymentParameters); - await Helpers.Retry(async () => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), 10, 200); + await Helpers.Retry(async () => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), TimeoutExtensions.DefaultTimeoutValue); StopServer(); EventLogHelpers.VerifyEventLogEvent(result, EventLogHelpers.Started(result)); } } - [ConditionalTheory(Skip="https://github.com/aspnet/AspNetCore/issues/6752")] + [ConditionalTheory] [RequiresIIS(IISCapability.ApplicationInitialization)] + [RequiresNewHandler] [InlineData(HostingModel.InProcess)] [InlineData(HostingModel.OutOfProcess)] public async Task ApplicationInitializationPageIsRequested(HostingModel hostingModel) @@ -70,7 +71,7 @@ namespace IIS.FunctionalTests var result = await DeployAsync(baseDeploymentParameters); - await Helpers.Retry(async () => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), 10, 200); + await Helpers.Retry(async () => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), TimeoutExtensions.DefaultTimeoutValue); StopServer(); EventLogHelpers.VerifyEventLogEvent(result, EventLogHelpers.Started(result)); } diff --git a/src/Shared/HttpSys/NativeInterop/CookedUrl.cs b/src/Shared/HttpSys/NativeInterop/CookedUrl.cs index ee5b2ec53d..b51e073d67 100644 --- a/src/Shared/HttpSys/NativeInterop/CookedUrl.cs +++ b/src/Shared/HttpSys/NativeInterop/CookedUrl.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; namespace Microsoft.AspNetCore.HttpSys.Internal { // Note this type should only be used while the request buffer remains pinned - internal class CookedUrl + internal readonly struct CookedUrl { private readonly HttpApiTypes.HTTP_COOKED_URL _nativeCookedUrl;