diff --git a/src/Authoring/Configs/CorsConfig.cs b/src/Authoring/Configs/CorsConfig.cs index b98c9b0..f459436 100644 --- a/src/Authoring/Configs/CorsConfig.cs +++ b/src/Authoring/Configs/CorsConfig.cs @@ -24,7 +24,7 @@ public record CorsConfig /// Policy expressions are allowed. /// [ExpressionAllowed] - public string? TerminateUnmatchedRequest { get; init; } + public bool? TerminateUnmatchedRequest { get; init; } /// /// List of origins allowed to make cross-origin calls to your API.
diff --git a/test/Test.Core/Compiling/CorsTests.cs b/test/Test.Core/Compiling/CorsTests.cs index 4dd9cdc..18d452d 100644 --- a/test/Test.Core/Compiling/CorsTests.cs +++ b/test/Test.Core/Compiling/CorsTests.cs @@ -236,6 +236,68 @@ public void Inbound(IInboundContext context) { """, DisplayName = "Should compile cors policy with expose headers" )] + [DataRow( + """ + [Document] + public class PolicyDocument : IDocument + { + public void Inbound(IInboundContext context) { + context.Cors(new CorsConfig() + { + AllowedOrigins = ["contoso.com"], + AllowedHeaders = ["accept"], + TerminateUnmatchedRequest = true, + }); + } + } + """, + """ + + + + + contoso.com + + +
accept
+
+
+
+
+ """, + DisplayName = "Should compile cors policy with terminate unmatched request explicitly enabled" + )] + [DataRow( + """ + [Document] + public class PolicyDocument : IDocument + { + public void Inbound(IInboundContext context) { + context.Cors(new CorsConfig() + { + AllowedOrigins = ["contoso.com"], + AllowedHeaders = ["accept"], + TerminateUnmatchedRequest = false, + }); + } + } + """, + """ + + + + + contoso.com + + +
accept
+
+
+
+
+ """, + DisplayName = "Should compile cors policy with terminate unmatched request disabled" + )] public void ShouldCompileCorsPolicy(string code, string expectedXml) { code.CompileDocument().Should().BeSuccessful().And.DocumentEquivalentTo(expectedXml);