From 00f660b50d7b32639594598bcaa3f211a6e3a0a3 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 25 Mar 2016 16:10:46 -0700 Subject: [PATCH] React to OpenIdConnect event changes. --- .../OpenIdConnect/TestOpenIdConnectEvents.cs | 19 ++++++------------- shared/Mocks/StartupOpenIdConnectTesting.cs | 5 ++--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/shared/Mocks/OpenIdConnect/TestOpenIdConnectEvents.cs b/shared/Mocks/OpenIdConnect/TestOpenIdConnectEvents.cs index 87e6f7c9c8..0c6c04c9e9 100644 --- a/shared/Mocks/OpenIdConnect/TestOpenIdConnectEvents.cs +++ b/shared/Mocks/OpenIdConnect/TestOpenIdConnectEvents.cs @@ -20,19 +20,13 @@ namespace MusicStore.Mocks.OpenIdConnect return Task.FromResult(0); } - internal static Task AuthenticationValidated(AuthenticationValidatedContext context) - { - eventsFired.Add(nameof(AuthenticationValidated)); - return Task.FromResult(0); - } - - internal static Task AuthorizationResponseRecieved(AuthorizationResponseReceivedContext context) + internal static Task TokenValidated(TokenValidatedContext context) { Helpers.ThrowIfConditionFailed(() => context.Ticket != null, "context.Ticket is null."); Helpers.ThrowIfConditionFailed(() => context.Ticket.Principal != null, "context.Ticket.Principal is null."); Helpers.ThrowIfConditionFailed(() => context.Ticket.Principal.Identity != null, "context.Ticket.Principal.Identity is null."); Helpers.ThrowIfConditionFailed(() => !string.IsNullOrWhiteSpace(context.Ticket.Principal.Identity.Name), "context.Ticket.Principal.Identity.Name is null."); - eventsFired.Add(nameof(AuthorizationResponseRecieved)); + eventsFired.Add(nameof(TokenValidated)); return Task.FromResult(0); } @@ -43,10 +37,9 @@ namespace MusicStore.Mocks.OpenIdConnect eventsFired.Add(nameof(AuthorizationCodeReceived)); // Verify all events are fired. - if (eventsFired.Contains(nameof(RedirectToAuthenticationEndpoint)) && + if (eventsFired.Contains(nameof(RedirectToIdentityProvider)) && eventsFired.Contains(nameof(MessageReceived)) && - eventsFired.Contains(nameof(AuthenticationValidated)) && - eventsFired.Contains(nameof(AuthorizationResponseRecieved)) && + eventsFired.Contains(nameof(TokenValidated)) && eventsFired.Contains(nameof(AuthorizationCodeReceived))) { ((ClaimsIdentity)context.Ticket.Principal.Identity).AddClaim(new Claim("ManageStore", "Allowed")); @@ -55,9 +48,9 @@ namespace MusicStore.Mocks.OpenIdConnect return Task.FromResult(0); } - internal static Task RedirectToAuthenticationEndpoint(RedirectContext context) + internal static Task RedirectToIdentityProvider(RedirectContext context) { - eventsFired.Add(nameof(RedirectToAuthenticationEndpoint)); + eventsFired.Add(nameof(RedirectToIdentityProvider)); if (context.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest) { diff --git a/shared/Mocks/StartupOpenIdConnectTesting.cs b/shared/Mocks/StartupOpenIdConnectTesting.cs index 7bfbbf3d0b..602862817b 100644 --- a/shared/Mocks/StartupOpenIdConnectTesting.cs +++ b/shared/Mocks/StartupOpenIdConnectTesting.cs @@ -130,9 +130,8 @@ namespace MusicStore { OnMessageReceived = TestOpenIdConnectEvents.MessageReceived, OnAuthorizationCodeReceived = TestOpenIdConnectEvents.AuthorizationCodeReceived, - OnRedirectToAuthenticationEndpoint = TestOpenIdConnectEvents.RedirectToAuthenticationEndpoint, - OnAuthenticationValidated = TestOpenIdConnectEvents.AuthenticationValidated, - OnAuthorizationResponseReceived = TestOpenIdConnectEvents.AuthorizationResponseRecieved + OnRedirectToIdentityProvider = TestOpenIdConnectEvents.RedirectToIdentityProvider, + OnTokenValidated = TestOpenIdConnectEvents.TokenValidated, } }; options.TokenValidationParameters.ValidateLifetime = false;