diff --git a/src/MusicStore/Mocks/StartupSocialTesting.cs b/src/MusicStore/Mocks/StartupSocialTesting.cs index 71fd128eb8..e97b525c20 100644 --- a/src/MusicStore/Mocks/StartupSocialTesting.cs +++ b/src/MusicStore/Mocks/StartupSocialTesting.cs @@ -1,36 +1,43 @@ using System; +using System.IO; +using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Http; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Routing; -using Microsoft.Framework.ConfigurationModel; -using Microsoft.Framework.DependencyInjection; -using MusicStore.Models; using Microsoft.AspNet.Security.Facebook; using Microsoft.AspNet.Security.Google; -using Microsoft.AspNet.Security.Twitter; using Microsoft.AspNet.Security.MicrosoftAccount; +using Microsoft.AspNet.Security.Twitter; using Microsoft.Framework.Cache.Memory; +using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Runtime; using MusicStore.Mocks.Common; using MusicStore.Mocks.Facebook; -using MusicStore.Mocks.Twitter; using MusicStore.Mocks.Google; -using Microsoft.Framework.Runtime; -using System.Threading.Tasks; using MusicStore.Mocks.MicrosoftAccount; +using MusicStore.Mocks.Twitter; +using MusicStore.Models; namespace MusicStore { public class StartupSocialTesting { - public StartupSocialTesting() + public StartupSocialTesting(IApplicationEnvironment appEnvironment) { //Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, //then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely. Configuration = new Configuration() .AddJsonFile("config.json") .AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values. + + // Used to override some configuration parameters that cannot be overridden by environment. + if (File.Exists(Path.Combine(appEnvironment.ApplicationBasePath, "configoverride.json"))) + { + ((Configuration)Configuration).AddJsonFile("configoverride.json"); + } } public IConfiguration Configuration { get; private set; } @@ -44,7 +51,10 @@ namespace MusicStore app.UseServices(services => { //Sql client not available on mono - var useInMemoryStore = Type.GetType("Mono.Runtime") != null; + string value; + var useInMemoryStore = Configuration.TryGet("UseInMemoryStore", out value) && value == "true" ? + true : + Type.GetType("Mono.Runtime") != null; // Add EF services to the services container if (useInMemoryStore) @@ -125,7 +135,7 @@ namespace MusicStore app.UseFacebookAuthentication(); - app.UseGoogleAuthentication(options => + app.UseGoogleAuthentication(options => { options.ClientId = "[ClientId]"; options.ClientSecret = "[ClientSecret]"; diff --git a/src/MusicStore/MusicStore.kproj b/src/MusicStore/MusicStore.kproj index 3910cb78a8..abf0b43234 100644 --- a/src/MusicStore/MusicStore.kproj +++ b/src/MusicStore/MusicStore.kproj @@ -1,4 +1,4 @@ - + 14.0 @@ -12,6 +12,7 @@ 2.0 + 5001 diff --git a/src/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/StartupNtlmAuthentication.cs index d84f2d4ec8..b0a34a444b 100644 --- a/src/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/StartupNtlmAuthentication.cs @@ -1,15 +1,15 @@ using System; +using System.Security.Claims; +using System.Security.Principal; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Server.WebListener; +using Microsoft.Framework.Cache.Memory; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; -using MusicStore.Models; using Microsoft.Net.Http.Server; -using Microsoft.AspNet.Server.WebListener; -using System.Security.Claims; -using System.Security.Principal; -using Microsoft.Framework.Cache.Memory; +using MusicStore.Models; namespace MusicStore { @@ -43,7 +43,6 @@ namespace MusicStore { //Set up NTLM authentication for WebListener like below. //For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or modify the applicationHost.config to enable NTLM. - //Note: This does not work on CoreCLR yet! if ((app.Server as ServerInformation) != null) { var serverInformation = (ServerInformation)app.Server; @@ -55,13 +54,11 @@ namespace MusicStore //Who will get admin access? For demo sake I'm listing the currently logged on user as the application administrator. But this can be changed to suit the needs. var identity = (ClaimsIdentity)context.User.Identity; -#if ASPNET50 - //no WindowsIdentity yet on CoreCLR - if (identity.GetUserName() == Environment.UserDomainName + "\\" + Environment.UserName) + if (identity.GetUserName() == Environment.GetEnvironmentVariable("USERDOMAIN") + "\\" + Environment.GetEnvironmentVariable("USERNAME")) { identity.AddClaim(new Claim("ManageStore", "Allowed")); } -#endif + await next.Invoke(); }); diff --git a/test/E2ETests/DeploymentUtility.cs b/test/E2ETests/DeploymentUtility.cs index 12a42abf80..dc17d7b5cc 100644 --- a/test/E2ETests/DeploymentUtility.cs +++ b/test/E2ETests/DeploymentUtility.cs @@ -53,37 +53,6 @@ namespace E2ETests } } - /// - /// Copy klr.iis\[arch] to bin folder - /// - /// - private static void CopyKlrIIsBinFolder(StartParameters startParameters) - { - if (startParameters.ServerType == ServerType.HeliosNativeModule) - { - Console.WriteLine(@"Copying klr.iis\x86\* content to [ApplicationFolder]\bin\"); - var archFolderName = startParameters.KreArchitecture.ToString(); - var sourcePath = Path.Combine(Environment.CurrentDirectory, "NativeModule", "klr.iis", archFolderName); - var targetPath = Path.Combine(startParameters.ApplicationPath, "bin", archFolderName); - if (!Directory.Exists(targetPath)) - { - Directory.CreateDirectory(targetPath); - } - - try - { - foreach (var sourceFile in Directory.EnumerateFiles(sourcePath, "*", SearchOption.AllDirectories)) - { - File.Copy(sourceFile, Path.Combine(targetPath, Path.GetFileName(sourceFile)), true); - } - } - catch (Exception exception) - { - Console.WriteLine("Exception while copying assemblies", exception.Message); - } - } - } - private static string APP_RELATIVE_PATH = Path.Combine("..", "..", "src", "MusicStore"); public static Process StartApplication(StartParameters startParameters, string identityDbName) @@ -96,8 +65,16 @@ namespace E2ETests if (!string.IsNullOrWhiteSpace(startParameters.EnvironmentName)) { - //To choose an environment based Startup - Environment.SetEnvironmentVariable("KRE_ENV", startParameters.EnvironmentName); + if (startParameters.ServerType != ServerType.IISNativeModule) + { + // To choose an environment based Startup. + Environment.SetEnvironmentVariable("KRE_ENV", startParameters.EnvironmentName); + } + else + { + // Cannot override with environment in case of IIS. Pack and write a Microsoft.AspNet.Hosting.ini file. + startParameters.PackApplicationBeforeStart = true; + } } Process hostProcess = null; @@ -109,15 +86,39 @@ namespace E2ETests else { //Tweak the %PATH% to the point to the right KREFLAVOR - Environment.SetEnvironmentVariable("PATH", SwitchPathToKreFlavor(startParameters.KreFlavor, startParameters.KreArchitecture)); + startParameters.KreName = SwitchPathToKreFlavor(startParameters.KreFlavor, startParameters.KreArchitecture); //Reason to do pack here instead of in a common place is use the right KRE to do the packing. Previous line switches to use the right KRE. if (startParameters.PackApplicationBeforeStart) { - KpmPack(startParameters); + if (startParameters.ServerType == ServerType.IISNativeModule) + { + // Pack to IIS root\application folder. + KpmPack(startParameters, Path.Combine(Environment.GetEnvironmentVariable("SystemDrive") + @"\", @"inetpub\wwwroot")); + + // Drop a Microsoft.AspNet.Hosting.ini with KRE_ENV information. + var iniFile = Path.Combine(startParameters.ApplicationPath, "Microsoft.AspNet.Hosting.ini"); + File.WriteAllText(iniFile, string.Format("KRE_ENV={0}", startParameters.EnvironmentName)); + + // Can't use localdb with IIS. Setting an override to use InMemoryStore. + var overrideConfig = Path.Combine(startParameters.ApplicationPath, "..", "approot", "src", "MusicStore", "configoverride.json"); + overrideConfig = Path.GetFullPath(overrideConfig); + File.WriteAllText(overrideConfig, "{\"UseInMemoryStore\": \"true\"}"); + + Thread.Sleep(1 * 1000); + } + else + { + KpmPack(startParameters); + } } - if (startParameters.ServerType == ServerType.Helios || startParameters.ServerType == ServerType.HeliosNativeModule) + if (startParameters.ServerType == ServerType.IISNativeModule) + { + startParameters.IISApplication = new IISApplication(startParameters); + startParameters.IISApplication.SetupApplication(); + } + else if (startParameters.ServerType == ServerType.Helios) { hostProcess = StartHeliosHost(startParameters); } @@ -183,22 +184,7 @@ namespace E2ETests startParameters.ApplicationHostConfigTemplateContent.Replace("[ApplicationPhysicalPath]", startParameters.ApplicationPath); } - if (startParameters.ServerType == ServerType.HeliosNativeModule) - { - startParameters.ApplicationHostConfigTemplateContent = - startParameters.ApplicationHostConfigTemplateContent. - Replace("[KlrBootStrapperDirectory]", Path.Combine(Environment.CurrentDirectory, "NativeModule", "klr.iis.bootstrapper")); - } - - if (startParameters.ServerType == ServerType.Helios) - { - CopyAspNetLoader(startParameters.ApplicationPath); - } - else - { - //Native module - CopyKlrIIsBinFolder(startParameters); - } + CopyAspNetLoader(startParameters.ApplicationPath); if (!string.IsNullOrWhiteSpace(startParameters.ApplicationHostConfigTemplateContent)) { @@ -268,23 +254,31 @@ namespace E2ETests Console.WriteLine(); Console.WriteLine("Current %PATH% value : {0}", pathValue); - StringBuilder replaceStr = new StringBuilder(); - replaceStr.Append("KRE"); - replaceStr.Append((kreFlavor == KreFlavor.CoreClr) ? "-CoreCLR" : "-CLR"); - replaceStr.Append((kreArchitecture == KreArchitecture.x86) ? "-x86" : "-amd64"); + var replaceStr = new StringBuilder(). + Append("KRE"). + Append((kreFlavor == KreFlavor.CoreClr) ? "-CoreCLR" : "-CLR"). + Append((kreArchitecture == KreArchitecture.x86) ? "-x86" : "-amd64"). + ToString(); - pathValue = Regex.Replace(pathValue, "KRE-(CLR|CoreCLR)-(x86|amd64)", replaceStr.ToString(), RegexOptions.IgnoreCase); + pathValue = Regex.Replace(pathValue, "KRE-(CLR|CoreCLR)-(x86|amd64)", replaceStr, RegexOptions.IgnoreCase); + + var startIndex = pathValue.IndexOf(replaceStr); // First instance of this KRE name. + var kreName = pathValue.Substring(startIndex, pathValue.IndexOf(';', startIndex) - startIndex); + kreName = kreName.Substring(0, kreName.IndexOf('\\')); // Trim the \bin from the path. + + // Tweak the %PATH% to the point to the right KREFLAVOR. + Environment.SetEnvironmentVariable("PATH", pathValue); Console.WriteLine(); - Console.WriteLine("Setting %PATH% value to : {0}", pathValue); - return pathValue; + Console.WriteLine("Changing to use KRE : {0}", kreName); + return kreName; } - private static void KpmPack(StartParameters startParameters) + private static void KpmPack(StartParameters startParameters, string packRoot = null) { - startParameters.PackedApplicationRootPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + startParameters.PackedApplicationRootPath = Path.Combine(packRoot ?? Path.GetTempPath(), Guid.NewGuid().ToString()); - var parameters = string.Format("pack {0} -o {1}", startParameters.ApplicationPath, startParameters.PackedApplicationRootPath); + var parameters = string.Format("pack {0} -o {1} --runtime {2}", startParameters.ApplicationPath, startParameters.PackedApplicationRootPath, startParameters.KreName); Console.WriteLine(string.Format("Executing command kpm {0}", parameters)); var startInfo = new ProcessStartInfo @@ -298,7 +292,8 @@ namespace E2ETests var hostProcess = Process.Start(startInfo); hostProcess.WaitForExit(60 * 1000); - startParameters.ApplicationPath = (startParameters.ServerType == ServerType.Helios) ? + startParameters.ApplicationPath = + (startParameters.ServerType == ServerType.Helios || startParameters.ServerType == ServerType.IISNativeModule) ? Path.Combine(startParameters.PackedApplicationRootPath, "wwwroot") : Path.Combine(startParameters.PackedApplicationRootPath, "approot", "src", "MusicStore"); @@ -351,7 +346,12 @@ namespace E2ETests public static void CleanUpApplication(StartParameters startParameters, Process hostProcess, string musicStoreDbName) { - if (hostProcess != null && !hostProcess.HasExited) + if (startParameters.ServerType == ServerType.IISNativeModule) + { + // Stop & delete the application pool. + startParameters.IISApplication.StopAndDeleteAppPool(); + } + else if (hostProcess != null && !hostProcess.HasExited) { //Shutdown the host process hostProcess.Kill(); diff --git a/test/E2ETests/HeliosNativeModuleApplicationHost.config b/test/E2ETests/HeliosNativeModuleApplicationHost.config deleted file mode 100644 index a42e207737..0000000000 --- a/test/E2ETests/HeliosNativeModuleApplicationHost.config +++ /dev/null @@ -1,1036 +0,0 @@ - - - - - - - - -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
- -
-
- -
-
-
- - -
-
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/E2ETests/Helpers.cs b/test/E2ETests/Helpers.cs index cad8f55672..ff9ff5d0c9 100644 --- a/test/E2ETests/Helpers.cs +++ b/test/E2ETests/Helpers.cs @@ -12,7 +12,7 @@ namespace E2ETests } } - public static bool SkipTestOnCurrentConfiguration(bool RunTestOnMono, KreArchitecture architecture) + public static bool SkipTestOnCurrentConfiguration(bool RunTestOnMono, KreArchitecture architecture, ServerType serverType) { if (RunTestOnMono && !RunningOnMono) { @@ -35,6 +35,26 @@ namespace E2ETests return true; } + if (serverType == ServerType.IISNativeModule && + !(Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2)) + { + // Works only on 6.2 and above + Console.WriteLine("Skipping Native module test since machine is not Win2012R2/Win8.1 and above"); + return true; + } + + + //if (serverType == ServerType.IISNativeModule && + // Environment.GetEnvironmentVariable("IIS_NATIVE_MODULE_SETUP") != "true") + //{ + // // Native module variations require IIS setup. Once native module is setup on IIS, set the value of the environment + // // variable to true to run the native module variation. + // // TODO: Need a better way to detect native module on the machine. + // Console.WriteLine("Skipping Native module test since native module is not installed on IIS."); + // Console.WriteLine("Setup the native module and set the IIS_NATIVE_MODULE_SETUP to true to run the variation."); + // return true; + //} + return false; } } diff --git a/test/E2ETests/IISApplication.cs b/test/E2ETests/IISApplication.cs new file mode 100644 index 0000000000..64e9eab1f1 --- /dev/null +++ b/test/E2ETests/IISApplication.cs @@ -0,0 +1,67 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.Web.Administration; + +namespace E2ETests +{ + public class IISApplication + { + private const string WEBSITE_NAME = "MusicStore"; + private const string NATIVE_MODULE_MANAGED_RUNTIME_VERSION = "vCoreFX"; + + private readonly ServerManager _serverManager = new ServerManager(); + private readonly StartParameters _startParameters; + private ApplicationPool _applicationPool; + private Application _application; + + public string VirtualDirectoryName { get; set; } + + public IISApplication(StartParameters startParameters) + { + _startParameters = startParameters; + } + + public void SetupApplication() + { + VirtualDirectoryName = new DirectoryInfo(_startParameters.ApplicationPath).Parent.Name; + _applicationPool = CreateAppPool(VirtualDirectoryName); + _application = Website.Applications.Add("/" + VirtualDirectoryName, _startParameters.ApplicationPath); + _application.ApplicationPoolName = _applicationPool.Name; + _serverManager.CommitChanges(); + } + + private Site _website; + private Site Website + { + get + { + _website = _serverManager.Sites.Where(s => s.Name == WEBSITE_NAME).FirstOrDefault(); + if (_website == null) + { + _website = _serverManager.Sites.Add(WEBSITE_NAME, Path.Combine(Environment.GetEnvironmentVariable("SystemDrive") + @"\", @"inetpub\wwwroot"), 5005); + } + + return _website; + } + } + + private ApplicationPool CreateAppPool(string appPoolName) + { + var applicationPool = _serverManager.ApplicationPools.Add(appPoolName); + applicationPool.ManagedRuntimeVersion = NATIVE_MODULE_MANAGED_RUNTIME_VERSION; + applicationPool.Enable32BitAppOnWin64 = (_startParameters.KreArchitecture == KreArchitecture.x86); + return applicationPool; + } + + public void StopAndDeleteAppPool() + { + _applicationPool.Stop(); + // Remove the application from website. + _application = Website.Applications.Where(a => a.Path == _application.Path).FirstOrDefault(); + Website.Applications.Remove(_application); + _serverManager.ApplicationPools.Remove(_serverManager.ApplicationPools[_applicationPool.Name]); + _serverManager.CommitChanges(); + } + } +} \ No newline at end of file diff --git a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.dll b/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.dll deleted file mode 100644 index ffeb557cde..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.dll and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.dll.lastcodeanalysissucceeded b/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.dll.lastcodeanalysissucceeded deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.exp b/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.exp deleted file mode 100644 index 737728550b..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.exp and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.ilk b/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.ilk deleted file mode 100644 index 8d1b038988..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.ilk and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.lib b/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.lib deleted file mode 100644 index 8f0602d5d2..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.lib and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.pdb b/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.pdb deleted file mode 100644 index 73569487ec..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis.bootstrapper/klr.iis.bootstrapper.pdb and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.dll b/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.dll deleted file mode 100644 index cde22ba6e5..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.dll and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.dll.lastcodeanalysissucceeded b/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.dll.lastcodeanalysissucceeded deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.exp b/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.exp deleted file mode 100644 index 1aae434aec..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.exp and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.ilk b/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.ilk deleted file mode 100644 index b9e1d6ad56..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.ilk and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.lib b/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.lib deleted file mode 100644 index 6f28b2c60a..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.lib and /dev/null differ diff --git a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.pdb b/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.pdb deleted file mode 100644 index 58a28778f0..0000000000 Binary files a/test/E2ETests/NativeModule/klr.iis/x86/klr.iis.pdb and /dev/null differ diff --git a/test/E2ETests/NtlmAuthentationTest.cs b/test/E2ETests/NtlmAuthentationTest.cs index e51e8546a2..07b6221efd 100644 --- a/test/E2ETests/NtlmAuthentationTest.cs +++ b/test/E2ETests/NtlmAuthentationTest.cs @@ -9,23 +9,20 @@ namespace E2ETests public partial class SmokeTests { [Theory] - [InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")] - [InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5002/")] + [InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5001/")] - //WindowsIdentity not available on CoreCLR - //[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")] - //[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5002/")] + [InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5002/")] public void NtlmAuthenticationTest(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl) { Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl); - if (Helpers.SkipTestOnCurrentConfiguration(false, architecture)) + if (Helpers.SkipTestOnCurrentConfiguration(false, architecture, serverType)) { Assert.True(true); return; } - var startParameters = new StartParameters + startParameters = new StartParameters { ServerType = serverType, KreFlavor = kreFlavor, diff --git a/test/E2ETests/PublishAndRunTests.cs b/test/E2ETests/PublishAndRunTests.cs index af32b9f096..ed5d3e2fd6 100644 --- a/test/E2ETests/PublishAndRunTests.cs +++ b/test/E2ETests/PublishAndRunTests.cs @@ -8,9 +8,6 @@ using Xunit; namespace E2ETests { - /// - /// Summary description for PublishAndRunTests - /// public partial class SmokeTests { [Theory] @@ -19,17 +16,17 @@ namespace E2ETests //https://github.com/aspnet/KRuntime/issues/642 //[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/", false)] [InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/", true)] - public void PublishAndRunTests(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl, bool RunTestOnMono = false) + public void PublishAndRunTests(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl, bool runTestOnMono = false) { Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl); - if (Helpers.SkipTestOnCurrentConfiguration(RunTestOnMono, architecture)) + if (Helpers.SkipTestOnCurrentConfiguration(runTestOnMono, architecture, serverType)) { Assert.True(true); return; } - var startParameters = new StartParameters + startParameters = new StartParameters { ServerType = serverType, KreFlavor = kreFlavor, diff --git a/test/E2ETests/Scenarios.cs b/test/E2ETests/Scenarios.cs index bd34280714..3ceadcca58 100644 --- a/test/E2ETests/Scenarios.cs +++ b/test/E2ETests/Scenarios.cs @@ -1,9 +1,9 @@ -using Microsoft.AspNet.SignalR.Client; -using System; +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Threading; +using Microsoft.AspNet.SignalR.Client; using Xunit; namespace E2ETests @@ -22,7 +22,7 @@ namespace E2ETests Console.WriteLine("Sending an IfNoneMatch header with e-tag"); httpClient.DefaultRequestHeaders.IfNoneMatch.Add(response.Headers.ETag); response = httpClient.GetAsync("favicon.ico").Result; - Assert.Equal(HttpStatusCode.NotModified, response.StatusCode); + Assert.Equal(HttpStatusCode.NotModified, response.StatusCode); httpClient.DefaultRequestHeaders.IfNoneMatch.Clear(); Console.WriteLine("Successfully received a NotModified status"); @@ -35,9 +35,9 @@ namespace E2ETests private void VerifyHomePage(HttpResponseMessage response, string responseContent, bool useNtlmAuthentication = false) { Console.WriteLine("Home page content : {0}", responseContent); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); ValidateLayoutPage(responseContent); - Assert.Contains("Home Page – MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); if (!useNtlmAuthentication) @@ -52,11 +52,20 @@ namespace E2ETests Console.WriteLine("Application initialization successful."); } + private string PrefixBaseAddress(string url) + { + url = startParameters.ServerType == ServerType.IISNativeModule ? + string.Format(url, startParameters.IISApplication.VirtualDirectoryName) : + string.Format(url, string.Empty); + + return url.Replace("//", "/").Replace("%2F%2F", "%2F").Replace("%2F/", "%2F"); + } + private void ValidateLayoutPage(string responseContent) { Assert.Contains("ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); - Assert.Contains("
  • Home
  • ", responseContent, StringComparison.OrdinalIgnoreCase); - Assert.Contains("Store ", responseContent, StringComparison.OrdinalIgnoreCase); + Assert.Contains(PrefixBaseAddress("
  • Home
  • "), responseContent, StringComparison.OrdinalIgnoreCase); + Assert.Contains(PrefixBaseAddress("Store "), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("
      ", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("
    • ", responseContent, StringComparison.OrdinalIgnoreCase); } @@ -70,7 +79,7 @@ namespace E2ETests ValidateLayoutPage(responseContent); Assert.Contains("Log in – MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("

      Use a local account to log in.

      ", responseContent, StringComparison.OrdinalIgnoreCase); - Assert.Equal(ApplicationBaseUrl + "Account/Login?ReturnUrl=%2FAdmin%2FStoreManager%2F", response.RequestMessage.RequestUri.AbsoluteUri); + Assert.Equal(ApplicationBaseUrl + PrefixBaseAddress("Account/Login?ReturnUrl=%2F{0}%2FAdmin%2FStoreManager%2F"), response.RequestMessage.RequestUri.AbsoluteUri); Console.WriteLine("Redirected to login page as expected."); } @@ -331,8 +340,8 @@ namespace E2ETests var responseContent = response.Content.ReadAsStringAsync().Result; Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("http://myapp/testurl", responseContent, StringComparison.OrdinalIgnoreCase); - Assert.Contains(string.Format("Edit", albumId), responseContent, StringComparison.OrdinalIgnoreCase); - Assert.Contains("Back to List", responseContent, StringComparison.OrdinalIgnoreCase); + Assert.Contains(PrefixBaseAddress(string.Format("Edit", "{0}", albumId)), responseContent, StringComparison.OrdinalIgnoreCase); + Assert.Contains(PrefixBaseAddress("Back to List"), responseContent, StringComparison.OrdinalIgnoreCase); } // This gets the view that non-admin users get to see. @@ -400,7 +409,7 @@ namespace E2ETests Console.WriteLine("Verifying if the album '{0}' is deleted from store", albumName); response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result; - Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); + Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); Console.WriteLine("Album is successfully deleted from the store.", albumName, albumId); } diff --git a/test/E2ETests/ServerType.cs b/test/E2ETests/ServerType.cs index aa10657c47..e229407ab8 100644 --- a/test/E2ETests/ServerType.cs +++ b/test/E2ETests/ServerType.cs @@ -3,7 +3,7 @@ public enum ServerType { Helios, - HeliosNativeModule, + IISNativeModule, WebListener, Kestrel } diff --git a/test/E2ETests/SmokeTests.cs b/test/E2ETests/SmokeTests.cs index dc06396fe4..c1a0677d1b 100644 --- a/test/E2ETests/SmokeTests.cs +++ b/test/E2ETests/SmokeTests.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using System.IO; using System.Net; using System.Net.Http; using System.Threading; @@ -15,6 +14,7 @@ namespace E2ETests private string ApplicationBaseUrl; private HttpClient httpClient; private HttpClientHandler httpClientHandler; + private StartParameters startParameters; [Theory] [InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/", false)] @@ -27,25 +27,23 @@ namespace E2ETests [InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/", true)] [InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/", false)] [InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5004/", false)] - //Native module variation requires some more work - //[InlineData(ServerType.HeliosNativeModule, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/", false)] - public void SmokeTestSuite(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl, bool RunTestOnMono) + //[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5005/", false)] + //[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5005/", false)] + public void SmokeTestSuite(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl, bool runTestOnMono) { Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl); - if (Helpers.SkipTestOnCurrentConfiguration(RunTestOnMono, architecture)) + if (Helpers.SkipTestOnCurrentConfiguration(runTestOnMono, architecture, serverType)) { Assert.True(true); return; } - var startParameters = new StartParameters + startParameters = new StartParameters { ServerType = serverType, KreFlavor = kreFlavor, KreArchitecture = architecture, - ApplicationHostConfigTemplateContent = (serverType == ServerType.HeliosNativeModule) ? File.ReadAllText("HeliosNativeModuleApplicationHost.config") : null, - SiteName = (serverType == ServerType.HeliosNativeModule) ? "MusicStoreNativeModule" : null, EnvironmentName = "SocialTesting" }; @@ -64,9 +62,14 @@ namespace E2ETests try { hostProcess = DeploymentUtility.StartApplication(startParameters, musicStoreDbName); + if (serverType == ServerType.IISNativeModule) + { + // Accomodate the vdir name. + ApplicationBaseUrl += startParameters.IISApplication.VirtualDirectoryName + "/"; + } httpClientHandler = new HttpClientHandler(); - httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(applicationBaseUrl) }; + httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) }; HttpResponseMessage response = null; string responseContent = null; diff --git a/test/E2ETests/StartParameters.cs b/test/E2ETests/StartParameters.cs index c8707d670e..6e7ba15b67 100644 --- a/test/E2ETests/StartParameters.cs +++ b/test/E2ETests/StartParameters.cs @@ -24,5 +24,9 @@ public bool PackApplicationBeforeStart { get; set; } public string PackedApplicationRootPath { get; set; } + + public string KreName { get; set; } + + public IISApplication IISApplication { get; set; } } } \ No newline at end of file diff --git a/test/E2ETests/project.json b/test/E2ETests/project.json index 602b7e5398..ceb87814f2 100644 --- a/test/E2ETests/project.json +++ b/test/E2ETests/project.json @@ -6,9 +6,10 @@ "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*", + "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.AspNet.SignalR.Client": "2.1.1", - "Microsoft.AspNet.WebUtilities": "1.0.0-*" + "Microsoft.Web.Administration": "7.0.0", + "Xunit.KRunner": "1.0.0-*" }, "frameworks": { "aspnet50": {