Skip to content

Commit 8031e6e

Browse files
twsouthwickgithub-actions
authored andcommitted
Add tests
1 parent 918ec31 commit 8031e6e

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/Servers/IIS/IIS/test/Common.FunctionalTests/RequestResponseTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,26 @@ public async Task HostingEnvironmentIsCorrect()
611611
Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\", await _fixture.Client.GetStringAsync("/ASPNETCORE_IIS_PHYSICAL_PATH"));
612612
}
613613

614+
[ConditionalTheory]
615+
[InlineData("IIISEnvironmentFeature")]
616+
[InlineData("IIISEnvironmentFeatureConfig")]
617+
public async Task IISEnvironmentFeatureIsAvailable(string endpoint)
618+
{
619+
var expected = $"""
620+
IIS Version: 10.0
621+
ApplicationId: /LM/W3SVC/1/ROOT
622+
Application Path: {_fixture.DeploymentResult.ContentRoot}\
623+
Application Virtual Path: /
624+
Application Config Path: MACHINE/WEBROOT/APPHOST/HTTPTESTSITE
625+
AppPool ID: IISExpressAppPool
626+
AppPool Config File: {_fixture.DeploymentResult.DeploymentParameters.ServerConfigLocation}
627+
Site ID: 1
628+
Site Name: {_fixture.DeploymentResult.DeploymentParameters.SiteName.ToUpperInvariant()}
629+
""";
630+
631+
Assert.Equal(expected, await _fixture.Client.GetStringAsync($"/{endpoint}"));
632+
}
633+
614634
[ConditionalTheory]
615635
[InlineData(65000)]
616636
[InlineData(1000000)]

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,38 @@ public void ConfigureServices(IServiceCollection serviceCollection)
6767

6868
private async Task BaseDirectory(HttpContext ctx) => await ctx.Response.WriteAsync(AppContext.BaseDirectory);
6969

70+
private async Task IIISEnvironmentFeatureConfig(HttpContext ctx)
71+
{
72+
var config = ctx.RequestServices.GetService<IConfiguration>();
73+
74+
await ctx.Response.WriteAsync("IIS Version: " + config["IIS_VERSION"] + Environment.NewLine);
75+
await ctx.Response.WriteAsync("ApplicationId: " + config["IIS_APPLICATION_ID"] + Environment.NewLine);
76+
await ctx.Response.WriteAsync("Application Path: " + config["IIS_PHYSICAL_PATH"] + Environment.NewLine);
77+
await ctx.Response.WriteAsync("Application Virtual Path: " + config["IIS_APPLICATION_VIRTUAL_PATH"] + Environment.NewLine);
78+
await ctx.Response.WriteAsync("Application Config Path: " + config["IIS_APP_CONFIG_PATH"] + Environment.NewLine);
79+
await ctx.Response.WriteAsync("AppPool ID: " + config["IIS_APP_POOL_ID"] + Environment.NewLine);
80+
await ctx.Response.WriteAsync("AppPool Config File: " + config["IIS_APP_POOL_CONFIG_FILE"] + Environment.NewLine);
81+
await ctx.Response.WriteAsync("Site ID: " + config["IIS_SITE_ID"] + Environment.NewLine);
82+
await ctx.Response.WriteAsync("Site Name: " + config["IIS_SITE_NAME"]);
83+
}
84+
85+
#if !FORWARDCOMPAT
86+
private async Task IIISEnvironmentFeature(HttpContext ctx)
87+
{
88+
var envFeature = ctx.RequestServices.GetService<IServer>().Features.Get<IIISEnvironmentFeature>();
89+
90+
await ctx.Response.WriteAsync("IIS Version: " + envFeature.IISVersion + Environment.NewLine);
91+
await ctx.Response.WriteAsync("ApplicationId: " + envFeature.ApplicationId + Environment.NewLine);
92+
await ctx.Response.WriteAsync("Application Path: " + envFeature.ApplicationPhysicalPath + Environment.NewLine);
93+
await ctx.Response.WriteAsync("Application Virtual Path: " + envFeature.ApplicationVirtualPath + Environment.NewLine);
94+
await ctx.Response.WriteAsync("Application Config Path: " + envFeature.AppConfigPath + Environment.NewLine);
95+
await ctx.Response.WriteAsync("AppPool ID: " + envFeature.AppPoolId + Environment.NewLine);
96+
await ctx.Response.WriteAsync("AppPool Config File: " + envFeature.AppPoolConfigFile + Environment.NewLine);
97+
await ctx.Response.WriteAsync("Site ID: " + envFeature.SiteId + Environment.NewLine);
98+
await ctx.Response.WriteAsync("Site Name: " + envFeature.SiteName);
99+
}
100+
#endif
101+
70102
private async Task ASPNETCORE_IIS_PHYSICAL_PATH(HttpContext ctx) => await ctx.Response.WriteAsync(Environment.GetEnvironmentVariable("ASPNETCORE_IIS_PHYSICAL_PATH"));
71103

72104
private async Task ServerAddresses(HttpContext ctx)
@@ -1128,7 +1160,7 @@ private async Task TransferEncodingHeadersWithMultipleValues(HttpContext ctx)
11281160
try
11291161
{
11301162
#if !FORWARDCOMPAT
1131-
Assert.True(ctx.Request.CanHaveBody());
1163+
Assert.True(ctx.Request.CanHaveBody());
11321164
#endif
11331165
Assert.True(ctx.Request.Headers.ContainsKey("Transfer-Encoding"));
11341166
Assert.Equal("gzip, chunked", ctx.Request.Headers["Transfer-Encoding"]);
@@ -1146,7 +1178,7 @@ private async Task TransferEncodingAndContentLengthShouldBeRemove(HttpContext ct
11461178
try
11471179
{
11481180
#if !FORWARDCOMPAT
1149-
Assert.True(ctx.Request.CanHaveBody());
1181+
Assert.True(ctx.Request.CanHaveBody());
11501182
#endif
11511183
Assert.True(ctx.Request.Headers.ContainsKey("Transfer-Encoding"));
11521184
Assert.Equal("gzip, chunked", ctx.Request.Headers["Transfer-Encoding"]);

0 commit comments

Comments
 (0)