Skip to content

Commit c0c10bc

Browse files
authored
Merge pull request #2 from NikiforovAll/feature/development-only-by-default
Make DevelopmentOnly flag default option
2 parents 3154ee5 + 748a5e9 commit c0c10bc

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

Source/ConfigurationDebugViewEndpoint/ConfigurationDebugViewEndpoint.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ItemGroup>
1313
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1414
</ItemGroup>
15-
<ItemGroup Label="Pacakge References">
15+
<ItemGroup Label="Package References">
1616
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
1717
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
1818
</ItemGroup>

Source/ConfigurationDebugViewEndpoint/ConfigurationDebugViewOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public class ConfigurationDebugViewOptions
99
/// Gets or sets a value that controls whether to use <see cref="ConfigurationDebugViewMiddleware"/>
1010
/// exclusively on Development environment.
1111
/// </summary>
12-
public bool AllowDevelopmentOnly { get; set; }
12+
public bool AllowDevelopmentOnly { get; set; } = true;
1313
}
1414
}

Tests/ConfigurationDebugViewEndpoint.Test/EndpointRouteBuilderExtensionsTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,33 @@ public async Task WithAllowDevelopmentOnlyOptions_Development_ConfigurationRetur
8181
Assert.Equal(expectedStatusCode, (int)response.StatusCode);
8282
}
8383

84+
[Theory]
85+
[InlineData("Development", 200)]
86+
[InlineData("Production", 404)]
87+
public async Task DefaultOptions_Development_ConfigurationReturned(
88+
string environment,
89+
int expectedStatusCode)
90+
{
91+
var pattern = "/config";
92+
using var host = new HostBuilder().ConfigureWebHost(builder =>
93+
{
94+
builder.ConfigureServices(services => services.AddRouting());
95+
builder.Configure(app =>
96+
{
97+
app.UseRouting();
98+
app.UseEndpoints(endpoints =>
99+
endpoints.MapConfigurationDebugView(pattern));
100+
});
101+
builder.UseTestServer()
102+
.UseEnvironment(environment);
103+
})
104+
.Build();
105+
106+
await host.StartAsync();
107+
using var server = host.GetTestServer();
108+
var response = await server.CreateClient().GetAsync($"http://example.com{pattern}");
109+
Assert.Equal(expectedStatusCode, (int)response.StatusCode);
110+
}
111+
84112
}
85113
}

0 commit comments

Comments
 (0)