diff --git a/test/E2ETests/Implementation/FacebookLoginScenarios.cs b/test/E2ETests/Implementation/FacebookLoginScenarios.cs index 4aafe03a74..bef77f5d3a 100644 --- a/test/E2ETests/Implementation/FacebookLoginScenarios.cs +++ b/test/E2ETests/Implementation/FacebookLoginScenarios.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using Microsoft.AspNet.Http.Core.Collections; using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.Logging; @@ -11,14 +12,14 @@ namespace E2ETests { public partial class Validator { - public void LoginWithFacebook() + public async Task LoginWithFacebook() { _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with Facebook account"); var formParameters = new List> { @@ -28,7 +29,7 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); Assert.Equal("https://www.facebook.com/v2.2/dialog/oauth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty)); var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query)); Assert.Equal("code", queryItems["response_type"]); @@ -44,8 +45,8 @@ namespace E2ETests _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - response = _httpClient.GetAsync("Account/Login").Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("Account/Login"); + responseContent = await response.Content.ReadAsStringAsync(); formParameters = new List> { new KeyValuePair("provider", "Facebook"), @@ -54,12 +55,12 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); //Post a message to the Facebook middleware - response = _httpClient.GetAsync("signin-facebook?code=ValidCode&state=ValidStateData").Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("signin-facebook?code=ValidCode&state=ValidStateData"); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); //Correlation cookie not getting cleared after successful signin? if (!Helpers.RunningOnMono) @@ -76,9 +77,9 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/ExternalLoginConfirmation", content); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@test.com"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase); @@ -89,7 +90,7 @@ namespace E2ETests _logger.LogInformation("Verifying if the middleware notifications were fired"); //Check for a non existing item - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result; + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")); //This action requires admin permissions. If notifications are fired this permission is granted Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); _logger.LogInformation("Middleware notifications were fired successfully"); diff --git a/test/E2ETests/Implementation/GoogleLoginScenarios.cs b/test/E2ETests/Implementation/GoogleLoginScenarios.cs index d7cfe73fab..0e9ef44ab7 100644 --- a/test/E2ETests/Implementation/GoogleLoginScenarios.cs +++ b/test/E2ETests/Implementation/GoogleLoginScenarios.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using Microsoft.AspNet.Http.Core.Collections; using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.Logging; @@ -11,14 +12,14 @@ namespace E2ETests { public partial class Validator { - public void LoginWithGoogle() + public async Task LoginWithGoogle() { _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with Google account"); var formParameters = new List> { @@ -28,7 +29,7 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); Assert.Equal("https://accounts.google.com/o/oauth2/auth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty)); var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query)); Assert.Equal("code", queryItems["response_type"]); @@ -45,8 +46,8 @@ namespace E2ETests _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - response = _httpClient.GetAsync("Account/Login").Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("Account/Login"); + responseContent = await response.Content.ReadAsStringAsync(); formParameters = new List> { new KeyValuePair("provider", "Google"), @@ -55,12 +56,12 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); //Post a message to the Google middleware - response = _httpClient.GetAsync("signin-google?code=ValidCode&state=ValidStateData").Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("signin-google?code=ValidCode&state=ValidStateData"); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); //Correlation cookie not getting cleared after successful signin? if (!Helpers.RunningOnMono) @@ -77,9 +78,9 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/ExternalLoginConfirmation", content); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@gmail.com"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase); @@ -90,9 +91,9 @@ namespace E2ETests _logger.LogInformation("Verifying if the middleware notifications were fired"); //Check for a non existing item - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result; + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")); //This action requires admin permissions. If notifications are fired this permission is granted - _logger.LogVerbose(response.Content.ReadAsStringAsync().Result); + _logger.LogVerbose(await response.Content.ReadAsStringAsync()); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); _logger.LogInformation("Middleware notifications were fired successfully"); } diff --git a/test/E2ETests/Implementation/MicrosoftAccountAuthenticationScenarios.cs b/test/E2ETests/Implementation/MicrosoftAccountAuthenticationScenarios.cs index 9ddff25443..f07a5eef5f 100644 --- a/test/E2ETests/Implementation/MicrosoftAccountAuthenticationScenarios.cs +++ b/test/E2ETests/Implementation/MicrosoftAccountAuthenticationScenarios.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using Microsoft.AspNet.Http.Core.Collections; using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.Logging; @@ -11,14 +12,14 @@ namespace E2ETests { public partial class Validator { - public void LoginWithMicrosoftAccount() + public async Task LoginWithMicrosoftAccount() { _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with Microsoft account"); var formParameters = new List> { @@ -28,7 +29,7 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); Assert.Equal("https://login.live.com/oauth20_authorize.srf", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty)); var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query)); Assert.Equal("code", queryItems["response_type"]); @@ -45,8 +46,8 @@ namespace E2ETests _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - response = _httpClient.GetAsync("Account/Login").Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("Account/Login"); + responseContent = await response.Content.ReadAsStringAsync(); formParameters = new List> { new KeyValuePair("provider", "Microsoft"), @@ -55,12 +56,12 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); //Post a message to the MicrosoftAccount middleware - response = _httpClient.GetAsync("signin-microsoft?code=ValidCode&state=ValidStateData").Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("signin-microsoft?code=ValidCode&state=ValidStateData"); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); //Correlation cookie not getting cleared after successful signin? if (!Helpers.RunningOnMono) @@ -76,9 +77,9 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/ExternalLoginConfirmation", content); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("Hello {0}!", "microsoft@test.com"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase); @@ -89,9 +90,9 @@ namespace E2ETests _logger.LogInformation("Verifying if the middleware notifications were fired"); //Check for a non existing item - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result; + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")); //This action requires admin permissions. If notifications are fired this permission is granted - _logger.LogInformation(response.Content.ReadAsStringAsync().Result); + _logger.LogInformation(await response.Content.ReadAsStringAsync()); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); _logger.LogInformation("Middleware notifications were fired successfully"); } diff --git a/test/E2ETests/Implementation/OpenIdConnectLoginScenarios.cs b/test/E2ETests/Implementation/OpenIdConnectLoginScenarios.cs index 09c3fb4606..5450e7b7b4 100644 --- a/test/E2ETests/Implementation/OpenIdConnectLoginScenarios.cs +++ b/test/E2ETests/Implementation/OpenIdConnectLoginScenarios.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using Microsoft.AspNet.Http.Core.Collections; using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.Logging; @@ -11,14 +12,14 @@ namespace E2ETests { public partial class Validator { - public void LoginWithOpenIdConnect() + public async Task LoginWithOpenIdConnect() { _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with OpenIdConnect account"); var formParameters = new List> { @@ -28,7 +29,7 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/oauth2/authorize", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty)); var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query)); Assert.Equal("c99497aa-3ee2-4707-b8a8-c33f51323fef", queryItems["client_id"]); @@ -53,9 +54,9 @@ namespace E2ETests new KeyValuePair("session_state", "d0b59ffa-2df9-4d8c-b43a-2c410987f4ae") }; - response = _httpClient.PostAsync(string.Empty, new FormUrlEncodedContent(token.ToArray())).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync(string.Empty, new FormUrlEncodedContent(token.ToArray())); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Equal(_deploymentResult.ApplicationBaseUri + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri); formParameters = new List> @@ -65,9 +66,9 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/ExternalLoginConfirmation", content); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("Hello {0}!", "User3@aspnettest.onmicrosoft.com"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase); @@ -78,15 +79,15 @@ namespace E2ETests _logger.LogInformation("Verifying if the middleware notifications were fired"); //Check for a non existing item - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result; + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")); //This action requires admin permissions. If notifications are fired this permission is granted Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); _logger.LogInformation("Middleware notifications were fired successfully"); _logger.LogInformation("Verifying the OpenIdConnect logout flow.."); - response = _httpClient.GetAsync(string.Empty).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync(string.Empty); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); ValidateLayoutPage(responseContent); formParameters = new List> { @@ -99,7 +100,7 @@ namespace E2ETests handler.CookieContainer.Add(new Uri(_deploymentResult.ApplicationBaseUri), _httpClientHandler.CookieContainer.GetCookies(new Uri(_deploymentResult.ApplicationBaseUri))); _httpClient = new HttpClient(handler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - response = _httpClient.PostAsync("Account/LogOff", content).Result; + response = await _httpClient.PostAsync("Account/LogOff", content); Assert.Null(handler.CookieContainer.GetCookies(new Uri(_deploymentResult.ApplicationBaseUri)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application")); Assert.Equal( "https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/oauth2/logout", diff --git a/test/E2ETests/Implementation/TwitterLoginScenarios.cs b/test/E2ETests/Implementation/TwitterLoginScenarios.cs index 85d02060bb..8c302066f7 100644 --- a/test/E2ETests/Implementation/TwitterLoginScenarios.cs +++ b/test/E2ETests/Implementation/TwitterLoginScenarios.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using Microsoft.AspNet.Http.Core.Collections; using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.Logging; @@ -14,14 +15,14 @@ namespace E2ETests /// public partial class Validator { - public void LoginWithTwitter() + public async Task LoginWithTwitter() { _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with Twitter account"); var formParameters = new List> { @@ -31,7 +32,7 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); Assert.Equal("https://twitter.com/oauth/authenticate", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty)); var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query)); Assert.Equal("custom", queryItems["custom_redirect_uri"]); @@ -43,8 +44,8 @@ namespace E2ETests _httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = true }; _httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_deploymentResult.ApplicationBaseUri) }; - response = _httpClient.GetAsync("Account/Login").Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("Account/Login"); + responseContent = await response.Content.ReadAsStringAsync(); formParameters = new List> { new KeyValuePair("provider", "Twitter"), @@ -53,12 +54,12 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLogin", content).Result; + response = await _httpClient.PostAsync("Account/ExternalLogin", content); //Post a message to the Facebook middleware - response = _httpClient.GetAsync("signin-twitter?oauth_token=valid_oauth_token&oauth_verifier=valid_oauth_verifier").Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync("signin-twitter?oauth_token=valid_oauth_token&oauth_verifier=valid_oauth_verifier"); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); //Check correlation cookie not getting cleared after successful signin if (!Helpers.RunningOnMono) @@ -76,9 +77,9 @@ namespace E2ETests }; content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/ExternalLoginConfirmation", content); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("Hello {0}!", "twitter@test.com"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase); @@ -89,7 +90,7 @@ namespace E2ETests _logger.LogInformation("Verifying if the middleware notifications were fired"); //Check for a non existing item - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")).Result; + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", "123")); //This action requires admin permissions. If notifications are fired this permission is granted Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); _logger.LogInformation("Middleware notifications were fired successfully"); diff --git a/test/E2ETests/Implementation/Validator.cs b/test/E2ETests/Implementation/Validator.cs index 8d7476114d..778426a8ac 100644 --- a/test/E2ETests/Implementation/Validator.cs +++ b/test/E2ETests/Implementation/Validator.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Net; using System.Net.Http; using System.Threading; +using System.Threading.Tasks; using DeploymentHelpers; using Microsoft.AspNet.SignalR.Client; using Microsoft.Framework.Logging; @@ -30,11 +31,11 @@ namespace E2ETests _deploymentResult = deploymentResult; } - public void VerifyHomePage( + public async Task VerifyHomePage( HttpResponseMessage response, bool useNtlmAuthentication = false) { - var responseContent = response.Content.ReadAsStringAsync().Result; + var responseContent = await response.Content.ReadAsStringAsync(); if (response.StatusCode != HttpStatusCode.OK) { @@ -58,7 +59,7 @@ namespace E2ETests _logger.LogInformation("Application initialization successful."); _logger.LogInformation("Application runtime information"); - //var runtimeResponse = _httpClient.GetAsync("runtimeinfo").Result; + //var runtimeResponse = await _httpClient.GetAsync("runtimeinfo"); // https://github.com/aspnet/Diagnostics/issues/108 if (_deploymentResult.DeploymentParameters.RuntimeFlavor != RuntimeFlavor.coreclr) @@ -66,15 +67,15 @@ namespace E2ETests //Helpers.ThrowIfResponseStatusNotOk(runtimeResponse, _logger); } - //var runtimeInfo = runtimeResponse.Content.ReadAsStringAsync().Result; + //var runtimeInfo = await runtimeResponse.Content.ReadAsStringAsync(); //_logger.LogInformation(runtimeInfo); } - public void VerifyNtlmHomePage(HttpResponseMessage response) + public async Task VerifyNtlmHomePage(HttpResponseMessage response) { - VerifyHomePage(response, useNtlmAuthentication: true); + await VerifyHomePage(response, useNtlmAuthentication: true); - var homePageContent = response.Content.ReadAsStringAsync().Result; + var homePageContent = await response.Content.ReadAsStringAsync(); //Check if the user name appears in the page Assert.Contains( @@ -91,34 +92,34 @@ namespace E2ETests Assert.Contains("
  • ", responseContent, StringComparison.OrdinalIgnoreCase); } - public void VerifyStaticContentServed() + public async Task VerifyStaticContentServed() { _logger.LogInformation("Validating if static contents are served.."); _logger.LogInformation("Fetching favicon.ico.."); - var response = _httpClient.GetAsync("favicon.ico").Result; - ThrowIfResponseStatusNotOk(response); + var response = await _httpClient.GetAsync("favicon.ico"); + await ThrowIfResponseStatusNotOk(response); _logger.LogInformation("Etag received: {etag}", response.Headers.ETag.Tag); //Check if you receive a NotModified on sending an etag _logger.LogInformation("Sending an IfNoneMatch header with e-tag"); _httpClient.DefaultRequestHeaders.IfNoneMatch.Add(response.Headers.ETag); - response = _httpClient.GetAsync("favicon.ico").Result; + response = await _httpClient.GetAsync("favicon.ico"); Assert.Equal(HttpStatusCode.NotModified, response.StatusCode); _httpClient.DefaultRequestHeaders.IfNoneMatch.Clear(); _logger.LogInformation("Successfully received a NotModified status"); _logger.LogInformation("Fetching /Content/bootstrap.css.."); - response = _httpClient.GetAsync("Content/bootstrap.css").Result; - ThrowIfResponseStatusNotOk(response); + response = await _httpClient.GetAsync("Content/bootstrap.css"); + await ThrowIfResponseStatusNotOk(response); _logger.LogInformation("Verified static contents are served successfully"); } - public void AccessStoreWithPermissions() + public async Task AccessStoreWithPermissions() { _logger.LogInformation("Trying to access the store inventory.."); - var response = _httpClient.GetAsync("Admin/StoreManager/").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Admin/StoreManager/"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); Assert.Equal(_deploymentResult.ApplicationBaseUri + "Admin/StoreManager/", response.RequestMessage.RequestUri.AbsoluteUri); _logger.LogInformation("Successfully acccessed the store inventory"); } @@ -137,12 +138,12 @@ namespace E2ETests return url.Replace("//", "/").Replace("%2F%2F", "%2F").Replace("%2F/", "%2F"); } - public void AccessStoreWithoutPermissions(string email = null) + public async Task AccessStoreWithoutPermissions(string email = null) { _logger.LogInformation("Trying to access StoreManager that needs ManageStore claim with the current user : {email}", email ?? "Anonymous"); - var response = _httpClient.GetAsync("Admin/StoreManager/").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Admin/StoreManager/"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); ValidateLayoutPage(responseContent); Assert.Contains("Log in – ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("

    Use a local account to log in.

    ", responseContent, StringComparison.OrdinalIgnoreCase); @@ -150,12 +151,12 @@ namespace E2ETests _logger.LogInformation("Redirected to login page as expected."); } - public void RegisterUserWithNonMatchingPasswords() + public async Task RegisterUserWithNonMatchingPasswords() { _logger.LogInformation("Trying to create user with not matching password and confirm password"); - var response = _httpClient.GetAsync("Account/Register").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Register"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); ValidateLayoutPage(responseContent); var generatedEmail = Guid.NewGuid().ToString().Replace("-", string.Empty) + "@test.com"; @@ -169,18 +170,18 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/Register", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/Register", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_deploymentResult.ApplicationBaseUri)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application")); Assert.Contains("
    • The password and confirmation password do not match.
    • ", responseContent, StringComparison.OrdinalIgnoreCase); _logger.LogInformation("Server side model validator rejected the user '{email}''s registration as passwords do not match.", generatedEmail); } - public string RegisterValidUser() + public async Task RegisterValidUser() { - var response = _httpClient.GetAsync("Account/Register").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Register"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); ValidateLayoutPage(responseContent); var generatedEmail = Guid.NewGuid().ToString().Replace("-", string.Empty) + "@test.com"; @@ -194,8 +195,8 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/Register", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/Register", content); + responseContent = await response.Content.ReadAsStringAsync(); //Account verification Assert.Equal(_deploymentResult.ApplicationBaseUri + "Account/Register", response.RequestMessage.RequestUri.AbsoluteUri); @@ -204,19 +205,19 @@ namespace E2ETests var endIndex = responseContent.IndexOf("\">link]]", startIndex); var confirmUrl = responseContent.Substring(startIndex, endIndex - startIndex); confirmUrl = WebUtility.HtmlDecode(confirmUrl); - response = _httpClient.GetAsync(confirmUrl).Result; - ThrowIfResponseStatusNotOk(response); - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.GetAsync(confirmUrl); + await ThrowIfResponseStatusNotOk(response); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("Thank you for confirming your email.", responseContent, StringComparison.OrdinalIgnoreCase); return generatedEmail; } - public void RegisterExistingUser(string email) + public async Task RegisterExistingUser(string email) { _logger.LogInformation("Trying to register a user with name '{email}' again", email); - var response = _httpClient.GetAsync("Account/Register").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Register"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Creating a new user with name '{email}'", email); var formParameters = new List> { @@ -227,18 +228,18 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/Register", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/Register", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("User name '{0}' is already taken.", email), responseContent, StringComparison.OrdinalIgnoreCase); _logger.LogInformation("Identity threw a valid exception that user '{email}' already exists in the system", email); } - public void SignOutUser(string email) + public async Task SignOutUser(string email) { _logger.LogInformation("Signing out from '{email}''s session", email); - var response = _httpClient.GetAsync(string.Empty).Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync(string.Empty); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); ValidateLayoutPage(responseContent); var formParameters = new List> { @@ -246,8 +247,8 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/LogOff", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/LogOff", content); + responseContent = await response.Content.ReadAsStringAsync(); if (!Helpers.RunningOnMono) { @@ -268,11 +269,11 @@ namespace E2ETests } } - public void SignInWithInvalidPassword(string email, string invalidPassword) + public async Task SignInWithInvalidPassword(string email, string invalidPassword) { - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with user '{email}'", email); var formParameters = new List> { @@ -282,19 +283,19 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/Login", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/Login", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("
      • Invalid login attempt.
      • ", responseContent, StringComparison.OrdinalIgnoreCase); //Verify cookie not sent Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_deploymentResult.ApplicationBaseUri)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application")); _logger.LogInformation("Identity successfully prevented an invalid user login."); } - public void SignInWithUser(string email, string password) + public async Task SignInWithUser(string email, string password) { - var response = _httpClient.GetAsync("Account/Login").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Account/Login"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Signing in with user '{email}'", email); var formParameters = new List> { @@ -304,8 +305,8 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Account/Login", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Account/Login", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(string.Format("Hello {0}!", email), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase); //Verify cookie sent @@ -313,11 +314,11 @@ namespace E2ETests _logger.LogInformation("Successfully signed in with user '{email}'", email); } - public void ChangePassword(string email) + public async Task ChangePassword(string email) { - var response = _httpClient.GetAsync("Manage/ChangePassword").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Manage/ChangePassword"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); var formParameters = new List> { new KeyValuePair("OldPassword", "Password~1"), @@ -327,14 +328,14 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Manage/ChangePassword", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Manage/ChangePassword", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("Your password has been changed.", responseContent, StringComparison.OrdinalIgnoreCase); Assert.NotNull(_httpClientHandler.CookieContainer.GetCookies(new Uri(_deploymentResult.ApplicationBaseUri)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application")); _logger.LogInformation("Successfully changed the password for user '{email}'", email); } - public string CreateAlbum() + public async Task CreateAlbum() { var albumName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12); #if DNX451 @@ -349,12 +350,12 @@ namespace E2ETests }; IHubProxy proxy = hubConnection.CreateHubProxy("Announcement"); - hubConnection.Start().Wait(); + await hubConnection.Start(); #endif _logger.LogInformation("Trying to create an album with name '{album}'", albumName); - var response = _httpClient.GetAsync("Admin/StoreManager/create").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Admin/StoreManager/create"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); var formParameters = new List> { new KeyValuePair("__RequestVerificationToken", HtmlDOMHelper.RetrieveAntiForgeryToken(responseContent, "/Admin/StoreManager/create")), @@ -366,8 +367,8 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Admin/StoreManager/create", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Admin/StoreManager/create", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Equal(_deploymentResult.ApplicationBaseUri + "Admin/StoreManager", response.RequestMessage.RequestUri.AbsoluteUri); Assert.Contains(albumName, responseContent); #if DNX451 @@ -380,77 +381,77 @@ namespace E2ETests return albumName; } - public string FetchAlbumIdFromName(string albumName) + public async Task FetchAlbumIdFromName(string albumName) { // Run some CORS validation. _logger.LogInformation("Fetching the album id of '{album}'", albumName); _httpClient.DefaultRequestHeaders.Add("Origin", "http://notpermitteddomain.com"); - var response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result; - ThrowIfResponseStatusNotOk(response); + var response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)); + await ThrowIfResponseStatusNotOk(response); IEnumerable values; Assert.False(response.Headers.TryGetValues("Access-Control-Allow-Origin", out values)); _httpClient.DefaultRequestHeaders.Remove("Origin"); _httpClient.DefaultRequestHeaders.Add("Origin", "http://example.com"); - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result; - ThrowIfResponseStatusNotOk(response); + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)); + await ThrowIfResponseStatusNotOk(response); Assert.Equal("http://example.com", response.Headers.GetValues("Access-Control-Allow-Origin").First()); _httpClient.DefaultRequestHeaders.Remove("Origin"); - var albumId = response.Content.ReadAsStringAsync().Result; + var albumId = await response.Content.ReadAsStringAsync(); _logger.LogInformation("Album id for album '{album}' is '{id}'", albumName, albumId); return albumId; } - public void VerifyAlbumDetails(string albumId, string albumName) + public async Task VerifyAlbumDetails(string albumId, string albumName) { _logger.LogInformation("Getting details of album with Id '{id}'", albumId); - var response = _httpClient.GetAsync(string.Format("Admin/StoreManager/Details?id={0}", albumId)).Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/Details?id={0}", albumId)); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("http://myapp/testurl", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains(PrefixBaseAddress(string.Format("Edit", "{0}", albumId)), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains(PrefixBaseAddress("Back to List"), responseContent, StringComparison.OrdinalIgnoreCase); } - public void VerifyStatusCodePages() + public async Task VerifyStatusCodePages() { _logger.LogInformation("Getting details of a non-existing album with Id '-1'"); - var response = _httpClient.GetAsync("Admin/StoreManager/Details?id=-1").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Admin/StoreManager/Details?id=-1"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("Item not found.", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Equal(PrefixBaseAddress("/{0}/Home/StatusCodePage"), response.RequestMessage.RequestUri.AbsolutePath); } // This gets the view that non-admin users get to see. - public void GetAlbumDetailsFromStore(string albumId, string albumName) + public async Task GetAlbumDetailsFromStore(string albumId, string albumName) { _logger.LogInformation("Getting details of album with Id '{id}'", albumId); - var response = _httpClient.GetAsync(string.Format("Store/Details/{0}", albumId)).Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync(string.Format("Store/Details/{0}", albumId)); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase); } - public void AddAlbumToCart(string albumId, string albumName) + public async Task AddAlbumToCart(string albumId, string albumName) { _logger.LogInformation("Adding album id '{albumId}' to the cart", albumId); - var response = _httpClient.GetAsync(string.Format("ShoppingCart/AddToCart?id={0}", albumId)).Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync(string.Format("ShoppingCart/AddToCart?id={0}", albumId)); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains(albumName, responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("", responseContent, StringComparison.OrdinalIgnoreCase); _logger.LogInformation("Verified that album is added to cart"); } - public void CheckOutCartItems() + public async Task CheckOutCartItems() { _logger.LogInformation("Checking out the cart contents..."); - var response = _httpClient.GetAsync("Checkout/AddressAndPayment").Result; - ThrowIfResponseStatusNotOk(response); - var responseContent = response.Content.ReadAsStringAsync().Result; + var response = await _httpClient.GetAsync("Checkout/AddressAndPayment"); + await ThrowIfResponseStatusNotOk(response); + var responseContent = await response.Content.ReadAsStringAsync(); var formParameters = new List> { @@ -468,13 +469,13 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - response = _httpClient.PostAsync("Checkout/AddressAndPayment", content).Result; - responseContent = response.Content.ReadAsStringAsync().Result; + response = await _httpClient.PostAsync("Checkout/AddressAndPayment", content); + responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("

        Checkout Complete

        ", responseContent, StringComparison.OrdinalIgnoreCase); Assert.StartsWith(_deploymentResult.ApplicationBaseUri + "Checkout/Complete/", response.RequestMessage.RequestUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase); } - public void DeleteAlbum(string albumId, string albumName) + public async Task DeleteAlbum(string albumId, string albumName) { _logger.LogInformation("Deleting album '{album}' from the store..", albumName); @@ -484,20 +485,20 @@ namespace E2ETests }; var content = new FormUrlEncodedContent(formParameters.ToArray()); - var response = _httpClient.PostAsync("Admin/StoreManager/RemoveAlbum", content).Result; - ThrowIfResponseStatusNotOk(response); + var response = await _httpClient.PostAsync("Admin/StoreManager/RemoveAlbum", content); + await ThrowIfResponseStatusNotOk(response); _logger.LogInformation("Verifying if the album '{album}' is deleted from store", albumName); - response = _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)).Result; + response = await _httpClient.GetAsync(string.Format("Admin/StoreManager/GetAlbumIdFromName?albumName={0}", albumName)); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); _logger.LogInformation("Album '{album}' with id '{Id}' is successfully deleted from the store.", albumName, albumId); } - private void ThrowIfResponseStatusNotOk(HttpResponseMessage response) + private async Task ThrowIfResponseStatusNotOk(HttpResponseMessage response) { if (response.StatusCode != HttpStatusCode.OK) { - _logger.LogError(response.Content.ReadAsStringAsync().Result); + _logger.LogError(await response.Content.ReadAsStringAsync()); throw new Exception(string.Format("Received the above response with status code : {0}", response.StatusCode)); } } diff --git a/test/E2ETests/NtlmAuthentationTest.cs b/test/E2ETests/NtlmAuthentationTest.cs index 24cd95f193..475fe643c5 100644 --- a/test/E2ETests/NtlmAuthentationTest.cs +++ b/test/E2ETests/NtlmAuthentationTest.cs @@ -64,10 +64,10 @@ namespace E2ETests }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); - validator.VerifyNtlmHomePage(response); + await validator.VerifyNtlmHomePage(response); //Should be able to access the store as the Startup adds necessary permissions for the current user - validator.AccessStoreWithPermissions(); + await validator.AccessStoreWithPermissions(); logger.LogInformation("Variation completed successfully."); } diff --git a/test/E2ETests/OpenIdConnectTests.cs b/test/E2ETests/OpenIdConnectTests.cs index 1f7454484c..4281876116 100644 --- a/test/E2ETests/OpenIdConnectTests.cs +++ b/test/E2ETests/OpenIdConnectTests.cs @@ -73,10 +73,10 @@ namespace E2ETests }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); - validator.VerifyHomePage(response); + await validator.VerifyHomePage(response); // OpenIdConnect login. - validator.LoginWithOpenIdConnect(); + await validator.LoginWithOpenIdConnect(); logger.LogInformation("Variation completed successfully."); } diff --git a/test/E2ETests/PublishAndRunTests.cs b/test/E2ETests/PublishAndRunTests.cs index d12e180f7f..d3b27b69f3 100644 --- a/test/E2ETests/PublishAndRunTests.cs +++ b/test/E2ETests/PublishAndRunTests.cs @@ -96,10 +96,10 @@ namespace E2ETests }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); - validator.VerifyHomePage(response); + await validator.VerifyHomePage(response); // Static files are served? - validator.VerifyStaticContentServed(); + await validator.VerifyStaticContentServed(); if (serverType != ServerType.IISExpress) { diff --git a/test/E2ETests/SmokeTests.cs b/test/E2ETests/SmokeTests.cs index 715118909c..01ac33d781 100644 --- a/test/E2ETests/SmokeTests.cs +++ b/test/E2ETests/SmokeTests.cs @@ -165,88 +165,88 @@ namespace E2ETests var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); - validator.VerifyHomePage(response); + await validator.VerifyHomePage(response); // Verify the static file middleware can serve static content. - validator.VerifyStaticContentServed(); + await validator.VerifyStaticContentServed(); // Making a request to a protected resource should automatically redirect to login page. - validator.AccessStoreWithoutPermissions(); + await validator.AccessStoreWithoutPermissions(); // Register a user - Negative scenario where the Password & ConfirmPassword do not match. - validator.RegisterUserWithNonMatchingPasswords(); + await validator.RegisterUserWithNonMatchingPasswords(); // Register a valid user. - var generatedEmail = validator.RegisterValidUser(); + var generatedEmail = await validator.RegisterValidUser(); - validator.SignInWithUser(generatedEmail, "Password~1"); + await validator.SignInWithUser(generatedEmail, "Password~1"); // Register a user - Negative scenario : Trying to register a user name that's already registered. - validator.RegisterExistingUser(generatedEmail); + await validator.RegisterExistingUser(generatedEmail); // Logout from this user session - This should take back to the home page - validator.SignOutUser(generatedEmail); + await validator.SignOutUser(generatedEmail); // Sign in scenarios: Invalid password - Expected an invalid user name password error. - validator.SignInWithInvalidPassword(generatedEmail, "InvalidPassword~1"); + await validator.SignInWithInvalidPassword(generatedEmail, "InvalidPassword~1"); // Sign in scenarios: Valid user name & password. - validator.SignInWithUser(generatedEmail, "Password~1"); + await validator.SignInWithUser(generatedEmail, "Password~1"); // Change password scenario - validator.ChangePassword(generatedEmail); + await validator.ChangePassword(generatedEmail); // SignIn with old password and verify old password is not allowed and new password is allowed - validator.SignOutUser(generatedEmail); - validator.SignInWithInvalidPassword(generatedEmail, "Password~1"); - validator.SignInWithUser(generatedEmail, "Password~2"); + await validator.SignOutUser(generatedEmail); + await validator.SignInWithInvalidPassword(generatedEmail, "Password~1"); + await validator.SignInWithUser(generatedEmail, "Password~2"); // Making a request to a protected resource that this user does not have access to - should automatically redirect to login page again - validator.AccessStoreWithoutPermissions(generatedEmail); + await validator.AccessStoreWithoutPermissions(generatedEmail); // Logout from this user session - This should take back to the home page - validator.SignOutUser(generatedEmail); + await validator.SignOutUser(generatedEmail); // Login as an admin user - validator.SignInWithUser("Administrator@test.com", "YouShouldChangeThisPassword1!"); + await validator.SignInWithUser("Administrator@test.com", "YouShouldChangeThisPassword1!"); // Now navigating to the store manager should work fine as this user has the necessary permission to administer the store. - validator.AccessStoreWithPermissions(); + await validator.AccessStoreWithPermissions(); // Create an album - var albumName = validator.CreateAlbum(); - var albumId = validator.FetchAlbumIdFromName(albumName); + var albumName = await validator.CreateAlbum(); + var albumId = await validator.FetchAlbumIdFromName(albumName); // Get details of the album - validator.VerifyAlbumDetails(albumId, albumName); + await validator.VerifyAlbumDetails(albumId, albumName); // Verify status code pages acts on non-existing items. - validator.VerifyStatusCodePages(); + await validator.VerifyStatusCodePages(); // Get the non-admin view of the album. - validator.GetAlbumDetailsFromStore(albumId, albumName); + await validator.GetAlbumDetailsFromStore(albumId, albumName); // Add an album to cart and checkout the same - validator.AddAlbumToCart(albumId, albumName); - validator.CheckOutCartItems(); + await validator.AddAlbumToCart(albumId, albumName); + await validator.CheckOutCartItems(); // Delete the album from store - validator.DeleteAlbum(albumId, albumName); + await validator.DeleteAlbum(albumId, albumName); // Logout from this user session - This should take back to the home page - validator.SignOutUser("Administrator"); + await validator.SignOutUser("Administrator"); // Google login - validator.LoginWithGoogle(); + await validator.LoginWithGoogle(); // Facebook login - validator.LoginWithFacebook(); + await validator.LoginWithFacebook(); // Twitter login - validator.LoginWithTwitter(); + await validator.LoginWithTwitter(); // MicrosoftAccountLogin - validator.LoginWithMicrosoftAccount(); + await validator.LoginWithMicrosoftAccount(); logger.LogInformation("Variation completed successfully."); }