Fixing some issues with OpenIdconnect E2E test
1. Adding notifications and verification for them.
This commit is contained in:
parent
3ec5584c8c
commit
4f32cb95fa
|
|
@ -89,13 +89,12 @@ namespace E2ETests
|
|||
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.ExternalLogin"));
|
||||
_logger.WriteInformation("Successfully signed in with user '{0}'", "User3@aspnettest.onmicrosoft.com");
|
||||
|
||||
//_logger.WriteInformation("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;
|
||||
////This action requires admin permissions. If notifications are fired this permission is granted
|
||||
//Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
//_logger.WriteInformation("Middleware notifications were fired successfully");
|
||||
Console.ReadLine();
|
||||
_logger.WriteInformation("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;
|
||||
//This action requires admin permissions. If notifications are fired this permission is granted
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
_logger.WriteInformation("Middleware notifications were fired successfully");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Security.Notifications;
|
||||
|
|
@ -39,8 +38,6 @@ namespace MusicStore.Mocks.OpenIdConnect
|
|||
|
||||
internal static async Task AuthorizationCodeReceived(AuthorizationCodeReceivedNotification context)
|
||||
{
|
||||
Debugger.Launch();
|
||||
|
||||
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.");
|
||||
notificationsFired.Add(nameof(AuthorizationCodeReceived));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNet.Diagnostics;
|
|||
using Microsoft.AspNet.Diagnostics.Entity;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Security;
|
||||
using Microsoft.AspNet.Security.OpenIdConnect;
|
||||
using Microsoft.Framework.Cache.Memory;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
|
@ -113,18 +114,16 @@ namespace MusicStore
|
|||
options.TokenValidationParameters.ValidateLifetime = false;
|
||||
options.ProtocolValidator.RequireNonce = true;
|
||||
options.ProtocolValidator.NonceLifetime = TimeSpan.FromDays(36500);
|
||||
options.UseTokenLifetime = false;
|
||||
|
||||
if (options.Notifications == null)
|
||||
options.Notifications = new OpenIdConnectAuthenticationNotifications
|
||||
{
|
||||
// Bug: Notifications should be instantiated.
|
||||
options.Notifications = new Microsoft.AspNet.Security.OpenIdConnect.OpenIdConnectAuthenticationNotifications();
|
||||
}
|
||||
|
||||
options.Notifications.MessageReceived = OpenIdConnectNotifications.MessageReceived;
|
||||
options.Notifications.AuthorizationCodeReceived = OpenIdConnectNotifications.AuthorizationCodeReceived;
|
||||
options.Notifications.RedirectToIdentityProvider = OpenIdConnectNotifications.RedirectToIdentityProvider;
|
||||
options.Notifications.SecurityTokenReceived = OpenIdConnectNotifications.SecurityTokenReceived;
|
||||
options.Notifications.SecurityTokenValidated = OpenIdConnectNotifications.SecurityTokenValidated;
|
||||
MessageReceived = OpenIdConnectNotifications.MessageReceived,
|
||||
AuthorizationCodeReceived = OpenIdConnectNotifications.AuthorizationCodeReceived,
|
||||
RedirectToIdentityProvider = OpenIdConnectNotifications.RedirectToIdentityProvider,
|
||||
SecurityTokenReceived = OpenIdConnectNotifications.SecurityTokenReceived,
|
||||
SecurityTokenValidated = OpenIdConnectNotifications.SecurityTokenValidated
|
||||
};
|
||||
});
|
||||
|
||||
// Add MVC to the request pipeline
|
||||
|
|
|
|||
Loading…
Reference in New Issue