Skip to content

Commit 983ec24

Browse files
committed
Fix assertions where we expected OpenAPI to be enabled for published apps, which is not the case
1 parent 9674e32 commit 983ec24

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,51 @@ public ITestOutputHelper Output
3434
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)]
3535
public async Task WebApiNativeAotTemplateCSharp()
3636
{
37-
await WebApiNativeAotTemplateCore(languageOverride: null, additionalEndpointsThatShould200Ok: new[] { "/openapi/v1.json" });
37+
await WebApiNativeAotTemplateCore(languageOverride: null, additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" });
3838
}
3939

4040
[ConditionalFact]
4141
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)]
4242
public async Task WebApiNativeAotTemplateProgramMainCSharp()
4343
{
44-
await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }, additionalEndpointsThatShould200Ok: new[] { "/openapi/v1.json" });
44+
await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }, additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" });
45+
}
46+
47+
[ConditionalTheory]
48+
[InlineData(false)]
49+
[InlineData(true)]
50+
public async Task WebApiNativeAotTemplateCSharp_OpenApiDisabledInProductionEnvironment()
51+
{
52+
var args = useProgramMain
53+
? new[] { ArgConstants.UseProgramMain }
54+
: new[] { };
55+
56+
await WebApiNativeAotTemplateCore(languageOverride: null, args: args, additionalEndpointsThatShould404NotFoundForPublishedProjects: new[] { "/openapi/v1.json" });
4557
}
4658

4759
[ConditionalTheory]
4860
[InlineData(false)]
4961
[InlineData(true)]
5062
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)]
51-
public async Task WebApiTemplateCSharp_WithoutOpenAPI(bool useProgramMain)
63+
public async Task WebApiNativeAotTemplateCSharp_WithoutOpenAPI(bool useProgramMain)
5264
{
5365
var args = useProgramMain
5466
? new[] { ArgConstants.UseProgramMain, ArgConstants.NoOpenApi }
5567
: new[] { ArgConstants.NoOpenApi };
5668

57-
await WebApiNativeAotTemplateCore(languageOverride: null, args: args, additionalEndpointsThatShould404NotFound: new[] { "/openapi/v1.json" });
69+
await WebApiNativeAotTemplateCore(
70+
languageOverride: null,
71+
args: args,
72+
additionalEndpointsThatShould404NotFoundForBuiltProjects: new[] { "/openapi/v1.json" };
5873
}
5974

60-
private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] args = null, string[] additionalEndpointsThatShould200Ok = null, string[] additionalEndpointsThatShould404NotFound = null)
75+
private async Task WebApiNativeAotTemplateCore(
76+
string languageOverride,
77+
string[] args = null,
78+
string[] additionalEndpointsThatShould200OkForBuiltProjects = null,
79+
string[] additionalEndpointsThatShould200OkForPublishedProjects = null,
80+
string[] additionalEndpointsThatShould404NotFoundForBuiltProjects = null,
81+
string[] additionalEndpointsThatShould404NotFoundForPublishedProjects = null)
6182
{
6283
var project = await ProjectFactory.CreateProject(Output);
6384
project.SetCurrentRuntimeIdentifier();
@@ -90,7 +111,7 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[]
90111
Assert.False(
91112
aspNetProcess.Process.HasExited,
92113
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process));
93-
await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200Ok, additionalEndpointsThatShould404NotFound);
114+
await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200OkForBuiltProjects, additionalEndpointsThatShould404NotFoundForBuiltProjects);
94115
}
95116

96117
using (var aspNetProcess = project.StartPublishedProjectAsync(noHttps: true, usePublishedAppHost: true))
@@ -99,7 +120,7 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[]
99120
aspNetProcess.Process.HasExited,
100121
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process));
101122

102-
await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200Ok, additionalEndpointsThatShould404NotFound);
123+
await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200OkForPublishedProjects, additionalEndpointsThatShould404NotFoundForPublishedProjects);
103124
}
104125
}
105126

0 commit comments

Comments
 (0)