Reacting to new Hosting API
This commit is contained in:
parent
b1a671f3fc
commit
efcc7ae956
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -28,5 +29,15 @@ namespace IISSample
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var application = new WebApplicationBuilder()
|
||||
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
application.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"server": "Microsoft.AspNet.Server.Kestrel"
|
||||
}
|
||||
|
|
@ -3,12 +3,13 @@
|
|||
"dependencies": {
|
||||
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Server.Kestrel",
|
||||
"weblistener": "Microsoft.AspNet.Server.WebListener"
|
||||
"web": "IISSample"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http.Features.Authentication;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
|
@ -17,18 +18,20 @@ namespace Microsoft.AspNet.IISPlatformHandler
|
|||
{
|
||||
var assertsExecuted = false;
|
||||
|
||||
var server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseIISPlatformHandler();
|
||||
app.Run(context =>
|
||||
var builder = new WebApplicationBuilder()
|
||||
.Configure(app =>
|
||||
{
|
||||
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
||||
Assert.NotNull(auth);
|
||||
Assert.Equal("Microsoft.AspNet.IISPlatformHandler.AuthenticationHandler", auth.Handler.GetType().FullName);
|
||||
assertsExecuted = true;
|
||||
return Task.FromResult(0);
|
||||
app.UseIISPlatformHandler();
|
||||
app.Run(context =>
|
||||
{
|
||||
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
||||
Assert.NotNull(auth);
|
||||
Assert.Equal("Microsoft.AspNet.IISPlatformHandler.AuthenticationHandler", auth.Handler.GetType().FullName);
|
||||
assertsExecuted = true;
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
var server = new TestServer(builder);
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "");
|
||||
await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -41,17 +44,19 @@ namespace Microsoft.AspNet.IISPlatformHandler
|
|||
{
|
||||
var assertsExecuted = false;
|
||||
|
||||
var server = TestServer.Create(app =>
|
||||
{
|
||||
app.UseIISPlatformHandler(options => options.FlowWindowsAuthentication = false);
|
||||
app.Run(context =>
|
||||
var builder = new WebApplicationBuilder()
|
||||
.Configure(app =>
|
||||
{
|
||||
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
||||
Assert.Null(auth);
|
||||
assertsExecuted = true;
|
||||
return Task.FromResult(0);
|
||||
app.UseIISPlatformHandler(options => options.FlowWindowsAuthentication = false);
|
||||
app.Run(context =>
|
||||
{
|
||||
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
||||
Assert.Null(auth);
|
||||
assertsExecuted = true;
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
var server = new TestServer(builder);
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "");
|
||||
await server.CreateClient().SendAsync(req);
|
||||
|
|
|
|||
Loading…
Reference in New Issue