Reacting to new Hosting API

This commit is contained in:
John Luo 2015-12-18 10:49:37 -08:00
parent 965a86e404
commit a041807023
29 changed files with 590 additions and 479 deletions

View File

@ -22,11 +22,6 @@
"environmentVariables": { "environmentVariables": {
"Hosting:Environment": "Development" "Hosting:Environment": "Development"
} }
},
"kestrel": {
"commandName": "kestrel",
"launchBrowser": true,
"launchUrl": "http://localhost:5004"
} }
} }
} }

View File

@ -2,6 +2,7 @@ using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -40,5 +41,15 @@ namespace CookieSample
await context.Response.WriteAsync("Hello old timer"); await context.Response.WriteAsync("Hello old timer");
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -4,12 +4,13 @@
"Microsoft.AspNet.DataProtection": "1.0.0-*", "Microsoft.AspNet.DataProtection": "1.0.0-*",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*" "Microsoft.Extensions.Logging.Console": "1.0.0-*"
}, },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": { "commands": {
"web": "Microsoft.AspNet.Server.Kestrel", "web": "CookieSample"
"weblistener": "Microsoft.AspNet.Server.WebListener"
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -22,11 +22,6 @@
"environmentVariables": { "environmentVariables": {
"Hosting:Environment": "Development" "Hosting:Environment": "Development"
} }
},
"kestrel": {
"commandName": "kestrel",
"launchBrowser": true,
"launchUrl": "http://localhost:5004"
} }
} }
} }

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -50,5 +51,15 @@ namespace CookieSessionSample
await context.Response.WriteAsync("Hello old timer"); await context.Response.WriteAsync("Hello old timer");
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -4,13 +4,14 @@
"Microsoft.AspNet.DataProtection": "1.0.0-*", "Microsoft.AspNet.DataProtection": "1.0.0-*",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Extensions.Caching.Memory": "1.0.0-*", "Microsoft.Extensions.Caching.Memory": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*" "Microsoft.Extensions.Logging.Console": "1.0.0-*"
}, },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": { "commands": {
"web": "Microsoft.AspNet.Server.Kestrel", "web": "CookieSessionSample"
"weblistener": "Microsoft.AspNet.Server.WebListener"
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -112,6 +112,14 @@ namespace JwtBearerSample
} }
// Entry point for the application. // Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args); public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -11,7 +11,7 @@
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*" "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*"
}, },
"commands": { "commands": {
"web": "Microsoft.AspNet.Server.Kestrel" "web": "JwtBearerSample"
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -15,17 +15,13 @@
"ASPNET_ENV": "Development" "ASPNET_ENV": "Development"
} }
}, },
"kestrel": {
"commandName": "kestrel",
"launchBrowser": true,
"launchUrl": "http://localhost:42023"
},
"web": { "web": {
"commandName": "web", "commandName": "web",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "http://localhost:42023", "launchUrl": "http://localhost:42023",
"environmentVariables": { "environmentVariables": {
"Hosting:Environment": "Development" "Hosting:Environment": "Development",
"ASPNET_server.urls": "http://localhost:42023"
} }
} }
} }

View File

@ -2,6 +2,7 @@ using System.Linq;
using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Authentication.OpenIdConnect;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -63,5 +64,15 @@ namespace OpenIdConnectSample
await context.Response.WriteAsync("Hello Authenticated User"); await context.Response.WriteAsync("Hello Authenticated User");
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -4,7 +4,6 @@
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*", "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*" "Microsoft.Extensions.Logging.Console": "1.0.0-*"
}, },
@ -12,10 +11,11 @@
"dnx451": { }, "dnx451": { },
"dnxcore50": { } "dnxcore50": { }
}, },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": { "commands": {
"web": "Microsoft.AspNet.Server.Kestrel", "web": "OpenIdConnectSample"
"kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:42023",
"weblistener": "Microsoft.AspNet.Server.WebListener --server.urls http://localhost:42023"
}, },
"userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318" "userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318"
} }

View File

@ -10,22 +10,17 @@
"profiles": { "profiles": {
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": { "environmentVariables": {
"ASPNET_ENV": "Development" "ASPNET_ENV": "Development"
} }
}, },
"kestrel": {
"commandName": "kestrel",
"launchBrowser": true,
"launchUrl": "http://localhost:54540/"
},
"web": { "web": {
"commandName": "web", "commandName": "web",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "http://localhost:54540/", "launchUrl": "http://localhost:54540/",
"environmentVariables": { "environmentVariables": {
"Hosting:Environment": "Development" "Hosting:Environment": "Development",
"ASPNET_server.urls": "http://localhost:54540/"
} }
} }
} }

View File

@ -12,6 +12,7 @@ using Microsoft.AspNet.Authentication.MicrosoftAccount;
using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authentication.OAuth;
using Microsoft.AspNet.Authentication.Twitter; using Microsoft.AspNet.Authentication.Twitter;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -160,7 +161,7 @@ namespace CookieSample
SaveTokensAsClaims = true SaveTokensAsClaims = true
}); });
// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets. //// You must first create an app with live.com and add it's ID and Secret to your config.json or user-secrets.
app.UseMicrosoftAccountAuthentication(options => app.UseMicrosoftAccountAuthentication(options =>
{ {
options.DisplayName = "MicrosoftAccount - Requires project changes"; options.DisplayName = "MicrosoftAccount - Requires project changes";
@ -323,5 +324,15 @@ namespace CookieSample
await context.Response.WriteAsync("</body></html>"); await context.Response.WriteAsync("</body></html>");
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -8,14 +8,14 @@
"Microsoft.AspNet.DataProtection": "1.0.0-*", "Microsoft.AspNet.DataProtection": "1.0.0-*",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*" "Microsoft.Extensions.Logging.Console": "1.0.0-*"
}, },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": { "commands": {
"web": "Microsoft.AspNet.Server.Kestrel", "web": "SocialSample"
"kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:54540",
"weblistener": "Microsoft.AspNet.Server.WebListener --server.urls=http://localhost:54540"
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.DataProtection;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.AspNet.Http.Features.Authentication;
@ -748,12 +749,14 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task MapWillNotAffectChallenge() public async Task MapWillNotAffectChallenge()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); app.UseCookieAuthentication(options => options.LoginPath = new PathString("/page"));
app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" })));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/login"); var transaction = await server.SendAsync("http://example.com/login");
@ -767,14 +770,17 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task ChallengeDoesNotSet401OnUnauthorized() public async Task ChallengeDoesNotSet401OnUnauthorized()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(); app.UseCookieAuthentication();
app.Run(async context => app.Run(async context =>
{ {
await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync()); await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync());
}); });
}, services => services.AddAuthentication()); })
.ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
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);
@ -783,12 +789,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task UseCookieWithInstanceDoesntUseSharedOptions() public async Task UseCookieWithInstanceDoesntUseSharedOptions()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.CookieName = "One"); app.UseCookieAuthentication(options => options.CookieName = "One");
app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity()))); app.Run(context => context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity())));
}, services => services.AddAuthentication()); })
.ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com"); var transaction = await server.SendAsync("http://example.com");
@ -799,13 +808,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login"));
app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies",
new ClaimsPrincipal()))); new ClaimsPrincipal())));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/notlogin?ReturnUrl=%2Fpage"); var transaction = await server.SendAsync("http://example.com/notlogin?ReturnUrl=%2Fpage");
Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode);
@ -815,13 +826,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task MapWillNotAffectSignInRedirectToReturnUrl() public async Task MapWillNotAffectSignInRedirectToReturnUrl()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login")); app.UseCookieAuthentication(options => options.LoginPath = new PathString("/login"));
app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies", app.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.SignInAsync("Cookies",
new ClaimsPrincipal()))); new ClaimsPrincipal())));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/login?ReturnUrl=%2Fpage"); var transaction = await server.SendAsync("http://example.com/login?ReturnUrl=%2Fpage");
@ -835,12 +848,14 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout"));
app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies")));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
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);
@ -850,12 +865,14 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task MapWillNotAffectSignOutRedirectToReturnUrl() public async Task MapWillNotAffectSignOutRedirectToReturnUrl()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout")); app.UseCookieAuthentication(options => options.LogoutPath = new PathString("/logout"));
app.Map("/logout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies"))); app.Map("/logout", signoutApp => signoutApp.Run(context => context.Authentication.SignOutAsync("Cookies")));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage");
@ -869,12 +886,14 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task MapWillNotAffectAccessDenied() public async Task MapWillNotAffectAccessDenied()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); app.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied"));
app.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); app.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies")));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/forbid"); var transaction = await server.SendAsync("http://example.com/forbid");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
@ -886,13 +905,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task NestedMapWillNotAffectLogin() public async Task NestedMapWillNotAffectLogin()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
app.Map("/base", map => app.Map("/base", map =>
{ {
map.UseCookieAuthentication(options => options.LoginPath = new PathString("/page")); map.UseCookieAuthentication(options => options.LoginPath = new PathString("/page"));
map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); map.Map("/login", signoutApp => signoutApp.Run(context => context.Authentication.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" })));
}), }))
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/base/login"); var transaction = await server.SendAsync("http://example.com/base/login");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
@ -905,13 +926,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact] [Fact]
public async Task NestedMapWillNotAffectAccessDenied() public async Task NestedMapWillNotAffectAccessDenied()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
app.Map("/base", map => app.Map("/base", map =>
{ {
map.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied")); map.UseCookieAuthentication(options => options.AccessDeniedPath = new PathString("/denied"));
map.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies"))); map.Map("/forbid", signoutApp => signoutApp.Run(context => context.Authentication.ForbidAsync("Cookies")));
}), }))
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/base/forbid"); var transaction = await server.SendAsync("http://example.com/base/forbid");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
@ -925,7 +948,8 @@ namespace Microsoft.AspNet.Authentication.Cookies
{ {
var dp = new NoOpDataProtector(); var dp = new NoOpDataProtector();
var server1 = TestServer.Create(app => var builder1 = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => app.UseCookieAuthentication(options =>
{ {
@ -936,13 +960,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
context.Authentication.SignInAsync("Cookies", context.Authentication.SignInAsync("Cookies",
new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))),
new AuthenticationProperties())); new AuthenticationProperties()));
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server1 = new TestServer(builder1);
var transaction = await SendAsync(server1, "http://example.com/stuff"); var transaction = await SendAsync(server1, "http://example.com/stuff");
Assert.NotNull(transaction.SetCookie); Assert.NotNull(transaction.SetCookie);
var server2 = TestServer.Create(app => var builder2 = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => app.UseCookieAuthentication(options =>
{ {
@ -956,8 +982,9 @@ namespace Microsoft.AspNet.Authentication.Cookies
await context.Authentication.AuthenticateAsync(authContext); await context.Authentication.AuthenticateAsync(authContext);
Describe(context.Response, authContext); Describe(context.Response, authContext);
}); });
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server2 = new TestServer(builder2);
var transaction2 = await SendAsync(server2, "http://example.com/stuff", transaction.CookieNameValue); var transaction2 = await SendAsync(server2, "http://example.com/stuff", transaction.CookieNameValue);
Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name));
} }
@ -1003,7 +1030,8 @@ namespace Microsoft.AspNet.Authentication.Cookies
private static TestServer CreateServer(Action<CookieAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null, Uri baseAddress = null, Action<ClaimsTransformationOptions> claimsTransform = null) private static TestServer CreateServer(Action<CookieAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null, Uri baseAddress = null, Action<ClaimsTransformationOptions> claimsTransform = null)
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(configureOptions); app.UseCookieAuthentication(configureOptions);
// app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" }); // app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookie2" });
@ -1066,8 +1094,9 @@ namespace Microsoft.AspNet.Authentication.Cookies
await next(); await next();
} }
}); });
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
var server = new TestServer(builder);
server.BaseAddress = baseAddress; server.BaseAddress = baseAddress;
return server; return server;
} }

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
@ -13,6 +12,7 @@ using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authentication.OAuth;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.DataProtection;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
@ -226,7 +226,8 @@ namespace Microsoft.AspNet.Authentication.Facebook
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Action<IServiceCollection> configureServices, Func<HttpContext, bool> handler) private static TestServer CreateServer(Action<IApplicationBuilder> configure, Action<IServiceCollection> configureServices, Func<HttpContext, bool> handler)
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
if (configure != null) if (configure != null)
{ {
@ -239,8 +240,9 @@ namespace Microsoft.AspNet.Authentication.Facebook
await next(); await next();
} }
}); });
}, })
configureServices); .ConfigureServices(configureServices);
return new TestServer(builder);
} }
} }
} }

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authentication.OAuth;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.DataProtection;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.AspNet.Http.Features.Authentication;
@ -765,7 +766,8 @@ namespace Microsoft.AspNet.Authentication.Google
private static TestServer CreateServer(Action<GoogleOptions> configureOptions, Func<HttpContext, Task> testpath = null) private static TestServer CreateServer(Action<GoogleOptions> configureOptions, Func<HttpContext, Task> testpath = null)
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => app.UseCookieAuthentication(options =>
{ {
@ -828,11 +830,12 @@ namespace Microsoft.AspNet.Authentication.Google
await next(); await next();
} }
}); });
}, })
services => .ConfigureServices(services =>
{ {
services.AddAuthentication(options => options.SignInScheme = TestExtensions.CookieAuthenticationScheme); services.AddAuthentication(options => options.SignInScheme = TestExtensions.CookieAuthenticationScheme);
}); });
return new TestServer(builder);
} }
} }
} }

View File

@ -9,6 +9,7 @@ using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Http.Features.Authentication; using Microsoft.AspNet.Http.Features.Authentication;
@ -536,7 +537,8 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
private static TestServer CreateServer(Action<JwtBearerOptions> configureOptions, Func<HttpContext, bool> handler = null) private static TestServer CreateServer(Action<JwtBearerOptions> configureOptions, Func<HttpContext, bool> handler = null)
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
if (configureOptions != null) if (configureOptions != null)
{ {
@ -595,8 +597,9 @@ namespace Microsoft.AspNet.Authentication.JwtBearer
await next(); await next();
} }
}); });
}, })
services => services.AddAuthentication()); .ConfigureServices(services => services.AddAuthentication());
return new TestServer(builder);
} }
// TODO: see if we can share the TestExtensions SendAsync method (only diff is auth header) // TODO: see if we can share the TestExtensions SendAsync method (only diff is auth header)

View File

@ -12,6 +12,7 @@ using Microsoft.AspNet.Authentication.MicrosoftAccount;
using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Authentication.OAuth;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.DataProtection; using Microsoft.AspNet.DataProtection;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
@ -177,7 +178,8 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
private static TestServer CreateServer(Action<MicrosoftAccountOptions> configureOptions) private static TestServer CreateServer(Action<MicrosoftAccountOptions> configureOptions)
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => app.UseCookieAuthentication(options =>
{ {
@ -215,8 +217,8 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
await next(); await next();
} }
}); });
}, })
services => .ConfigureServices(services =>
{ {
services.AddAuthentication(); services.AddAuthentication();
services.Configure<SharedAuthenticationOptions>(options => services.Configure<SharedAuthenticationOptions>(options =>
@ -224,6 +226,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
options.SignInScheme = TestExtensions.CookieAuthenticationScheme; options.SignInScheme = TestExtensions.CookieAuthenticationScheme;
}); });
}); });
return new TestServer(builder);
} }
private static HttpResponseMessage ReturnJsonResponse(object content) private static HttpResponseMessage ReturnJsonResponse(object content)

View File

@ -12,6 +12,7 @@ using System.Text.Encodings.Web;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Authentication.OpenIdConnect;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -94,8 +95,8 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, UrlEncoder encoder, OpenIdConnectHandler handler = null) private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, UrlEncoder encoder, OpenIdConnectHandler handler = null)
{ {
return TestServer.Create( var builder = new WebApplicationBuilder()
app => .Configure(app =>
{ {
var options = new OpenIdConnectOptions(); var options = new OpenIdConnectOptions();
configureOptions(options); configureOptions(options);
@ -104,13 +105,13 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
{ {
await next(); await next();
}); });
}, })
services => .ConfigureServices(services =>
{ {
services.AddWebEncoders(); services.AddWebEncoders();
services.AddDataProtection(); services.AddDataProtection();
} });
); return new TestServer(builder);
} }
} }
} }

View File

@ -14,6 +14,7 @@ using System.Xml.Linq;
using Microsoft.AspNet.Authentication.Cookies; using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.AspNet.Authentication.OpenIdConnect; using Microsoft.AspNet.Authentication.OpenIdConnect;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
@ -380,7 +381,8 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, Func<HttpContext, Task> handler = null, AuthenticationProperties properties = null) private static TestServer CreateServer(Action<OpenIdConnectOptions> configureOptions, Func<HttpContext, Task> handler = null, AuthenticationProperties properties = null)
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => app.UseCookieAuthentication(options =>
{ {
@ -428,8 +430,8 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
await next(); await next();
} }
}); });
}, })
services => .ConfigureServices(services =>
{ {
services.AddAuthentication(); services.AddAuthentication();
services.Configure<SharedAuthenticationOptions>(options => services.Configure<SharedAuthenticationOptions>(options =>
@ -437,6 +439,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}); });
}); });
return new TestServer(builder);
} }
private static async Task<Transaction> SendAsync(TestServer server, string uri, string cookieHeader = null) private static async Task<Transaction> SendAsync(TestServer server, string uri, string cookieHeader = null)

View File

@ -1,17 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information.
using System; using System;
using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Security.Claims; using System.Security.Claims;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.WebEncoders;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Authentication.Twitter namespace Microsoft.AspNet.Authentication.Twitter
@ -153,7 +152,8 @@ namespace Microsoft.AspNet.Authentication.Twitter
private static TestServer CreateServer(Action<TwitterOptions> configure, Func<HttpContext, bool> handler = null) private static TestServer CreateServer(Action<TwitterOptions> configure, Func<HttpContext, bool> handler = null)
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => app.UseCookieAuthentication(options =>
{ {
@ -181,8 +181,8 @@ namespace Microsoft.AspNet.Authentication.Twitter
await next(); await next();
} }
}); });
}, })
services => .ConfigureServices(services =>
{ {
services.AddAuthentication(); services.AddAuthentication();
services.Configure<SharedAuthenticationOptions>(options => services.Configure<SharedAuthenticationOptions>(options =>
@ -190,6 +190,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
options.SignInScheme = "External"; options.SignInScheme = "External";
}); });
}); });
return new TestServer(builder);
} }
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Http.Features.Internal; using Microsoft.AspNet.Http.Features.Internal;
@ -129,7 +130,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test
[Fact] [Fact]
public async Task CookiePolicyCanHijackAppend() public async Task CookiePolicyCanHijackAppend()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookiePolicy(options => options.OnAppendCookie = ctx => ctx.CookieName = ctx.CookieValue = "Hao"); app.UseCookiePolicy(options => options.OnAppendCookie = ctx => ctx.CookieName = ctx.CookieValue = "Hao");
app.Run(context => app.Run(context =>
@ -141,6 +143,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test
return Task.FromResult(0); return Task.FromResult(0);
}); });
}); });
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/login"); var transaction = await server.SendAsync("http://example.com/login");
@ -154,7 +157,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test
[Fact] [Fact]
public async Task CookiePolicyCanHijackDelete() public async Task CookiePolicyCanHijackDelete()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookiePolicy(options => options.OnDeleteCookie = ctx => ctx.CookieName = "A"); app.UseCookiePolicy(options => options.OnDeleteCookie = ctx => ctx.CookieName = "A");
app.Run(context => app.Run(context =>
@ -166,6 +170,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test
return Task.FromResult(0); return Task.FromResult(0);
}); });
}); });
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/login"); var transaction = await server.SendAsync("http://example.com/login");
@ -177,7 +182,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test
[Fact] [Fact]
public async Task CookiePolicyCallsCookieFeature() public async Task CookiePolicyCallsCookieFeature()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.Use(next => context => app.Use(next => context =>
{ {
@ -194,6 +200,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test
return context.Response.WriteAsync("Done"); return context.Response.WriteAsync("Done");
}); });
}); });
var server = new TestServer(builder);
var transaction = await server.SendAsync("http://example.com/login"); var transaction = await server.SendAsync("http://example.com/login");
Assert.Equal("Done", transaction.ResponseText); Assert.Equal("Done", transaction.ResponseText);
@ -251,7 +258,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test
RequestDelegate configureSetup, RequestDelegate configureSetup,
params RequestTest[] tests) params RequestTest[] tests)
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.Map(path, map => app.Map(path, map =>
{ {
@ -259,6 +267,7 @@ namespace Microsoft.AspNet.CookiePolicy.Test
map.Run(configureSetup); map.Run(configureSetup);
}); });
}); });
var server = new TestServer(builder);
foreach (var test in tests) foreach (var test in tests)
{ {
await test.Execute(server); await test.Execute(server);

View File

@ -13,6 +13,7 @@ using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Authentication;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Owin; using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.Cookies;
@ -120,7 +121,8 @@ namespace Microsoft.AspNet.CookiePolicy.Test
var transaction = await SendAsync(interopServer, "http://example.com"); var transaction = await SendAsync(interopServer, "http://example.com");
var newServer = TestHost.TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection);
app.Run(async context => app.Run(async context =>
@ -128,7 +130,9 @@ namespace Microsoft.AspNet.CookiePolicy.Test
var result = await context.Authentication.AuthenticateAsync("Cookies"); var result = await context.Authentication.AuthenticateAsync("Cookies");
await context.Response.WriteAsync(result.Identity.Name); await context.Response.WriteAsync(result.Identity.Name);
}); });
}, services => services.AddAuthentication()); })
.ConfigureServices(services => services.AddAuthentication());
var newServer = new 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());
@ -146,11 +150,14 @@ namespace Microsoft.AspNet.CookiePolicy.Test
user.AddIdentity(identity); user.AddIdentity(identity);
var dataProtection = new DataProtection.DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts")); var dataProtection = new DataProtection.DataProtectionProvider(new DirectoryInfo("..\\..\\artifacts"));
var newServer = TestHost.TestServer.Create(app => var builder = new WebApplicationBuilder()
.Configure(app =>
{ {
app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection); app.UseCookieAuthentication(options => options.DataProtectionProvider = dataProtection);
app.Run(context => context.Authentication.SignInAsync("Cookies", user)); app.Run(context => context.Authentication.SignInAsync("Cookies", user));
}, services => services.AddAuthentication()); })
.ConfigureServices(services => services.AddAuthentication());
var newServer = new TestHost.TestServer(builder);
var cookie = await SendAndGetCookie(newServer, "http://example.com/login"); var cookie = await SendAndGetCookie(newServer, "http://example.com/login");