diff --git a/test/E2ETests/compiler/shared/Mocks/Facebook/FacebookNotifications.cs b/test/E2ETests/compiler/shared/Mocks/Facebook/FacebookNotifications.cs index 2dce0c25c5..2beeb92ac4 100644 --- a/test/E2ETests/compiler/shared/Mocks/Facebook/FacebookNotifications.cs +++ b/test/E2ETests/compiler/shared/Mocks/Facebook/FacebookNotifications.cs @@ -15,17 +15,17 @@ namespace MusicStore.Mocks.Facebook /// internal class FacebookNotifications { - internal static async Task OnAuthenticated(FacebookAuthenticatedContext context) + internal static async Task OnAuthenticated(OAuthAuthenticatedContext context) { if (context.Principal != null) { Helpers.ThrowIfConditionFailed(() => context.AccessToken == "ValidAccessToken", ""); - 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", ""); - Helpers.ThrowIfConditionFailed(() => context.UserName == "AspnetvnextTest.AspnetvnextTest.7", ""); - Helpers.ThrowIfConditionFailed(() => context.User.SelectToken("id").ToString() == context.Id, ""); + Helpers.ThrowIfConditionFailed(() => FacebookAuthenticationHelper.GetEmail(context.User) == "AspnetvnextTest@test.com", ""); + Helpers.ThrowIfConditionFailed(() => FacebookAuthenticationHelper.GetId(context.User) == "Id", ""); + Helpers.ThrowIfConditionFailed(() => FacebookAuthenticationHelper.GetLink(context.User) == "https://www.facebook.com/myLink", ""); + Helpers.ThrowIfConditionFailed(() => FacebookAuthenticationHelper.GetName(context.User) == "AspnetvnextTest AspnetvnextTest", ""); + Helpers.ThrowIfConditionFailed(() => FacebookAuthenticationHelper.GetUserName(context.User) == "AspnetvnextTest.AspnetvnextTest.7", ""); + Helpers.ThrowIfConditionFailed(() => context.User.SelectToken("id").ToString() == FacebookAuthenticationHelper.GetId(context.User), ""); Helpers.ThrowIfConditionFailed(() => context.ExpiresIn.Value == TimeSpan.FromSeconds(100), ""); Helpers.ThrowIfConditionFailed(() => context.AccessToken == "ValidAccessToken", ""); context.Principal.Identities.First().AddClaim(new Claim("ManageStore", "false")); diff --git a/test/E2ETests/compiler/shared/Mocks/Google/GoogleNotifications.cs b/test/E2ETests/compiler/shared/Mocks/Google/GoogleNotifications.cs index 1903a79d77..ceca1473a0 100644 --- a/test/E2ETests/compiler/shared/Mocks/Google/GoogleNotifications.cs +++ b/test/E2ETests/compiler/shared/Mocks/Google/GoogleNotifications.cs @@ -15,16 +15,16 @@ namespace MusicStore.Mocks.Google /// internal class GoogleNotifications { - internal static async Task OnAuthenticated(GoogleAuthenticatedContext context) + internal static async Task OnAuthenticated(OAuthAuthenticatedContext context) { if (context.Principal != null) { Helpers.ThrowIfConditionFailed(() => context.AccessToken == "ValidAccessToken", "Access token is not valid"); Helpers.ThrowIfConditionFailed(() => context.RefreshToken == "ValidRefreshToken", "Refresh token is not valid"); - Helpers.ThrowIfConditionFailed(() => context.Email == "AspnetvnextTest@gmail.com", "Email is not valid"); - Helpers.ThrowIfConditionFailed(() => context.Id == "106790274378320830963", "Id is not valid"); - Helpers.ThrowIfConditionFailed(() => context.FamilyName == "AspnetvnextTest", "FamilyName is not valid"); - Helpers.ThrowIfConditionFailed(() => context.Name == "AspnetvnextTest AspnetvnextTest", "Name is not valid"); + Helpers.ThrowIfConditionFailed(() => GoogleAuthenticationHelper.GetEmail(context.User) == "AspnetvnextTest@gmail.com", "Email is not valid"); + Helpers.ThrowIfConditionFailed(() => GoogleAuthenticationHelper.GetId(context.User) == "106790274378320830963", "Id is not valid"); + Helpers.ThrowIfConditionFailed(() => GoogleAuthenticationHelper.GetFamilyName(context.User) == "AspnetvnextTest", "FamilyName is not valid"); + Helpers.ThrowIfConditionFailed(() => GoogleAuthenticationHelper.GetName(context.User) == "AspnetvnextTest AspnetvnextTest", "Name is not valid"); Helpers.ThrowIfConditionFailed(() => context.ExpiresIn.Value == TimeSpan.FromSeconds(1200), "ExpiresIn is not valid"); Helpers.ThrowIfConditionFailed(() => context.User != null, "User object is not valid"); context.Principal.Identities.First().AddClaim(new Claim("ManageStore", "false")); diff --git a/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/MicrosoftAccountNotifications.cs b/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/MicrosoftAccountNotifications.cs index ed5afba311..7cec2fb475 100644 --- a/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/MicrosoftAccountNotifications.cs +++ b/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/MicrosoftAccountNotifications.cs @@ -15,19 +15,19 @@ namespace MusicStore.Mocks.MicrosoftAccount /// internal class MicrosoftAccountNotifications { - internal static async Task OnAuthenticated(MicrosoftAccountAuthenticatedContext context) + internal static async Task OnAuthenticated(OAuthAuthenticatedContext context) { if (context.Principal != null) { Helpers.ThrowIfConditionFailed(() => context.AccessToken == "ValidAccessToken", "Access token is not valid"); Helpers.ThrowIfConditionFailed(() => context.RefreshToken == "ValidRefreshToken", "Refresh token is not valid"); - Helpers.ThrowIfConditionFailed(() => context.FirstName == "AspnetvnextTest", "Email is not valid"); - Helpers.ThrowIfConditionFailed(() => context.LastName == "AspnetvnextTest", "Email is not valid"); - Helpers.ThrowIfConditionFailed(() => context.Id == "fccf9a24999f4f4f", "Id is not valid"); - Helpers.ThrowIfConditionFailed(() => context.Name == "AspnetvnextTest AspnetvnextTest", "Name is not valid"); + Helpers.ThrowIfConditionFailed(() => MicrosoftAccountAuthenticationHelper.GetFirstName(context.User) == "AspnetvnextTest", "Email is not valid"); + Helpers.ThrowIfConditionFailed(() => MicrosoftAccountAuthenticationHelper.GetLastName(context.User) == "AspnetvnextTest", "Email is not valid"); + Helpers.ThrowIfConditionFailed(() => MicrosoftAccountAuthenticationHelper.GetId(context.User) == "fccf9a24999f4f4f", "Id is not valid"); + Helpers.ThrowIfConditionFailed(() => MicrosoftAccountAuthenticationHelper.GetName(context.User) == "AspnetvnextTest AspnetvnextTest", "Name is not valid"); Helpers.ThrowIfConditionFailed(() => context.ExpiresIn.Value == TimeSpan.FromSeconds(3600), "ExpiresIn is not valid"); Helpers.ThrowIfConditionFailed(() => context.User != null, "User object is not valid"); - Helpers.ThrowIfConditionFailed(() => context.Id == context.User.SelectToken("id").ToString(), "User id is not valid"); + Helpers.ThrowIfConditionFailed(() => MicrosoftAccountAuthenticationHelper.GetId(context.User) == context.User.SelectToken("id").ToString(), "User id is not valid"); context.Principal.Identities.First().AddClaim(new Claim("ManageStore", "false")); } diff --git a/test/E2ETests/compiler/shared/Mocks/OpenIdConnect/OpenIdConnectNotifications.cs b/test/E2ETests/compiler/shared/Mocks/OpenIdConnect/OpenIdConnectNotifications.cs index a6c461d624..c416492272 100644 --- a/test/E2ETests/compiler/shared/Mocks/OpenIdConnect/OpenIdConnectNotifications.cs +++ b/test/E2ETests/compiler/shared/Mocks/OpenIdConnect/OpenIdConnectNotifications.cs @@ -14,30 +14,30 @@ namespace MusicStore.Mocks.OpenIdConnect { private static List notificationsFired = new List(); - internal static async Task MessageReceived(MessageReceivedNotification context) + internal static Task MessageReceived(MessageReceivedNotification context) { Helpers.ThrowIfConditionFailed(() => context.ProtocolMessage != null, "ProtocolMessage is null."); notificationsFired.Add(nameof(MessageReceived)); - await Task.FromResult(0); + return Task.FromResult(0); } - internal static async Task SecurityTokenReceived(SecurityTokenReceivedNotification context) + internal static Task SecurityTokenReceived(SecurityTokenReceivedNotification context) { notificationsFired.Add(nameof(SecurityTokenReceived)); - await Task.FromResult(0); + return Task.FromResult(0); } - internal static async Task SecurityTokenValidated(SecurityTokenValidatedNotification context) + internal static Task SecurityTokenValidated(SecurityTokenValidatedNotification context) { Helpers.ThrowIfConditionFailed(() => context.AuthenticationTicket != null, "context.AuthenticationTicket is null."); Helpers.ThrowIfConditionFailed(() => context.AuthenticationTicket.Principal != null, "context.AuthenticationTicket.Principal is null."); Helpers.ThrowIfConditionFailed(() => context.AuthenticationTicket.Principal.Identity != null, "context.AuthenticationTicket.Principal.Identity is null."); Helpers.ThrowIfConditionFailed(() => !string.IsNullOrWhiteSpace(context.AuthenticationTicket.Principal.Identity.Name), "context.AuthenticationTicket.Principal.Identity.Name is null."); notificationsFired.Add(nameof(SecurityTokenValidated)); - await Task.FromResult(0); + return Task.FromResult(0); } - internal static async Task AuthorizationCodeReceived(AuthorizationCodeReceivedNotification context) + internal static Task AuthorizationCodeReceived(AuthorizationCodeReceivedNotification context) { Helpers.ThrowIfConditionFailed(() => context.Code == "AAABAAAAvPM1KaPlrEqdFSBzjqfTGGBtrTYVn589oKw4lLgJ6Svz0AhPVOJr0J2-Uu_KffGlqIbYlRAyxmt-vZ7VlSVdrWvOkNhK9OaAMaSD7LDoPbBTVMEkB0MdAgBTV34l2el-s8ZI02_9PvgQaORZs7n8eGaGbcoKAoxiDn2OcKuJVplXYgrGUwU4VpRaqe6RaNzuseM7qBFbLIv4Wps8CndE6W8ccmuu6EvGC6-H4uF9EZL7gU4nEcTcvkE4Qyt8do6VhTVfM1ygRNQgmV1BCig5t_5xfhL6-xWQdy15Uzn_Df8VSsyDXe8s9cxyKlqc_AIyLFy_NEiMQFUqjZWKd_rR3A8ugug15SEEGuo1kF3jMc7dVMdE6OF9UBd-Ax5ILWT7V4clnRQb6-CXB538DlolREfE-PowXYruFBA-ARD6rwAVtuVfCSbS0Zr4ZqfNjt6x8yQdK-OkdQRZ1thiZcZlm1lyb2EquGZ8Deh2iWBoY1uNcyjzhG-L43EivxtHAp6Y8cErhbo41iacgqOycgyJWxiB5J0HHkxD0nQ2RVVuY8Ybc9sdgyfKkkK2wZ3idGaRCdZN8Q9VBhWRXPDMqHWG8t3aZRtvJ_Xd3WhjNPJC0GpepUGNNQtXiEoIECC363o1z6PZC5-E7U3l9xK06BZkcfTOnggUiSWNCrxUKS44dNqaozdYlO5E028UgAEhJ4eDtcP3PZty-0j4j5Mw0F2FmyAA", "context.Code is invalid."); @@ -53,10 +53,10 @@ namespace MusicStore.Mocks.OpenIdConnect ((ClaimsIdentity)context.AuthenticationTicket.Principal.Identity).AddClaim(new Claim("ManageStore", "Allowed")); } - await Task.FromResult(0); + return Task.FromResult(0); } - internal static async Task RedirectToIdentityProvider + internal static Task RedirectToIdentityProvider (RedirectToIdentityProviderNotification context) { notificationsFired.Add(nameof(RedirectToIdentityProvider)); @@ -67,7 +67,7 @@ namespace MusicStore.Mocks.OpenIdConnect context.Request.Scheme + "://" + context.Request.Host + context.Request.PathBase + new PathString("/Account/Login"); } - await Task.FromResult(0); + return Task.FromResult(0); } } } diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index 292dc236e7..bb7c274f73 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.Facebook; using Microsoft.AspNet.Authentication.Google; using Microsoft.AspNet.Authentication.MicrosoftAccount; +using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authentication.Twitter; using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Builder; @@ -85,7 +86,7 @@ namespace MusicStore { options.AppId = "[AppId]"; options.AppSecret = "[AppSecret]"; - options.Notifications = new FacebookAuthenticationNotifications() + options.Notifications = new OAuthAuthenticationNotifications() { OnAuthenticated = FacebookNotifications.OnAuthenticated, OnReturnEndpoint = FacebookNotifications.OnReturnEndpoint, @@ -103,7 +104,7 @@ namespace MusicStore options.ClientId = "[ClientId]"; options.ClientSecret = "[ClientSecret]"; options.AccessType = "offline"; - options.Notifications = new GoogleAuthenticationNotifications() + options.Notifications = new OAuthAuthenticationNotifications() { OnAuthenticated = GoogleNotifications.OnAuthenticated, OnReturnEndpoint = GoogleNotifications.OnReturnEndpoint,