A few changes
1. Adding helpers to install an app on IIS and run on top of native module 2. Enabled CoreCLR + Ntlm tests.
This commit is contained in:
parent
acc191efca
commit
0c59794996
|
|
@ -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]";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<DevelopmentServerPort>5001</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -53,37 +53,6 @@ namespace E2ETests
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy klr.iis\[arch] to bin folder
|
||||
/// </summary>
|
||||
/// <param name="applicationPath"></param>
|
||||
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();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ using Xunit;
|
|||
|
||||
namespace E2ETests
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for PublishAndRunTests
|
||||
/// </summary>
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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>(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>(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
ValidateLayoutPage(responseContent);
|
||||
Assert.Contains("<a href=\"/Store/Details/", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store/Details/"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("<title>Home Page – MVC Music Store</title>", 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("<li><a href=\"/\">Home</a></li>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("<a href=\"/Store\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Store <b class=\"caret\"></b></a>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(PrefixBaseAddress("<li><a href=\"/{0}\">Home</a></li>"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Store <b class=\"caret\"></b></a>"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("<ul class=\"dropdown-menu\">", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("<li class=\"divider\"></li>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
|
@ -70,7 +79,7 @@ namespace E2ETests
|
|||
ValidateLayoutPage(responseContent);
|
||||
Assert.Contains("<title>Log in – MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("<h4>Use a local account to log in.</h4>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Equal<string>(ApplicationBaseUrl + "Account/Login?ReturnUrl=%2FAdmin%2FStoreManager%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||
Assert.Equal<string>(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("<a href=\"/Admin/StoreManager/Edit?id={0}\">Edit</a>", albumId), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("<a href=\"/Admin/StoreManager\">Back to List</a>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(PrefixBaseAddress(string.Format("<a href=\"/{0}/Admin/StoreManager/Edit?id={1}\">Edit</a>", "{0}", albumId)), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Admin/StoreManager\">Back to List</a>"), 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>(HttpStatusCode.NotFound, response.StatusCode);
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
Console.WriteLine("Album is successfully deleted from the store.", albumName, albumId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
public enum ServerType
|
||||
{
|
||||
Helios,
|
||||
HeliosNativeModule,
|
||||
IISNativeModule,
|
||||
WebListener,
|
||||
Kestrel
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -24,5 +24,9 @@
|
|||
public bool PackApplicationBeforeStart { get; set; }
|
||||
|
||||
public string PackedApplicationRootPath { get; set; }
|
||||
|
||||
public string KreName { get; set; }
|
||||
|
||||
public IISApplication IISApplication { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue