Enabling the E2E automation for social logins.
This commit is contained in:
parent
3e6ce61f27
commit
42e23bd261
|
|
@ -1,7 +1,6 @@
|
|||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
using MusicStore.Mocks.Common;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ namespace MusicStore.Mocks.Facebook
|
|||
Helpers.ThrowIfConditionFailed(() => queryParameters["appsecret_proof"] != null, "appsecret_proof is null");
|
||||
if (queryParameters["access_token"] == "ValidAccessToken")
|
||||
{
|
||||
response.Content = new StringContent("{\"id\":\"Id\",\"name\":\"AspnetvnextTest AspnetvnextTest\",\"first_name\":\"AspnetvnextTest\",\"last_name\":\"AspnetvnextTest\",\"link\":\"https:\\/\\/www.facebook.com\\/myLink\",\"username\":\"AspnetvnextTest.AspnetvnextTest.7\",\"gender\":\"male\",\"email\":\"AspnetvnextTest\\u0040gmail.com\",\"timezone\":-7,\"locale\":\"en_US\",\"verified\":true,\"updated_time\":\"2013-08-06T20:38:48+0000\",\"CertValidatorInvoked\":\"ValidAccessToken\"}");
|
||||
response.Content = new StringContent("{\"id\":\"Id\",\"name\":\"AspnetvnextTest AspnetvnextTest\",\"first_name\":\"AspnetvnextTest\",\"last_name\":\"AspnetvnextTest\",\"link\":\"https:\\/\\/www.facebook.com\\/myLink\",\"username\":\"AspnetvnextTest.AspnetvnextTest.7\",\"gender\":\"male\",\"email\":\"AspnetvnextTest\\u0040test.com\",\"timezone\":-7,\"locale\":\"en_US\",\"verified\":true,\"updated_time\":\"2013-08-06T20:38:48+0000\",\"CertValidatorInvoked\":\"ValidAccessToken\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace MusicStore.Mocks.Facebook
|
|||
if (context.Identity != null)
|
||||
{
|
||||
Helpers.ThrowIfConditionFailed(() => context.AccessToken == "ValidAccessToken", "");
|
||||
Helpers.ThrowIfConditionFailed(() => context.Email == "AspnetvnextTest@gmail.com", "");
|
||||
Helpers.ThrowIfConditionFailed(() => context.Email == "AspnetvnextTest@test.com", "");
|
||||
Helpers.ThrowIfConditionFailed(() => context.Id == "Id", "");
|
||||
Helpers.ThrowIfConditionFailed(() => context.Link == "https://www.facebook.com/myLink", "");
|
||||
Helpers.ThrowIfConditionFailed(() => context.Name == "AspnetvnextTest AspnetvnextTest", "");
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace MusicStore
|
|||
});
|
||||
|
||||
// Add Identity services to the services container
|
||||
services.AddIdentitySqlServer<MusicStoreContext, ApplicationUser>();
|
||||
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(configuration);
|
||||
|
||||
// Add MVC services to the services container
|
||||
services.AddMvc();
|
||||
|
|
@ -115,6 +115,7 @@ namespace MusicStore
|
|||
// Add static files to the request pipeline
|
||||
app.UseStaticFiles();
|
||||
|
||||
// Add cookie-based authentication to the request pipeline
|
||||
app.UseIdentity();
|
||||
|
||||
var facebookOptions = new FacebookAuthenticationOptions()
|
||||
|
|
@ -163,7 +164,10 @@ namespace MusicStore
|
|||
OnApplyRedirect = TwitterNotifications.OnApplyRedirect
|
||||
},
|
||||
StateDataFormat = new CustomTwitterStateDataFormat(),
|
||||
BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler()
|
||||
BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler(),
|
||||
#if ASPNET50
|
||||
BackchannelCertificateValidator = null
|
||||
#endif
|
||||
});
|
||||
|
||||
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ namespace MusicStore
|
|||
/// 2. Add a setting in the ini file named 'KRE_ENV' with value of the format 'Startup[EnvironmentName]'. For example: To load a Startup class named
|
||||
/// 'StartupNtlmAuthentication' the value of the env should be 'NtlmAuthentication' (eg. KRE_ENV=NtlmAuthentication). Runtime adds a 'Startup' prefix to this and loads 'StartupNtlmAuthentication'.
|
||||
/// If no environment name is specified the default startup class loaded is 'Startup'.
|
||||
/// https://github.com/aspnet/Helios/issues/53 - Environment based startup class loading is not available on Helios.
|
||||
/// Alternative ways to specify environment are:
|
||||
/// 1. Set the environment variable named SET KRE_ENV=NtlmAuthentication
|
||||
/// 2. For selfhost based servers pass in a command line variable named --env with this value. Eg:
|
||||
|
|
|
|||
|
|
@ -56,10 +56,33 @@ namespace E2ETests
|
|||
|
||||
//Post a message to the Facebook middleware
|
||||
response = httpClient.GetAsync("signin-facebook?code=ValidCode&state=ValidStateData").Result;
|
||||
//This should land us in ExternalLoginCallBack - this action is not implemented yet. We need to wait to complete automation.
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
//Correlation cookie not getting cleared after successful signin?
|
||||
//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.Contains("AspnetvnextTest@test.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
formParameters = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("Email", "AspnetvnextTest@test.com"),
|
||||
new KeyValuePair<string, string>("__RequestVerificationToken", HtmlDOMHelper.RetrieveAntiForgeryToken(responseContent, "/Account/ExternalLoginConfirmation?ReturnUrl=%2F")),
|
||||
};
|
||||
|
||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
//Verify cookie sent
|
||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||
|
||||
//https://github.com/aspnet/Identity/issues/210
|
||||
//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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,10 +57,33 @@ namespace E2ETests
|
|||
|
||||
//Post a message to the Google middleware
|
||||
response = httpClient.GetAsync("signin-google?code=ValidCode&state=ValidStateData").Result;
|
||||
//This should land us in ExternalLoginCallBack - this action is not implemented yet. We need to wait to complete automation.
|
||||
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
//Correlation cookie not getting cleared after successful signin?
|
||||
//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.Contains("AspnetvnextTest@gmail.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
formParameters = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("Email", "AspnetvnextTest@gmail.com"),
|
||||
new KeyValuePair<string, string>("__RequestVerificationToken", HtmlDOMHelper.RetrieveAntiForgeryToken(responseContent, "/Account/ExternalLoginConfirmation?ReturnUrl=%2F")),
|
||||
};
|
||||
|
||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
Assert.Contains(string.Format("Hello {0}!", "AspnetvnextTest@gmail.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
//Verify cookie sent
|
||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||
|
||||
//https://github.com/aspnet/Identity/issues/210
|
||||
//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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ namespace E2ETests
|
|||
{
|
||||
public partial class SmokeTests
|
||||
{
|
||||
[Theory]
|
||||
//[Theory]
|
||||
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/", false)]
|
||||
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5002/", false)]
|
||||
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5001/", false)]
|
||||
|
|
@ -64,12 +64,8 @@ namespace E2ETests
|
|||
//Check if the user name appears in the page
|
||||
Assert.Contains(string.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (serverType != ServerType.Helios)
|
||||
{
|
||||
//https://github.com/aspnet/Helios/issues/53
|
||||
//Should be able to access the store as the Startup adds necessary permissions for the current user
|
||||
AccessStoreWithPermissions();
|
||||
}
|
||||
//Should be able to access the store as the Startup adds necessary permissions for the current user
|
||||
AccessStoreWithPermissions();
|
||||
|
||||
var testCompletionTime = DateTime.Now;
|
||||
Console.WriteLine("[Time]: All tests completed in '{0}' seconds", (testCompletionTime - initializationCompleteTime).TotalSeconds);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace E2ETests
|
|||
/// </summary>
|
||||
public partial class SmokeTests
|
||||
{
|
||||
[Theory]
|
||||
//[Theory]
|
||||
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/", false)]
|
||||
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/", false)]
|
||||
//https://github.com/aspnet/KRuntime/issues/642
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ namespace E2ETests
|
|||
KreFlavor = kreFlavor,
|
||||
KreArchitecture = architecture,
|
||||
ApplicationHostConfigTemplateContent = (serverType == ServerType.HeliosNativeModule) ? File.ReadAllText("HeliosNativeModuleApplicationHost.config") : null,
|
||||
SiteName = (serverType == ServerType.HeliosNativeModule) ? "MusicStoreNativeModule" : null
|
||||
SiteName = (serverType == ServerType.HeliosNativeModule) ? "MusicStoreNativeModule" : null,
|
||||
EnvironmentName = "SocialTesting"
|
||||
};
|
||||
|
||||
var testStartTime = DateTime.Now;
|
||||
|
|
@ -135,6 +136,15 @@ namespace E2ETests
|
|||
//Logout from this user session - This should take back to the home page
|
||||
SignOutUser("Administrator");
|
||||
|
||||
//Google login
|
||||
LoginWithGoogle();
|
||||
|
||||
//Facebook login
|
||||
LoginWithFacebook();
|
||||
|
||||
//Twitter login
|
||||
LoginWithTwitter();
|
||||
|
||||
var testCompletionTime = DateTime.Now;
|
||||
Console.WriteLine("[Time]: All tests completed in '{0}' seconds", (testCompletionTime - initializationCompleteTime).TotalSeconds);
|
||||
Console.WriteLine("[Time]: Total time taken for this test variation '{0}' seconds", (testCompletionTime - testStartTime).TotalSeconds);
|
||||
|
|
|
|||
|
|
@ -55,10 +55,34 @@ namespace E2ETests
|
|||
|
||||
//Post a message to the Facebook middleware
|
||||
response = httpClient.GetAsync("signin-twitter?oauth_token=valid_oauth_token&oauth_verifier=valid_oauth_verifier").Result;
|
||||
//This should land us in ExternalLoginCallBack - this action is not implemented yet. We need to wait to complete automation.
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
//Correlation cookie not getting cleared after successful signin?
|
||||
//Assert.Null(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl))["__TwitterState"]);
|
||||
Assert.Equal(ApplicationBaseUrl + "Account/ExternalLoginCallback?ReturnUrl=%2F", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||
//Twitter does not give back the email claim for some reason.
|
||||
//Assert.Contains("AspnetvnextTest@gmail.com", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
formParameters = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("Email", "twitter@test.com"),
|
||||
new KeyValuePair<string, string>("__RequestVerificationToken", HtmlDOMHelper.RetrieveAntiForgeryToken(responseContent, "/Account/ExternalLoginConfirmation?ReturnUrl=%2F")),
|
||||
};
|
||||
|
||||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||
response = httpClient.PostAsync("Account/ExternalLoginConfirmation", content).Result;
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
Assert.Contains(string.Format("Hello {0}!", "twitter@test.com"), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("Log off", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
//Verify cookie sent
|
||||
Assert.NotNull(httpClientHandler.CookieContainer.GetCookies(new Uri(ApplicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
|
||||
|
||||
//https://github.com/aspnet/Identity/issues/210
|
||||
//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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue