Enabling IIS variation of the test
Also organizing some test code.
This commit is contained in:
parent
3c49e439c9
commit
68102b8786
|
|
@ -66,7 +66,8 @@ namespace E2ETests
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(startParameters.EnvironmentName))
|
if (!string.IsNullOrWhiteSpace(startParameters.EnvironmentName))
|
||||||
{
|
{
|
||||||
if (startParameters.ServerType != ServerType.IISNativeModule)
|
if (startParameters.ServerType != ServerType.IISNativeModule &&
|
||||||
|
startParameters.ServerType != ServerType.IIS)
|
||||||
{
|
{
|
||||||
// To choose an environment based Startup.
|
// To choose an environment based Startup.
|
||||||
Environment.SetEnvironmentVariable("KRE_ENV", startParameters.EnvironmentName);
|
Environment.SetEnvironmentVariable("KRE_ENV", startParameters.EnvironmentName);
|
||||||
|
|
@ -92,7 +93,8 @@ namespace E2ETests
|
||||||
//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.
|
//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)
|
if (startParameters.PackApplicationBeforeStart)
|
||||||
{
|
{
|
||||||
if (startParameters.ServerType == ServerType.IISNativeModule)
|
if (startParameters.ServerType == ServerType.IISNativeModule ||
|
||||||
|
startParameters.ServerType == ServerType.IIS)
|
||||||
{
|
{
|
||||||
// Pack to IIS root\application folder.
|
// Pack to IIS root\application folder.
|
||||||
KpmPack(startParameters, Path.Combine(Environment.GetEnvironmentVariable("SystemDrive") + @"\", @"inetpub\wwwroot"));
|
KpmPack(startParameters, Path.Combine(Environment.GetEnvironmentVariable("SystemDrive") + @"\", @"inetpub\wwwroot"));
|
||||||
|
|
@ -106,20 +108,23 @@ namespace E2ETests
|
||||||
overrideConfig = Path.GetFullPath(overrideConfig);
|
overrideConfig = Path.GetFullPath(overrideConfig);
|
||||||
File.WriteAllText(overrideConfig, "{\"UseInMemoryStore\": \"true\"}");
|
File.WriteAllText(overrideConfig, "{\"UseInMemoryStore\": \"true\"}");
|
||||||
|
|
||||||
// Set runAllManagedModulesForAllRequests=true
|
if (startParameters.ServerType == ServerType.IISNativeModule)
|
||||||
var webConfig = Path.Combine(startParameters.ApplicationPath, "web.config");
|
{
|
||||||
var configuration = new XmlDocument();
|
// Set runAllManagedModulesForAllRequests=true
|
||||||
configuration.LoadXml(File.ReadAllText(webConfig));
|
var webConfig = Path.Combine(startParameters.ApplicationPath, "web.config");
|
||||||
|
var configuration = new XmlDocument();
|
||||||
|
configuration.LoadXml(File.ReadAllText(webConfig));
|
||||||
|
|
||||||
// https://github.com/aspnet/Helios/issues/77
|
// https://github.com/aspnet/Helios/issues/77
|
||||||
var rammfarAttribute = configuration.CreateAttribute("runAllManagedModulesForAllRequests");
|
var rammfarAttribute = configuration.CreateAttribute("runAllManagedModulesForAllRequests");
|
||||||
rammfarAttribute.Value = "true";
|
rammfarAttribute.Value = "true";
|
||||||
var modulesNode = configuration.CreateElement("modules");
|
var modulesNode = configuration.CreateElement("modules");
|
||||||
modulesNode.Attributes.Append(rammfarAttribute);
|
modulesNode.Attributes.Append(rammfarAttribute);
|
||||||
var systemWebServerNode = configuration.CreateElement("system.webServer");
|
var systemWebServerNode = configuration.CreateElement("system.webServer");
|
||||||
systemWebServerNode.AppendChild(modulesNode);
|
systemWebServerNode.AppendChild(modulesNode);
|
||||||
configuration.SelectSingleNode("//configuration").AppendChild(systemWebServerNode);
|
configuration.SelectSingleNode("//configuration").AppendChild(systemWebServerNode);
|
||||||
configuration.Save(webConfig);
|
configuration.Save(webConfig);
|
||||||
|
}
|
||||||
|
|
||||||
Thread.Sleep(1 * 1000);
|
Thread.Sleep(1 * 1000);
|
||||||
}
|
}
|
||||||
|
|
@ -129,12 +134,13 @@ namespace E2ETests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startParameters.ServerType == ServerType.IISNativeModule)
|
if (startParameters.ServerType == ServerType.IISNativeModule ||
|
||||||
|
startParameters.ServerType == ServerType.IIS)
|
||||||
{
|
{
|
||||||
startParameters.IISApplication = new IISApplication(startParameters);
|
startParameters.IISApplication = new IISApplication(startParameters);
|
||||||
startParameters.IISApplication.SetupApplication();
|
startParameters.IISApplication.SetupApplication();
|
||||||
}
|
}
|
||||||
else if (startParameters.ServerType == ServerType.Helios)
|
else if (startParameters.ServerType == ServerType.IISExpress)
|
||||||
{
|
{
|
||||||
hostProcess = StartHeliosHost(startParameters);
|
hostProcess = StartHeliosHost(startParameters);
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +316,9 @@ namespace E2ETests
|
||||||
hostProcess.WaitForExit(60 * 1000);
|
hostProcess.WaitForExit(60 * 1000);
|
||||||
|
|
||||||
startParameters.ApplicationPath =
|
startParameters.ApplicationPath =
|
||||||
(startParameters.ServerType == ServerType.Helios || startParameters.ServerType == ServerType.IISNativeModule) ?
|
(startParameters.ServerType == ServerType.IISExpress ||
|
||||||
|
startParameters.ServerType == ServerType.IISNativeModule ||
|
||||||
|
startParameters.ServerType == ServerType.IIS) ?
|
||||||
Path.Combine(startParameters.PackedApplicationRootPath, "wwwroot") :
|
Path.Combine(startParameters.PackedApplicationRootPath, "wwwroot") :
|
||||||
Path.Combine(startParameters.PackedApplicationRootPath, "approot", "src", "MusicStore");
|
Path.Combine(startParameters.PackedApplicationRootPath, "approot", "src", "MusicStore");
|
||||||
|
|
||||||
|
|
@ -363,7 +371,8 @@ namespace E2ETests
|
||||||
|
|
||||||
public static void CleanUpApplication(StartParameters startParameters, Process hostProcess, string musicStoreDbName)
|
public static void CleanUpApplication(StartParameters startParameters, Process hostProcess, string musicStoreDbName)
|
||||||
{
|
{
|
||||||
if (startParameters.ServerType == ServerType.IISNativeModule)
|
if (startParameters.ServerType == ServerType.IISNativeModule ||
|
||||||
|
startParameters.ServerType == ServerType.IIS)
|
||||||
{
|
{
|
||||||
// Stop & delete the application pool.
|
// Stop & delete the application pool.
|
||||||
if (startParameters.IISApplication != null)
|
if (startParameters.IISApplication != null)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,11 @@ namespace E2ETests
|
||||||
private ApplicationPool CreateAppPool(string appPoolName)
|
private ApplicationPool CreateAppPool(string appPoolName)
|
||||||
{
|
{
|
||||||
var applicationPool = _serverManager.ApplicationPools.Add(appPoolName);
|
var applicationPool = _serverManager.ApplicationPools.Add(appPoolName);
|
||||||
applicationPool.ManagedRuntimeVersion = NATIVE_MODULE_MANAGED_RUNTIME_VERSION;
|
if (_startParameters.ServerType == ServerType.IISNativeModule)
|
||||||
|
{
|
||||||
|
// Not assigning a runtime version will choose v4.0 default.
|
||||||
|
applicationPool.ManagedRuntimeVersion = NATIVE_MODULE_MANAGED_RUNTIME_VERSION;
|
||||||
|
}
|
||||||
applicationPool.Enable32BitAppOnWin64 = (_startParameters.KreArchitecture == KreArchitecture.x86);
|
applicationPool.Enable32BitAppOnWin64 = (_startParameters.KreArchitecture == KreArchitecture.x86);
|
||||||
return applicationPool;
|
return applicationPool;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
{
|
{
|
||||||
public enum ServerType
|
public enum ServerType
|
||||||
{
|
{
|
||||||
Helios,
|
IISExpress,
|
||||||
|
IIS,
|
||||||
IISNativeModule,
|
IISNativeModule,
|
||||||
WebListener,
|
WebListener,
|
||||||
Kestrel
|
Kestrel
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
private void LoginWithFacebook()
|
private void LoginWithFacebook()
|
||||||
{
|
{
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
var response = httpClient.GetAsync("Account/Login").Result;
|
var response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Signing in with Facebook account");
|
Console.WriteLine("Signing in with Facebook account");
|
||||||
|
|
@ -26,23 +26,23 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://www.facebook.com/v2.2/dialog/oauth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://www.facebook.com/v2.2/dialog/oauth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
||||||
Assert.Equal<string>("code", queryItems["response_type"]);
|
Assert.Equal<string>("code", queryItems["response_type"]);
|
||||||
Assert.Equal<string>("[AppId]", queryItems["client_id"]);
|
Assert.Equal<string>("[AppId]", queryItems["client_id"]);
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + "signin-facebook", queryItems["redirect_uri"]);
|
Assert.Equal<string>(_applicationBaseUrl + "signin-facebook", queryItems["redirect_uri"]);
|
||||||
Assert.Equal<string>("email,read_friendlists,user_checkins", queryItems["scope"]);
|
Assert.Equal<string>("email,read_friendlists,user_checkins", queryItems["scope"]);
|
||||||
Assert.Equal<string>("ValidStateData", queryItems["state"]);
|
Assert.Equal<string>("ValidStateData", queryItems["state"]);
|
||||||
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
||||||
//Check for the correlation cookie
|
//Check for the correlation cookie
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Facebook"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Facebook"));
|
||||||
|
|
||||||
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
response = httpClient.GetAsync("Account/Login").Result;
|
response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
|
|
@ -52,19 +52,19 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
|
|
||||||
//Post a message to the Facebook middleware
|
//Post a message to the Facebook middleware
|
||||||
response = httpClient.GetAsync("signin-facebook?code=ValidCode&state=ValidStateData").Result;
|
response = _httpClient.GetAsync("signin-facebook?code=ValidCode&state=ValidStateData").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
//Correlation cookie not getting cleared after successful signin?
|
//Correlation cookie not getting cleared after successful signin?
|
||||||
if (!Helpers.RunningOnMono)
|
if (!Helpers.RunningOnMono)
|
||||||
{
|
{
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Facebook"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Facebook"));
|
||||||
}
|
}
|
||||||
Assert.Equal(ApplicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal(_applicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
Assert.Contains("AspnetvnextTest@test.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("AspnetvnextTest@test.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
|
|
@ -74,20 +74,20 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie sent
|
//Verify cookie sent
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
||||||
Console.WriteLine("Successfully signed in with user '{0}'", "AspnetvnextTest@test.com");
|
Console.WriteLine("Successfully signed in with user '{0}'", "AspnetvnextTest@test.com");
|
||||||
|
|
||||||
Console.WriteLine("Verifying if the middleware notifications were fired");
|
Console.WriteLine("Verifying if the middleware notifications were fired");
|
||||||
//Check for a non existing item
|
//Check for a non existing item
|
||||||
response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
||||||
//This action requires admin permissions. If notifications are fired this permission is granted
|
//This action requires admin permissions. If notifications are fired this permission is granted
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
Console.WriteLine("Middleware notifications were fired successfully");
|
Console.WriteLine("Middleware notifications were fired successfully");
|
||||||
|
|
@ -11,10 +11,10 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
private void LoginWithGoogle()
|
private void LoginWithGoogle()
|
||||||
{
|
{
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
var response = httpClient.GetAsync("Account/Login").Result;
|
var response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Signing in with Google account");
|
Console.WriteLine("Signing in with Google account");
|
||||||
|
|
@ -26,24 +26,24 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://accounts.google.com/o/oauth2/auth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://accounts.google.com/o/oauth2/auth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
||||||
Assert.Equal<string>("code", queryItems["response_type"]);
|
Assert.Equal<string>("code", queryItems["response_type"]);
|
||||||
Assert.Equal<string>("offline", queryItems["access_type"]);
|
Assert.Equal<string>("offline", queryItems["access_type"]);
|
||||||
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + "signin-google", queryItems["redirect_uri"]);
|
Assert.Equal<string>(_applicationBaseUrl + "signin-google", queryItems["redirect_uri"]);
|
||||||
Assert.Equal<string>("openid profile email", queryItems["scope"]);
|
Assert.Equal<string>("openid profile email", queryItems["scope"]);
|
||||||
Assert.Equal<string>("ValidStateData", queryItems["state"]);
|
Assert.Equal<string>("ValidStateData", queryItems["state"]);
|
||||||
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
||||||
//Check for the correlation cookie
|
//Check for the correlation cookie
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Google"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Google"));
|
||||||
|
|
||||||
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
response = httpClient.GetAsync("Account/Login").Result;
|
response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
|
|
@ -53,19 +53,19 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
|
|
||||||
//Post a message to the Google middleware
|
//Post a message to the Google middleware
|
||||||
response = httpClient.GetAsync("signin-google?code=ValidCode&state=ValidStateData").Result;
|
response = _httpClient.GetAsync("signin-google?code=ValidCode&state=ValidStateData").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
//Correlation cookie not getting cleared after successful signin?
|
//Correlation cookie not getting cleared after successful signin?
|
||||||
if (!Helpers.RunningOnMono)
|
if (!Helpers.RunningOnMono)
|
||||||
{
|
{
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Google"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Google"));
|
||||||
}
|
}
|
||||||
Assert.Equal(ApplicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal(_applicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
Assert.Contains("AspnetvnextTest@gmail.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("AspnetvnextTest@gmail.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
|
|
@ -75,20 +75,20 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@gmail.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@gmail.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie sent
|
//Verify cookie sent
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
||||||
Console.WriteLine("Successfully signed in with user '{0}'", "AspnetvnextTest@gmail.com");
|
Console.WriteLine("Successfully signed in with user '{0}'", "AspnetvnextTest@gmail.com");
|
||||||
|
|
||||||
Console.WriteLine("Verifying if the middleware notifications were fired");
|
Console.WriteLine("Verifying if the middleware notifications were fired");
|
||||||
//Check for a non existing item
|
//Check for a non existing item
|
||||||
response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
||||||
//This action requires admin permissions. If notifications are fired this permission is granted
|
//This action requires admin permissions. If notifications are fired this permission is granted
|
||||||
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
|
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
|
@ -11,10 +11,10 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
private void LoginWithMicrosoftAccount()
|
private void LoginWithMicrosoftAccount()
|
||||||
{
|
{
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
var response = httpClient.GetAsync("Account/Login").Result;
|
var response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Signing in with Microsoft account");
|
Console.WriteLine("Signing in with Microsoft account");
|
||||||
|
|
@ -26,24 +26,24 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://login.live.com/oauth20_authorize.srf", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://login.live.com/oauth20_authorize.srf", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
||||||
Assert.Equal<string>("code", queryItems["response_type"]);
|
Assert.Equal<string>("code", queryItems["response_type"]);
|
||||||
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + "signin-microsoft", queryItems["redirect_uri"]);
|
Assert.Equal<string>(_applicationBaseUrl + "signin-microsoft", queryItems["redirect_uri"]);
|
||||||
Assert.Equal<string>("wl.basic wl.signin", queryItems["scope"]);
|
Assert.Equal<string>("wl.basic wl.signin", queryItems["scope"]);
|
||||||
Assert.Equal<string>("ValidStateData", queryItems["state"]);
|
Assert.Equal<string>("ValidStateData", queryItems["state"]);
|
||||||
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
||||||
|
|
||||||
//Check for the correlation cookie
|
//Check for the correlation cookie
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Microsoft"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Microsoft"));
|
||||||
|
|
||||||
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
response = httpClient.GetAsync("Account/Login").Result;
|
response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
|
|
@ -53,19 +53,19 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
|
|
||||||
//Post a message to the MicrosoftAccount middleware
|
//Post a message to the MicrosoftAccount middleware
|
||||||
response = httpClient.GetAsync("signin-microsoft?code=ValidCode&state=ValidStateData").Result;
|
response = _httpClient.GetAsync("signin-microsoft?code=ValidCode&state=ValidStateData").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
//Correlation cookie not getting cleared after successful signin?
|
//Correlation cookie not getting cleared after successful signin?
|
||||||
if (!Helpers.RunningOnMono)
|
if (!Helpers.RunningOnMono)
|
||||||
{
|
{
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Microsoft"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Correlation.Microsoft"));
|
||||||
}
|
}
|
||||||
Assert.Equal(ApplicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal(_applicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
|
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
|
|
@ -74,20 +74,20 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
Assert.Contains(string.Format("Hello {0}!", "microsoft@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(string.Format("Hello {0}!", "microsoft@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie sent
|
//Verify cookie sent
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
||||||
Console.WriteLine("Successfully signed in with user '{0}'", "microsoft@test.com");
|
Console.WriteLine("Successfully signed in with user '{0}'", "microsoft@test.com");
|
||||||
|
|
||||||
Console.WriteLine("Verifying if the middleware notifications were fired");
|
Console.WriteLine("Verifying if the middleware notifications were fired");
|
||||||
//Check for a non existing item
|
//Check for a non existing item
|
||||||
response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
||||||
//This action requires admin permissions. If notifications are fired this permission is granted
|
//This action requires admin permissions. If notifications are fired this permission is granted
|
||||||
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
|
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
|
@ -14,20 +14,20 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
Console.WriteLine("Validating if static contents are served..");
|
Console.WriteLine("Validating if static contents are served..");
|
||||||
Console.WriteLine("Fetching favicon.ico..");
|
Console.WriteLine("Fetching favicon.ico..");
|
||||||
var response = httpClient.GetAsync("favicon.ico").Result;
|
var response = _httpClient.GetAsync("favicon.ico").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
Console.WriteLine("Etag received: {0}", response.Headers.ETag.Tag);
|
Console.WriteLine("Etag received: {0}", response.Headers.ETag.Tag);
|
||||||
|
|
||||||
//Check if you receive a NotModified on sending an etag
|
//Check if you receive a NotModified on sending an etag
|
||||||
Console.WriteLine("Sending an IfNoneMatch header with e-tag");
|
Console.WriteLine("Sending an IfNoneMatch header with e-tag");
|
||||||
httpClient.DefaultRequestHeaders.IfNoneMatch.Add(response.Headers.ETag);
|
_httpClient.DefaultRequestHeaders.IfNoneMatch.Add(response.Headers.ETag);
|
||||||
response = httpClient.GetAsync("favicon.ico").Result;
|
response = _httpClient.GetAsync("favicon.ico").Result;
|
||||||
Assert.Equal(HttpStatusCode.NotModified, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotModified, response.StatusCode);
|
||||||
httpClient.DefaultRequestHeaders.IfNoneMatch.Clear();
|
_httpClient.DefaultRequestHeaders.IfNoneMatch.Clear();
|
||||||
Console.WriteLine("Successfully received a NotModified status");
|
Console.WriteLine("Successfully received a NotModified status");
|
||||||
|
|
||||||
Console.WriteLine("Fetching /Content/bootstrap.css..");
|
Console.WriteLine("Fetching /Content/bootstrap.css..");
|
||||||
response = httpClient.GetAsync("Content/bootstrap.css").Result;
|
response = _httpClient.GetAsync("Content/bootstrap.css").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
Console.WriteLine("Verified static contents are served successfully");
|
Console.WriteLine("Verified static contents are served successfully");
|
||||||
}
|
}
|
||||||
|
|
@ -54,8 +54,9 @@ namespace E2ETests
|
||||||
|
|
||||||
private string PrefixBaseAddress(string url)
|
private string PrefixBaseAddress(string url)
|
||||||
{
|
{
|
||||||
url = startParameters.ServerType == ServerType.IISNativeModule ?
|
url = (_startParameters.ServerType == ServerType.IISNativeModule ||
|
||||||
string.Format(url, startParameters.IISApplication.VirtualDirectoryName) :
|
_startParameters.ServerType == ServerType.IIS) ?
|
||||||
|
string.Format(url, _startParameters.IISApplication.VirtualDirectoryName) :
|
||||||
string.Format(url, string.Empty);
|
string.Format(url, string.Empty);
|
||||||
|
|
||||||
return url.Replace("//", "/").Replace("%2F%2F", "%2F").Replace("%2F/", "%2F");
|
return url.Replace("//", "/").Replace("%2F%2F", "%2F").Replace("%2F/", "%2F");
|
||||||
|
|
@ -73,13 +74,13 @@ namespace E2ETests
|
||||||
private void AccessStoreWithoutPermissions(string email = null)
|
private void AccessStoreWithoutPermissions(string email = null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Trying to access StoreManager that needs ManageStore claim with the current user : {0}", email ?? "Anonymous");
|
Console.WriteLine("Trying to access StoreManager that needs ManageStore claim with the current user : {0}", email ?? "Anonymous");
|
||||||
var response = httpClient.GetAsync("Admin/StoreManager/").Result;
|
var response = _httpClient.GetAsync("Admin/StoreManager/").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
ValidateLayoutPage(responseContent);
|
ValidateLayoutPage(responseContent);
|
||||||
Assert.Contains("<title>Log in – MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
|
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.Contains("<h4>Use a local account to log in.</h4>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + PrefixBaseAddress("Account/Login?ReturnUrl=%2F{0}%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.");
|
Console.WriteLine("Redirected to login page as expected.");
|
||||||
}
|
}
|
||||||
|
|
@ -87,17 +88,17 @@ namespace E2ETests
|
||||||
private void AccessStoreWithPermissions()
|
private void AccessStoreWithPermissions()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Trying to access the store inventory..");
|
Console.WriteLine("Trying to access the store inventory..");
|
||||||
var response = httpClient.GetAsync("Admin/StoreManager/").Result;
|
var response = _httpClient.GetAsync("Admin/StoreManager/").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + "Admin/StoreManager/", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal<string>(_applicationBaseUrl + "Admin/StoreManager/", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
Console.WriteLine("Successfully acccessed the store inventory");
|
Console.WriteLine("Successfully acccessed the store inventory");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterUserWithNonMatchingPasswords()
|
private void RegisterUserWithNonMatchingPasswords()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Trying to create user with not matching password and confirm password");
|
Console.WriteLine("Trying to create user with not matching password and confirm password");
|
||||||
var response = httpClient.GetAsync("Account/Register").Result;
|
var response = _httpClient.GetAsync("Account/Register").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
ValidateLayoutPage(responseContent);
|
ValidateLayoutPage(responseContent);
|
||||||
|
|
@ -113,16 +114,16 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/Register", content).Result;
|
response = _httpClient.PostAsync("Account/Register", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Assert.Contains("<div class=\"validation-summary-errors text-danger\" data-valmsg-summary=\"true\"><ul><li>The password and confirmation password do not match.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("<div class=\"validation-summary-errors text-danger\" data-valmsg-summary=\"true\"><ul><li>The password and confirmation password do not match.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Console.WriteLine("Server side model validator rejected the user '{0}''s registration as passwords do not match.", generatedEmail);
|
Console.WriteLine("Server side model validator rejected the user '{0}''s registration as passwords do not match.", generatedEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string RegisterValidUser()
|
private string RegisterValidUser()
|
||||||
{
|
{
|
||||||
var response = httpClient.GetAsync("Account/Register").Result;
|
var response = _httpClient.GetAsync("Account/Register").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
ValidateLayoutPage(responseContent);
|
ValidateLayoutPage(responseContent);
|
||||||
|
|
@ -138,17 +139,17 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/Register", content).Result;
|
response = _httpClient.PostAsync("Account/Register", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
//Account verification
|
//Account verification
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + "Account/Register", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal<string>(_applicationBaseUrl + "Account/Register", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
Assert.Contains("For DEMO only: You can click this link to confirm the email:", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("For DEMO only: You can click this link to confirm the email:", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
var startIndex = responseContent.IndexOf("[[<a href=\"", 0) + "[[<a href=\"".Length;
|
var startIndex = responseContent.IndexOf("[[<a href=\"", 0) + "[[<a href=\"".Length;
|
||||||
var endIndex = responseContent.IndexOf("\">link</a>]]", startIndex);
|
var endIndex = responseContent.IndexOf("\">link</a>]]", startIndex);
|
||||||
var confirmUrl = responseContent.Substring(startIndex, endIndex - startIndex);
|
var confirmUrl = responseContent.Substring(startIndex, endIndex - startIndex);
|
||||||
confirmUrl = WebUtility.HtmlDecode(confirmUrl);
|
confirmUrl = WebUtility.HtmlDecode(confirmUrl);
|
||||||
response = httpClient.GetAsync(confirmUrl).Result;
|
response = _httpClient.GetAsync(confirmUrl).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains("Thank you for confirming your email.", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Thank you for confirming your email.", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
@ -158,7 +159,7 @@ namespace E2ETests
|
||||||
private void RegisterExistingUser(string email)
|
private void RegisterExistingUser(string email)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Trying to register a user with name '{0}' again", email);
|
Console.WriteLine("Trying to register a user with name '{0}' again", email);
|
||||||
var response = httpClient.GetAsync("Account/Register").Result;
|
var response = _httpClient.GetAsync("Account/Register").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Creating a new user with name '{0}'", email);
|
Console.WriteLine("Creating a new user with name '{0}'", email);
|
||||||
|
|
@ -171,7 +172,7 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/Register", content).Result;
|
response = _httpClient.PostAsync("Account/Register", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains(string.Format("Name {0} is already taken.", email), responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(string.Format("Name {0} is already taken.", email), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Console.WriteLine("Identity threw a valid exception that user '{0}' already exists in the system", email);
|
Console.WriteLine("Identity threw a valid exception that user '{0}' already exists in the system", email);
|
||||||
|
|
@ -180,7 +181,7 @@ namespace E2ETests
|
||||||
private void SignOutUser(string email)
|
private void SignOutUser(string email)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Signing out from '{0}''s session", email);
|
Console.WriteLine("Signing out from '{0}''s session", email);
|
||||||
var response = httpClient.GetAsync(string.Empty).Result;
|
var response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
ValidateLayoutPage(responseContent);
|
ValidateLayoutPage(responseContent);
|
||||||
|
|
@ -190,7 +191,7 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/LogOff", content).Result;
|
response = _httpClient.PostAsync("Account/LogOff", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
if (!Helpers.RunningOnMono)
|
if (!Helpers.RunningOnMono)
|
||||||
|
|
@ -201,20 +202,20 @@ namespace E2ETests
|
||||||
Assert.Contains("mvcmusicstore.codeplex.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("mvcmusicstore.codeplex.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Contains("/Images/home-showcase.png", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("/Images/home-showcase.png", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie cleared on logout
|
//Verify cookie cleared on logout
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Console.WriteLine("Successfully signed out of '{0}''s session", email);
|
Console.WriteLine("Successfully signed out of '{0}''s session", email);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Bug in Mono - on logout the cookie is not cleared in the cookie container and not redirected. Work around by reinstantiating the httpClient.
|
//Bug in Mono - on logout the cookie is not cleared in the cookie container and not redirected. Work around by reinstantiating the httpClient.
|
||||||
httpClientHandler = new HttpClientHandler();
|
_httpClientHandler = new HttpClientHandler();
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SignInWithInvalidPassword(string email, string invalidPassword)
|
private void SignInWithInvalidPassword(string email, string invalidPassword)
|
||||||
{
|
{
|
||||||
var response = httpClient.GetAsync("Account/Login").Result;
|
var response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Signing in with user '{0}'", email);
|
Console.WriteLine("Signing in with user '{0}'", email);
|
||||||
|
|
@ -226,17 +227,17 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/Login", content).Result;
|
response = _httpClient.PostAsync("Account/Login", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains("<div class=\"validation-summary-errors text-danger\"><ul><li>Invalid login attempt.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("<div class=\"validation-summary-errors text-danger\"><ul><li>Invalid login attempt.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie not sent
|
//Verify cookie not sent
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Console.WriteLine("Identity successfully prevented an invalid user login.");
|
Console.WriteLine("Identity successfully prevented an invalid user login.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SignInWithUser(string email, string password)
|
private void SignInWithUser(string email, string password)
|
||||||
{
|
{
|
||||||
var response = httpClient.GetAsync("Account/Login").Result;
|
var response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Signing in with user '{0}'", email);
|
Console.WriteLine("Signing in with user '{0}'", email);
|
||||||
|
|
@ -248,18 +249,18 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/Login", content).Result;
|
response = _httpClient.PostAsync("Account/Login", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains(string.Format("Hello {0}!", email), responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(string.Format("Hello {0}!", email), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie sent
|
//Verify cookie sent
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Console.WriteLine("Successfully signed in with user '{0}'", email);
|
Console.WriteLine("Successfully signed in with user '{0}'", email);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangePassword(string email)
|
private void ChangePassword(string email)
|
||||||
{
|
{
|
||||||
var response = httpClient.GetAsync("Manage/ChangePassword").Result;
|
var response = _httpClient.GetAsync("Manage/ChangePassword").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
var formParameters = new List<KeyValuePair<string, string>>
|
var formParameters = new List<KeyValuePair<string, string>>
|
||||||
|
|
@ -271,10 +272,10 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Manage/ChangePassword", content).Result;
|
response = _httpClient.PostAsync("Manage/ChangePassword", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains("Your password has been changed.", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Your password has been changed.", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Console.WriteLine("Successfully changed the password for user '{0}'", email);
|
Console.WriteLine("Successfully changed the password for user '{0}'", email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,7 +284,7 @@ namespace E2ETests
|
||||||
var albumName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12);
|
var albumName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12);
|
||||||
string dataFromHub = null;
|
string dataFromHub = null;
|
||||||
var OnReceivedEvent = new AutoResetEvent(false);
|
var OnReceivedEvent = new AutoResetEvent(false);
|
||||||
var hubConnection = new HubConnection(ApplicationBaseUrl + "SignalR");
|
var hubConnection = new HubConnection(_applicationBaseUrl + "SignalR");
|
||||||
hubConnection.Received += (data) =>
|
hubConnection.Received += (data) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("Data received by SignalR client: {0}", data);
|
Console.WriteLine("Data received by SignalR client: {0}", data);
|
||||||
|
|
@ -295,7 +296,7 @@ namespace E2ETests
|
||||||
hubConnection.Start().Wait();
|
hubConnection.Start().Wait();
|
||||||
|
|
||||||
Console.WriteLine("Trying to create an album with name '{0}'", albumName);
|
Console.WriteLine("Trying to create an album with name '{0}'", albumName);
|
||||||
var response = httpClient.GetAsync("Admin/StoreManager/create").Result;
|
var response = _httpClient.GetAsync("Admin/StoreManager/create").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
var formParameters = new List<KeyValuePair<string, string>>
|
var formParameters = new List<KeyValuePair<string, string>>
|
||||||
|
|
@ -309,9 +310,9 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Admin/StoreManager/create", content).Result;
|
response = _httpClient.PostAsync("Admin/StoreManager/create", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Equal<string>(ApplicationBaseUrl + "Admin/StoreManager", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal<string>(_applicationBaseUrl + "Admin/StoreManager", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
|
|
||||||
Assert.Contains(albumName, responseContent);
|
Assert.Contains(albumName, responseContent);
|
||||||
Console.WriteLine("Waiting for the SignalR client to receive album created announcement");
|
Console.WriteLine("Waiting for the SignalR client to receive album created announcement");
|
||||||
|
|
@ -325,7 +326,7 @@ namespace E2ETests
|
||||||
private string FetchAlbumIdFromName(string albumName)
|
private string FetchAlbumIdFromName(string albumName)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Fetching the album id of '{0}'", albumName);
|
Console.WriteLine("Fetching the album id of '{0}'", albumName);
|
||||||
var response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result;
|
var response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var albumId = response.Content.ReadAsStringAsync().Result;
|
var albumId = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Album id for album '{0}' is '{1}'", albumName, albumId);
|
Console.WriteLine("Album id for album '{0}' is '{1}'", albumName, albumId);
|
||||||
|
|
@ -335,7 +336,7 @@ namespace E2ETests
|
||||||
private void VerifyAlbumDetails(string albumId, string albumName)
|
private void VerifyAlbumDetails(string albumId, string albumName)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Getting details of album with Id '{0}'", albumId);
|
Console.WriteLine("Getting details of album with Id '{0}'", albumId);
|
||||||
var response = httpClient.GetAsync(string.Format("Admin/StoreManager/Details?id={0}", albumId)).Result;
|
var response = _httpClient.GetAsync(string.Format("Admin/StoreManager/Details?id={0}", albumId)).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
@ -348,7 +349,7 @@ namespace E2ETests
|
||||||
private void GetAlbumDetailsFromStore(string albumId, string albumName)
|
private void GetAlbumDetailsFromStore(string albumId, string albumName)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Getting details of album with Id '{0}'", albumId);
|
Console.WriteLine("Getting details of album with Id '{0}'", albumId);
|
||||||
var response = httpClient.GetAsync(string.Format("Store/Details/{0}", albumId)).Result;
|
var response = _httpClient.GetAsync(string.Format("Store/Details/{0}", albumId)).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
@ -357,7 +358,7 @@ namespace E2ETests
|
||||||
private void AddAlbumToCart(string albumId, string albumName)
|
private void AddAlbumToCart(string albumId, string albumName)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Adding album id '{0}' to the cart", albumId);
|
Console.WriteLine("Adding album id '{0}' to the cart", albumId);
|
||||||
var response = httpClient.GetAsync(string.Format("ShoppingCart/AddToCart?id={0}", albumId)).Result;
|
var response = _httpClient.GetAsync(string.Format("ShoppingCart/AddToCart?id={0}", albumId)).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
@ -368,7 +369,7 @@ namespace E2ETests
|
||||||
private void CheckOutCartItems()
|
private void CheckOutCartItems()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Checking out the cart contents...");
|
Console.WriteLine("Checking out the cart contents...");
|
||||||
var response = httpClient.GetAsync("Checkout/AddressAndPayment").Result;
|
var response = _httpClient.GetAsync("Checkout/AddressAndPayment").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
|
|
@ -388,10 +389,10 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Checkout/AddressAndPayment", content).Result;
|
response = _httpClient.PostAsync("Checkout/AddressAndPayment", content).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Assert.Contains("<h2>Checkout Complete</h2>", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("<h2>Checkout Complete</h2>", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.StartsWith(ApplicationBaseUrl + "Checkout/Complete/", response.RequestMessage.RequestUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
|
Assert.StartsWith(_applicationBaseUrl + "Checkout/Complete/", response.RequestMessage.RequestUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteAlbum(string albumId, string albumName)
|
private void DeleteAlbum(string albumId, string albumName)
|
||||||
|
|
@ -404,11 +405,11 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
var response = httpClient.PostAsync("Admin/StoreManager/RemoveAlbum", content).Result;
|
var response = _httpClient.PostAsync("Admin/StoreManager/RemoveAlbum", content).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
|
|
||||||
Console.WriteLine("Verifying if the album '{0}' is deleted from store", albumName);
|
Console.WriteLine("Verifying if the album '{0}' is deleted from store", albumName);
|
||||||
response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result;
|
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);
|
Console.WriteLine("Album is successfully deleted from the store.", albumName, albumId);
|
||||||
}
|
}
|
||||||
|
|
@ -14,10 +14,10 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
private void LoginWithTwitter()
|
private void LoginWithTwitter()
|
||||||
{
|
{
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
var response = httpClient.GetAsync("Account/Login").Result;
|
var response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
Console.WriteLine("Signing in with Twitter account");
|
Console.WriteLine("Signing in with Twitter account");
|
||||||
|
|
@ -29,19 +29,19 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://twitter.com/oauth/authenticate", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://twitter.com/oauth/authenticate", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
||||||
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
||||||
Assert.Equal<string>("valid_oauth_token", queryItems["oauth_token"]);
|
Assert.Equal<string>("valid_oauth_token", queryItems["oauth_token"]);
|
||||||
//Check for the correlation cookie
|
//Check for the correlation cookie
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl))["__TwitterState"]);
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl))["__TwitterState"]);
|
||||||
|
|
||||||
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
//This is just to generate a correlation cookie. Previous step would generate this cookie, but we have reset the handler now.
|
||||||
httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
_httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
response = httpClient.GetAsync("Account/Login").Result;
|
response = _httpClient.GetAsync("Account/Login").Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
formParameters = new List<KeyValuePair<string, string>>
|
formParameters = new List<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
|
|
@ -51,19 +51,19 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
|
|
||||||
//Post a message to the Facebook middleware
|
//Post a message to the Facebook middleware
|
||||||
response = httpClient.GetAsync("signin-twitter?oauth_token=valid_oauth_token&oauth_verifier=valid_oauth_verifier").Result;
|
response = _httpClient.GetAsync("signin-twitter?oauth_token=valid_oauth_token&oauth_verifier=valid_oauth_verifier").Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
//Check correlation cookie not getting cleared after successful signin
|
//Check correlation cookie not getting cleared after successful signin
|
||||||
if (!Helpers.RunningOnMono)
|
if (!Helpers.RunningOnMono)
|
||||||
{
|
{
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl))["__TwitterState"]);
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl))["__TwitterState"]);
|
||||||
}
|
}
|
||||||
Assert.Equal(ApplicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
Assert.Equal(_applicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||||
//Twitter does not give back the email claim for some reason.
|
//Twitter does not give back the email claim for some reason.
|
||||||
//Assert.Contains("AspnetvnextTest@gmail.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
//Assert.Contains("AspnetvnextTest@gmail.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
|
@ -74,20 +74,20 @@ namespace E2ETests
|
||||||
};
|
};
|
||||||
|
|
||||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||||
ThrowIfResponseStatusNotOk(response);
|
ThrowIfResponseStatusNotOk(response);
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
|
|
||||||
Assert.Contains(string.Format("Hello {0}!", "twitter@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains(string.Format("Hello {0}!", "twitter@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||||
//Verify cookie sent
|
//Verify cookie sent
|
||||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||||
Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
||||||
Console.WriteLine("Successfully signed in with user '{0}'", "twitter@test.com");
|
Console.WriteLine("Successfully signed in with user '{0}'", "twitter@test.com");
|
||||||
|
|
||||||
Console.WriteLine("Verifying if the middleware notifications were fired");
|
Console.WriteLine("Verifying if the middleware notifications were fired");
|
||||||
//Check for a non existing item
|
//Check for a non existing item
|
||||||
response = httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result;
|
||||||
//This action requires admin permissions. If notifications are fired this permission is granted
|
//This action requires admin permissions. If notifications are fired this permission is granted
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
Console.WriteLine("Middleware notifications were fired successfully");
|
Console.WriteLine("Middleware notifications were fired successfully");
|
||||||
|
|
@ -11,44 +11,44 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[OSSkipCondition(OperatingSystems.Unix | OperatingSystems.MacOSX)]
|
[OSSkipCondition(OperatingSystems.Unix | OperatingSystems.MacOSX)]
|
||||||
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")]
|
[InlineData(ServerType.IISExpress, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")]
|
||||||
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5001/")]
|
[InlineData(ServerType.IISExpress, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5001/")]
|
||||||
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5002/")]
|
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5002/")]
|
||||||
public void NtlmAuthenticationTest(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
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);
|
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
|
||||||
|
|
||||||
startParameters = new StartParameters
|
_startParameters = new StartParameters
|
||||||
{
|
{
|
||||||
ServerType = serverType,
|
ServerType = serverType,
|
||||||
KreFlavor = kreFlavor,
|
KreFlavor = kreFlavor,
|
||||||
KreArchitecture = architecture,
|
KreArchitecture = architecture,
|
||||||
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
|
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
|
||||||
ApplicationHostConfigTemplateContent = (serverType == ServerType.Helios) ? File.ReadAllText("NtlmAuthentation.config") : null,
|
ApplicationHostConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null,
|
||||||
SiteName = "MusicStoreNtlmAuthentication" //This is configured in the NtlmAuthentication.config
|
SiteName = "MusicStoreNtlmAuthentication" //This is configured in the NtlmAuthentication.config
|
||||||
};
|
};
|
||||||
|
|
||||||
var testStartTime = DateTime.Now;
|
var testStartTime = DateTime.Now;
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
Console.WriteLine("Pointing MusicStore DB to '{0}'", string.Format(Connection_string_Format, musicStoreDbName));
|
Console.WriteLine("Pointing MusicStore DB to '{0}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
||||||
//Override the connection strings using environment based configuration
|
//Override the connection strings using environment based configuration
|
||||||
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(Connection_string_Format, musicStoreDbName));
|
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
||||||
ApplicationBaseUrl = applicationBaseUrl;
|
_applicationBaseUrl = applicationBaseUrl;
|
||||||
Process hostProcess = null;
|
Process hostProcess = null;
|
||||||
bool testSuccessful = false;
|
bool testSuccessful = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hostProcess = DeploymentUtility.StartApplication(startParameters, musicStoreDbName);
|
hostProcess = DeploymentUtility.StartApplication(_startParameters, musicStoreDbName);
|
||||||
|
|
||||||
httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
_httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(applicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(applicationBaseUrl) };
|
||||||
|
|
||||||
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
var response = httpClient.GetAsync(string.Empty).Result;
|
var response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
var responseContent = response.Content.ReadAsStringAsync().Result;
|
var responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
var initializationCompleteTime = DateTime.Now;
|
var initializationCompleteTime = DateTime.Now;
|
||||||
Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds);
|
Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds);
|
||||||
|
|
@ -72,7 +72,7 @@ namespace E2ETests
|
||||||
Console.WriteLine("Some tests failed. Proceeding with cleanup.");
|
Console.WriteLine("Some tests failed. Proceeding with cleanup.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DeploymentUtility.CleanUpApplication(startParameters, hostProcess, musicStoreDbName);
|
DeploymentUtility.CleanUpApplication(_startParameters, hostProcess, musicStoreDbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||||
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")]
|
[InlineData(ServerType.IISExpress, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")]
|
||||||
public void Publish_And_Run_Tests_On_X86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
public void Publish_And_Run_Tests_On_X86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
||||||
{
|
{
|
||||||
Publish_And_Run_Tests(serverType, kreFlavor, architecture, applicationBaseUrl);
|
Publish_And_Run_Tests(serverType, kreFlavor, architecture, applicationBaseUrl);
|
||||||
|
|
@ -41,7 +41,7 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
|
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
|
||||||
|
|
||||||
startParameters = new StartParameters
|
_startParameters = new StartParameters
|
||||||
{
|
{
|
||||||
ServerType = serverType,
|
ServerType = serverType,
|
||||||
KreFlavor = kreFlavor,
|
KreFlavor = kreFlavor,
|
||||||
|
|
@ -52,21 +52,21 @@ namespace E2ETests
|
||||||
var testStartTime = DateTime.Now;
|
var testStartTime = DateTime.Now;
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
Console.WriteLine("Pointing MusicStore DB to '{0}'", string.Format(Connection_string_Format, musicStoreDbName));
|
Console.WriteLine("Pointing MusicStore DB to '{0}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
||||||
//Override the connection strings using environment based configuration
|
//Override the connection strings using environment based configuration
|
||||||
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(Connection_string_Format, musicStoreDbName));
|
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
||||||
ApplicationBaseUrl = applicationBaseUrl;
|
_applicationBaseUrl = applicationBaseUrl;
|
||||||
Process hostProcess = null;
|
Process hostProcess = null;
|
||||||
bool testSuccessful = false;
|
bool testSuccessful = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hostProcess = DeploymentUtility.StartApplication(startParameters, musicStoreDbName);
|
hostProcess = DeploymentUtility.StartApplication(_startParameters, musicStoreDbName);
|
||||||
|
|
||||||
httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
_httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(applicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(applicationBaseUrl) };
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
string responseContent = null;
|
string responseContent = null;
|
||||||
|
|
@ -78,7 +78,7 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = httpClient.GetAsync(string.Empty).Result;
|
response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
initializationCompleteTime = DateTime.Now;
|
initializationCompleteTime = DateTime.Now;
|
||||||
Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds);
|
Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds);
|
||||||
|
|
@ -101,9 +101,9 @@ namespace E2ETests
|
||||||
//Static files are served?
|
//Static files are served?
|
||||||
VerifyStaticContentServed();
|
VerifyStaticContentServed();
|
||||||
|
|
||||||
if (serverType != ServerType.Helios)
|
if (serverType != ServerType.IISExpress)
|
||||||
{
|
{
|
||||||
if (Directory.GetFiles(startParameters.ApplicationPath, "*.cmd", SearchOption.TopDirectoryOnly).Length > 0)
|
if (Directory.GetFiles(_startParameters.ApplicationPath, "*.cmd", SearchOption.TopDirectoryOnly).Length > 0)
|
||||||
{
|
{
|
||||||
throw new Exception("packExclude parameter values are not honored");
|
throw new Exception("packExclude parameter values are not honored");
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +121,7 @@ namespace E2ETests
|
||||||
Console.WriteLine("Some tests failed. Proceeding with cleanup.");
|
Console.WriteLine("Some tests failed. Proceeding with cleanup.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DeploymentUtility.CleanUpApplication(startParameters, hostProcess, musicStoreDbName);
|
DeploymentUtility.CleanUpApplication(_startParameters, hostProcess, musicStoreDbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,19 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
public partial class SmokeTests
|
public partial class SmokeTests
|
||||||
{
|
{
|
||||||
private const string Connection_string_Format = "Server=(localdb)\\MSSQLLocalDB;Database={0};Trusted_Connection=True;MultipleActiveResultSets=true";
|
private const string CONNECTION_STRING_FORMAT = "Server=(localdb)\\MSSQLLocalDB;Database={0};Trusted_Connection=True;MultipleActiveResultSets=true";
|
||||||
|
|
||||||
private string ApplicationBaseUrl;
|
private string _applicationBaseUrl;
|
||||||
private HttpClient httpClient;
|
private HttpClient _httpClient;
|
||||||
private HttpClientHandler httpClientHandler;
|
private HttpClientHandler _httpClientHandler;
|
||||||
private StartParameters startParameters;
|
private StartParameters _startParameters;
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||||
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")]
|
[InlineData(ServerType.IISExpress, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")]
|
||||||
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5002/")]
|
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5002/")]
|
||||||
[InlineData(ServerType.Kestrel, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5004/")]
|
[InlineData(ServerType.Kestrel, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5004/")]
|
||||||
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")]
|
[InlineData(ServerType.IISExpress, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")]
|
||||||
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5002/")]
|
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5002/")]
|
||||||
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5004/")]
|
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5004/")]
|
||||||
public void SmokeTestSuite_OnX86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
public void SmokeTestSuite_OnX86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
||||||
|
|
@ -34,7 +34,7 @@ namespace E2ETests
|
||||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||||
[SkipOn32BitOS]
|
[SkipOn32BitOS]
|
||||||
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/")]
|
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/")]
|
||||||
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/")]
|
[InlineData(ServerType.IISExpress, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/")]
|
||||||
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5004/")]
|
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5004/")]
|
||||||
public void SmokeTestSuite_OnAMD64(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
public void SmokeTestSuite_OnAMD64(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
||||||
{
|
{
|
||||||
|
|
@ -70,11 +70,20 @@ namespace E2ETests
|
||||||
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
|
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConditionalTheory]
|
||||||
|
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||||
|
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Unix)]
|
||||||
|
[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5005/")]
|
||||||
|
public void SmokeTestSuite_On_IIS_X86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
||||||
|
{
|
||||||
|
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
private void SmokeTestSuite(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
private void SmokeTestSuite(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
|
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
|
||||||
|
|
||||||
startParameters = new StartParameters
|
_startParameters = new StartParameters
|
||||||
{
|
{
|
||||||
ServerType = serverType,
|
ServerType = serverType,
|
||||||
KreFlavor = kreFlavor,
|
KreFlavor = kreFlavor,
|
||||||
|
|
@ -85,26 +94,26 @@ namespace E2ETests
|
||||||
var testStartTime = DateTime.Now;
|
var testStartTime = DateTime.Now;
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
Console.WriteLine("Pointing MusicStore DB to '{0}'", string.Format(Connection_string_Format, musicStoreDbName));
|
Console.WriteLine("Pointing MusicStore DB to '{0}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
||||||
//Override the connection strings using environment based configuration
|
//Override the connection strings using environment based configuration
|
||||||
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(Connection_string_Format, musicStoreDbName));
|
Environment.SetEnvironmentVariable("SQLAZURECONNSTR_DefaultConnection", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
||||||
ApplicationBaseUrl = applicationBaseUrl;
|
_applicationBaseUrl = applicationBaseUrl;
|
||||||
Process hostProcess = null;
|
Process hostProcess = null;
|
||||||
bool testSuccessful = false;
|
bool testSuccessful = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hostProcess = DeploymentUtility.StartApplication(startParameters, musicStoreDbName);
|
hostProcess = DeploymentUtility.StartApplication(_startParameters, musicStoreDbName);
|
||||||
if (serverType == ServerType.IISNativeModule)
|
if (serverType == ServerType.IISNativeModule || serverType == ServerType.IIS)
|
||||||
{
|
{
|
||||||
// Accomodate the vdir name.
|
// Accomodate the vdir name.
|
||||||
ApplicationBaseUrl += startParameters.IISApplication.VirtualDirectoryName + "/";
|
_applicationBaseUrl += _startParameters.IISApplication.VirtualDirectoryName + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
httpClientHandler = new HttpClientHandler();
|
_httpClientHandler = new HttpClientHandler();
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(ApplicationBaseUrl) };
|
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
string responseContent = null;
|
string responseContent = null;
|
||||||
|
|
@ -115,7 +124,7 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = httpClient.GetAsync(string.Empty).Result;
|
response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
initializationCompleteTime = DateTime.Now;
|
initializationCompleteTime = DateTime.Now;
|
||||||
Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds);
|
Console.WriteLine("[Time]: Approximate time taken for application initialization : '{0}' seconds", (initializationCompleteTime - testStartTime).TotalSeconds);
|
||||||
|
|
@ -224,7 +233,7 @@ namespace E2ETests
|
||||||
Console.WriteLine("Some tests failed. Proceeding with cleanup.");
|
Console.WriteLine("Some tests failed. Proceeding with cleanup.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DeploymentUtility.CleanUpApplication(startParameters, hostProcess, musicStoreDbName);
|
DeploymentUtility.CleanUpApplication(_startParameters, hostProcess, musicStoreDbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue