From 3780a475283c45c79fd0d4363312e59d482fb09a Mon Sep 17 00:00:00 2001 From: Chris R Date: Sun, 24 Jan 2016 19:21:40 -0800 Subject: [PATCH] Fix tests broken by renames. --- .../Cookies/CookieMiddlewareTests.cs | 8 +++---- .../Facebook/FacebookMiddlewareTests.cs | 2 +- .../Google/GoogleMiddlewareTests.cs | 22 +++++++++---------- .../MicrosoftAccountMiddlewareTests.cs | 4 ++-- .../OpenIdConnectMiddlewareTests.cs | 2 +- .../Transaction.cs | 2 +- .../Transaction.cs | 2 +- .../CookieInteropTests.cs | 20 ++++++++++------- .../TicketInteropTests.cs | 4 ++-- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs index 158c480516..785d5bfa62 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Cookies/CookieMiddlewareTests.cs @@ -438,7 +438,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction1 = await SendAsync(server, "http://example.com/testpath"); var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); - Assert.Contains(".AspNet.Cookies=; expires=", transaction2.SetCookie); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction2.SetCookie); Assert.Null(FindClaimValue(transaction2, ClaimTypes.Name)); } @@ -913,7 +913,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith(".AspNet.Cookies=")); + Assert.True(transaction.SetCookie[0].StartsWith(".AspNetCore.Cookies=")); } [Fact] @@ -979,7 +979,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.Contains(".AspNet.Cookies=; expires=", transaction.SetCookie[0]); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction.SetCookie[0]); } [Fact] @@ -1000,7 +1000,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Contains(".AspNet.Cookies=; expires=", transaction.SetCookie[0]); + Assert.Contains(".AspNetCore.Cookies=; expires=", transaction.SetCookie[0]); var location = transaction.Response.Headers.Location; Assert.Equal("/page", location.OriginalString); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index fa2bed53fd..aadb62f51b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook }, handler: null); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Facebook"; + var correlationKey = ".AspNetCore.Correlation.Facebook"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs index 7daec9863b..854c49ce97 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Authentication.Google ClientSecret = "Test Secret" }); var transaction = await server.SendAsync("https://example.com/challenge"); - Assert.Contains(".AspNet.Correlation.Google=", transaction.SetCookie.Single()); + Assert.Contains(".AspNetCore.Correlation.Google=", transaction.SetCookie.Single()); } [Fact] @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.Google AutomaticChallenge = true }); var transaction = await server.SendAsync("https://example.com/401"); - Assert.Contains(".AspNet.Correlation.Google=", transaction.SetCookie.Single()); + Assert.Contains(".AspNetCore.Correlation.Google=", transaction.SetCookie.Single()); } [Fact] @@ -335,7 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -347,7 +347,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/me", authCookie); @@ -394,7 +394,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } : new OAuthEvents() }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -446,7 +446,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } : new OAuthEvents() }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -528,7 +528,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -540,7 +540,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/me", authCookie); @@ -607,7 +607,7 @@ namespace Microsoft.AspNetCore.Authentication.Google } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); var state = stateFormat.Protect(properties); @@ -618,7 +618,7 @@ namespace Microsoft.AspNetCore.Authentication.Google Assert.Equal("/", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); } [Fact] @@ -690,7 +690,7 @@ namespace Microsoft.AspNetCore.Authentication.Google }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Google"; + var correlationKey = ".AspNetCore.Correlation.Google"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/foo"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index f80ee21229..2aad3cfef7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount } }); var properties = new AuthenticationProperties(); - var correlationKey = ".AspNet.Correlation.Microsoft"; + var correlationKey = ".AspNetCore.Correlation.Microsoft"; var correlationValue = "TestCorrelationId"; properties.Items.Add(correlationKey, correlationValue); properties.RedirectUri = "/me"; @@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal(2, transaction.SetCookie.Count); Assert.Contains(correlationKey, transaction.SetCookie[0]); - Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); + Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/me", authCookie); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index 4c95083d57..040812d88b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -486,7 +486,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect { if (SetCookie != null && SetCookie.Count > 0) { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNet.Cookie=")); + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore.Cookie=")); if (authCookie != null) { return authCookie.Substring(0, authCookie.IndexOf(';')); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs index 56058b850f..63f8af1bb2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/Transaction.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Authentication { if (SetCookie != null && SetCookie.Count > 0) { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme + "=")); + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme + "=")); if (authCookie != null) { return authCookie.Substring(0, authCookie.IndexOf(';')); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs index 25457e991d..040e0b3391 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Transaction.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.CookiePolicy { if (SetCookie != null && SetCookie.Count > 0) { - var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme + "=")); + var authCookie = SetCookie.SingleOrDefault(c => c.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme + "=")); if (authCookie != null) { return authCookie.Substring(0, authCookie.IndexOf(';')); diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index 08df190117..ef80b78e6e 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -24,7 +24,7 @@ namespace Microsoft.Owin.Security.Interop public class CookiesInteropTests { [Fact] - public async Task AspNet5WithInteropCookieContainsIdentity() + public async Task AspNetCoreWithInteropCookieContainsIdentity() { var identity = new ClaimsIdentity("Cookies"); identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); @@ -40,7 +40,9 @@ namespace Microsoft.Owin.Security.Interop app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, }); app.Run(context => @@ -55,7 +57,7 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions { DataProtectionProvider = dataProtection }); @@ -66,7 +68,7 @@ namespace Microsoft.Owin.Security.Interop }); }) .ConfigureServices(services => services.AddAuthentication()); - var newServer = new AspNet.TestHost.TestServer(builder); + var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First()); @@ -91,14 +93,14 @@ namespace Microsoft.Owin.Security.Interop var builder = new WebHostBuilder() .Configure(app => { - app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions + app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions { DataProtectionProvider = dataProtection }); app.Run(context => context.Authentication.SignInAsync("Cookies", user)); }) .ConfigureServices(services => services.AddAuthentication()); - var newServer = new AspNet.TestHost.TestServer(builder); + var newServer = new AspNetCore.TestHost.TestServer(builder); var cookie = await SendAndGetCookie(newServer, "http://example.com/login"); @@ -108,7 +110,9 @@ namespace Microsoft.Owin.Security.Interop app.UseCookieAuthentication(new Owin.Security.Cookies.CookieAuthenticationOptions { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)) + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, }); app.Run(async context => @@ -123,7 +127,7 @@ namespace Microsoft.Owin.Security.Interop Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); } - private static async Task SendAndGetCookie(AspNet.TestHost.TestServer server, string uri) + private static async Task SendAndGetCookie(AspNetCore.TestHost.TestServer server, string uri) { var request = new HttpRequestMessage(HttpMethod.Get, uri); var response = await server.CreateClient().SendAsync(request); diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index 06073e8b72..7b2d261bbf 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -58,14 +58,14 @@ namespace Microsoft.Owin.Security.Interop.Test var expires = DateTime.Today; var issued = new DateTime(1979, 11, 11); - var properties = new AspNet.Http.Authentication.AuthenticationProperties(); + var properties = new AspNetCore.Http.Authentication.AuthenticationProperties(); properties.IsPersistent = true; properties.RedirectUri = "/redirect"; properties.Items["key"] = "value"; properties.ExpiresUtc = expires; properties.IssuedUtc = issued; - var newTicket = new AspNet.Authentication.AuthenticationTicket(user, properties, "scheme"); + var newTicket = new AspNetCore.Authentication.AuthenticationTicket(user, properties, "scheme"); var newSerializer = new TicketSerializer(); var bytes = newSerializer.Serialize(newTicket);