Fix tests broken by renames.
This commit is contained in:
parent
0c6a805405
commit
3780a47528
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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(';'));
|
||||
|
|
|
|||
|
|
@ -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(';'));
|
||||
|
|
|
|||
|
|
@ -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(';'));
|
||||
|
|
|
|||
|
|
@ -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<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 response = await server.CreateClient().SendAsync(request);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue