From 26a7c7016db3b83dfcc7aab4ccfa25fc9e21a850 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 11 Aug 2016 10:15:07 -0700 Subject: [PATCH] Minor updates to CookieAuthenticationHandler and its tests 1. Remove unnecessary variable declaration. 2. Update test name to a more accurate description. --- .../CookieAuthenticationHandler.cs | 7 ++----- .../Cookies/CookieMiddlewareTests.cs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index ff77815ce4..9b45738756 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; -using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies @@ -314,8 +313,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { - CookieRedirectContext redirectContext = null; - // set redirect uri in order: // 1. properties.RedirectUri // 2. query parameter ReturnUrlParameter @@ -331,8 +328,8 @@ namespace Microsoft.AspNetCore.Authentication.Cookies if (redirectUri != null) { - redirectContext = new CookieRedirectContext(Context, Options, redirectUri, properties); - await Options.Events.RedirectToReturnUrl(redirectContext); + await Options.Events.RedirectToReturnUrl( + new CookieRedirectContext(Context, Options, redirectUri, properties)); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 4a4d19a021..942b1c4a5f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -1100,7 +1100,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } [Fact] - public async Task AbsoluteRedirectUriIsRejected() + public async Task AbsoluteRedirectUriInQueryStringIsRejected() { var options = new CookieAuthenticationOptions {