Fix tests broken by renames.

This commit is contained in:
Chris R 2016-01-24 19:21:40 -08:00
parent 0c6a805405
commit 3780a47528
9 changed files with 35 additions and 31 deletions

View File

@ -438,7 +438,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
var transaction1 = await SendAsync(server, "http://example.com/testpath"); var transaction1 = await SendAsync(server, "http://example.com/testpath");
var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); 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)); Assert.Null(FindClaimValue(transaction2, ClaimTypes.Name));
} }
@ -913,7 +913,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
var transaction = await server.SendAsync("http://example.com"); var transaction = await server.SendAsync("http://example.com");
Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode);
Assert.True(transaction.SetCookie[0].StartsWith(".AspNet.Cookies=")); Assert.True(transaction.SetCookie[0].StartsWith(".AspNetCore.Cookies="));
} }
[Fact] [Fact]
@ -979,7 +979,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage");
Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode);
Assert.Contains(".AspNet.Cookies=; expires=", transaction.SetCookie[0]); Assert.Contains(".AspNetCore.Cookies=; expires=", transaction.SetCookie[0]);
} }
[Fact] [Fact]
@ -1000,7 +1000,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); 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; var location = transaction.Response.Headers.Location;
Assert.Equal("/page", location.OriginalString); Assert.Equal("/page", location.OriginalString);

View File

@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
}, handler: null); }, handler: null);
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Facebook"; var correlationKey = ".AspNetCore.Correlation.Facebook";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/me"; properties.RedirectUri = "/me";

View File

@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
ClientSecret = "Test Secret" ClientSecret = "Test Secret"
}); });
var transaction = await server.SendAsync("https://example.com/challenge"); 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] [Fact]
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
AutomaticChallenge = true AutomaticChallenge = true
}); });
var transaction = await server.SendAsync("https://example.com/401"); 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] [Fact]
@ -335,7 +335,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
} }
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Google"; var correlationKey = ".AspNetCore.Correlation.Google";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/me"; properties.RedirectUri = "/me";
@ -347,7 +347,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
Assert.Equal(2, transaction.SetCookie.Count); Assert.Equal(2, transaction.SetCookie.Count);
Assert.Contains(correlationKey, transaction.SetCookie[0]); 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; var authCookie = transaction.AuthenticationCookieValue;
transaction = await server.SendAsync("https://example.com/me", authCookie); transaction = await server.SendAsync("https://example.com/me", authCookie);
@ -394,7 +394,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
} : new OAuthEvents() } : new OAuthEvents()
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Google"; var correlationKey = ".AspNetCore.Correlation.Google";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/me"; properties.RedirectUri = "/me";
@ -446,7 +446,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
} : new OAuthEvents() } : new OAuthEvents()
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Google"; var correlationKey = ".AspNetCore.Correlation.Google";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/me"; properties.RedirectUri = "/me";
@ -528,7 +528,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
} }
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Google"; var correlationKey = ".AspNetCore.Correlation.Google";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/me"; properties.RedirectUri = "/me";
@ -540,7 +540,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
Assert.Equal(2, transaction.SetCookie.Count); Assert.Equal(2, transaction.SetCookie.Count);
Assert.Contains(correlationKey, transaction.SetCookie[0]); 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; var authCookie = transaction.AuthenticationCookieValue;
transaction = await server.SendAsync("https://example.com/me", authCookie); transaction = await server.SendAsync("https://example.com/me", authCookie);
@ -607,7 +607,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
} }
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Google"; var correlationKey = ".AspNetCore.Correlation.Google";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
var state = stateFormat.Protect(properties); var state = stateFormat.Protect(properties);
@ -618,7 +618,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
Assert.Equal("/", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal("/", transaction.Response.Headers.GetValues("Location").First());
Assert.Equal(2, transaction.SetCookie.Count); Assert.Equal(2, transaction.SetCookie.Count);
Assert.Contains(correlationKey, transaction.SetCookie[0]); Assert.Contains(correlationKey, transaction.SetCookie[0]);
Assert.Contains(".AspNet." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]);
} }
[Fact] [Fact]
@ -690,7 +690,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Google"; var correlationKey = ".AspNetCore.Correlation.Google";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/foo"; properties.RedirectUri = "/foo";

View File

@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
} }
}); });
var properties = new AuthenticationProperties(); var properties = new AuthenticationProperties();
var correlationKey = ".AspNet.Correlation.Microsoft"; var correlationKey = ".AspNetCore.Correlation.Microsoft";
var correlationValue = "TestCorrelationId"; var correlationValue = "TestCorrelationId";
properties.Items.Add(correlationKey, correlationValue); properties.Items.Add(correlationKey, correlationValue);
properties.RedirectUri = "/me"; properties.RedirectUri = "/me";
@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First());
Assert.Equal(2, transaction.SetCookie.Count); Assert.Equal(2, transaction.SetCookie.Count);
Assert.Contains(correlationKey, transaction.SetCookie[0]); 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; var authCookie = transaction.AuthenticationCookieValue;
transaction = await server.SendAsync("https://example.com/me", authCookie); transaction = await server.SendAsync("https://example.com/me", authCookie);

View File

@ -486,7 +486,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.OpenIdConnect
{ {
if (SetCookie != null && SetCookie.Count > 0) 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) if (authCookie != null)
{ {
return authCookie.Substring(0, authCookie.IndexOf(';')); return authCookie.Substring(0, authCookie.IndexOf(';'));

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Authentication
{ {
if (SetCookie != null && SetCookie.Count > 0) 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) if (authCookie != null)
{ {
return authCookie.Substring(0, authCookie.IndexOf(';')); return authCookie.Substring(0, authCookie.IndexOf(';'));

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.CookiePolicy
{ {
if (SetCookie != null && SetCookie.Count > 0) 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) if (authCookie != null)
{ {
return authCookie.Substring(0, authCookie.IndexOf(';')); return authCookie.Substring(0, authCookie.IndexOf(';'));

View File

@ -24,7 +24,7 @@ namespace Microsoft.Owin.Security.Interop
public class CookiesInteropTests public class CookiesInteropTests
{ {
[Fact] [Fact]
public async Task AspNet5WithInteropCookieContainsIdentity() public async Task AspNetCoreWithInteropCookieContainsIdentity()
{ {
var identity = new ClaimsIdentity("Cookies"); var identity = new ClaimsIdentity("Cookies");
identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); identity.AddClaim(new Claim(ClaimTypes.Name, "Alice"));
@ -40,7 +40,9 @@ namespace Microsoft.Owin.Security.Interop
app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions 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 => app.Run(context =>
@ -55,7 +57,7 @@ namespace Microsoft.Owin.Security.Interop
var builder = new WebHostBuilder() var builder = new WebHostBuilder()
.Configure(app => .Configure(app =>
{ {
app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions
{ {
DataProtectionProvider = dataProtection DataProtectionProvider = dataProtection
}); });
@ -66,7 +68,7 @@ namespace Microsoft.Owin.Security.Interop
}); });
}) })
.ConfigureServices(services => services.AddAuthentication()); .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"); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login");
request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First()); request.Headers.Add("Cookie", transaction.SetCookie.Split(new[] { ';' }, 2).First());
@ -91,14 +93,14 @@ namespace Microsoft.Owin.Security.Interop
var builder = new WebHostBuilder() var builder = new WebHostBuilder()
.Configure(app => .Configure(app =>
{ {
app.UseCookieAuthentication(new AspNet.Builder.CookieAuthenticationOptions app.UseCookieAuthentication(new AspNetCore.Builder.CookieAuthenticationOptions
{ {
DataProtectionProvider = dataProtection DataProtectionProvider = dataProtection
}); });
app.Run(context => context.Authentication.SignInAsync("Cookies", user)); app.Run(context => context.Authentication.SignInAsync("Cookies", user));
}) })
.ConfigureServices(services => services.AddAuthentication()); .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"); 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 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 => app.Run(async context =>
@ -123,7 +127,7 @@ namespace Microsoft.Owin.Security.Interop
Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name));
} }
private static async Task<string> SendAndGetCookie(AspNet.TestHost.TestServer server, string uri) private static async Task<string> SendAndGetCookie(AspNetCore.TestHost.TestServer server, string uri)
{ {
var request = new HttpRequestMessage(HttpMethod.Get, uri); var request = new HttpRequestMessage(HttpMethod.Get, uri);
var response = await server.CreateClient().SendAsync(request); var response = await server.CreateClient().SendAsync(request);

View File

@ -58,14 +58,14 @@ namespace Microsoft.Owin.Security.Interop.Test
var expires = DateTime.Today; var expires = DateTime.Today;
var issued = new DateTime(1979, 11, 11); 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.IsPersistent = true;
properties.RedirectUri = "/redirect"; properties.RedirectUri = "/redirect";
properties.Items["key"] = "value"; properties.Items["key"] = "value";
properties.ExpiresUtc = expires; properties.ExpiresUtc = expires;
properties.IssuedUtc = issued; 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 newSerializer = new TicketSerializer();
var bytes = newSerializer.Serialize(newTicket); var bytes = newSerializer.Serialize(newTicket);