From e85c36fa8cf3bf29dee1be72289031b418b408cd Mon Sep 17 00:00:00 2001 From: Christer van der Meeren Date: Mon, 20 Aug 2018 17:25:45 +0200 Subject: [PATCH] Clarify CORS policy result log messages (#177) Fixes https://github.com/aspnet/Home/issues/3419 --- .../Internal/CORSLoggerExtensions.cs | 4 ++-- .../CorsServiceTests.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs index 2cf30d7525..bfcc82a2e6 100644 --- a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs @@ -38,12 +38,12 @@ namespace Microsoft.AspNetCore.Cors.Internal _policySuccess = LoggerMessage.Define( LogLevel.Information, 4, - "Policy execution successful."); + "CORS policy execution successful."); _policyFailure = LoggerMessage.Define( LogLevel.Information, 5, - "Policy execution failed."); + "CORS policy execution failed."); _originNotAllowed = LoggerMessage.Define( LogLevel.Information, diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index 7f7fb2220f..ebef888ad2 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -261,7 +261,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Method = "PUT", Headers = null, OriginLogMessage = "The request has an origin header: 'http://example.com'.", - PolicyLogMessage = "Policy execution failed.", + PolicyLogMessage = "CORS policy execution failed.", FailureReason = "Request origin http://example.com does not have permission to access the resource." } }, @@ -271,7 +271,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Method = "DELETE", Headers = null, OriginLogMessage = "The request has an origin header: 'http://allowed.example.com'.", - PolicyLogMessage = "Policy execution failed.", + PolicyLogMessage = "CORS policy execution failed.", FailureReason = "Request method DELETE not allowed in CORS policy." } }, @@ -281,7 +281,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Method = "PUT", Headers = new[] { "test" }, OriginLogMessage = "The request has an origin header: 'http://allowed.example.com'.", - PolicyLogMessage = "Policy execution failed.", + PolicyLogMessage = "CORS policy execution failed.", FailureReason = "Request header 'test' not allowed in CORS policy." } }, @@ -330,7 +330,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var writeList = sink.Writes.ToList(); Assert.Equal("The request is a preflight request.", writeList[0].State.ToString()); Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", writeList[1].State.ToString()); - Assert.Equal("Policy execution successful.", writeList[2].State.ToString()); + Assert.Equal("CORS policy execution successful.", writeList[2].State.ToString()); } [Fact] @@ -369,7 +369,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var writeList = sink.Writes.ToList(); Assert.Equal("The request has an origin header: 'http://example.com'.", writeList[0].State.ToString()); - Assert.Equal("Policy execution failed.", writeList[1].State.ToString()); + Assert.Equal("CORS policy execution failed.", writeList[1].State.ToString()); Assert.Equal("Request origin http://example.com does not have permission to access the resource.", writeList[2].State.ToString()); } @@ -389,7 +389,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var writeList = sink.Writes.ToList(); Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", writeList[0].State.ToString()); - Assert.Equal("Policy execution successful.", writeList[1].State.ToString()); + Assert.Equal("CORS policy execution successful.", writeList[1].State.ToString()); } [Fact]