diff --git a/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/CloudAdapter.cs b/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/CloudAdapter.cs index 6a531f8476..65bb2853e5 100644 --- a/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/CloudAdapter.cs +++ b/libraries/integration/Microsoft.Bot.Builder.Integration.AspNet.Core/CloudAdapter.cs @@ -112,10 +112,12 @@ public async Task ProcessAsync(HttpRequest httpRequest, HttpResponse httpRespons httpResponse.StatusCode = (int)HttpStatusCode.MethodNotAllowed; } } - catch (UnauthorizedAccessException) + catch (UnauthorizedAccessException ex) { // handle unauthorized here as this layer creates the http response httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; + + Logger.LogError(ex.ToString()); } } diff --git a/tests/integration/Microsoft.Bot.Builder.Integration.AspNet.Core.Tests/CloudAdapterTests.cs b/tests/integration/Microsoft.Bot.Builder.Integration.AspNet.Core.Tests/CloudAdapterTests.cs index d1244a3c33..8c8d1d0106 100644 --- a/tests/integration/Microsoft.Bot.Builder.Integration.AspNet.Core.Tests/CloudAdapterTests.cs +++ b/tests/integration/Microsoft.Bot.Builder.Integration.AspNet.Core.Tests/CloudAdapterTests.cs @@ -825,14 +825,25 @@ public async Task ExpiredTokenShouldThrowUnauthorizedAccessException() var httpResponseMock = new Mock().SetupAllProperties(); httpResponseMock.Setup(r => r.Body).Returns(response); + var loggerMock = new Mock>(); + var bot = new InvokeResponseBot(); // Act - var adapter = new CloudAdapter(); + var adapter = new CloudAdapter(BotFrameworkAuthenticationFactory.Create(), loggerMock.Object); await adapter.ProcessAsync(httpRequestMock.Object, httpResponseMock.Object, bot); // Assert Assert.Equal((int)HttpStatusCode.Unauthorized, httpResponseMock.Object.StatusCode); + + loggerMock.Verify( + x => x.Log( + LogLevel.Error, + It.IsAny(), + It.Is((o, t) => o.ToString().Contains("The token has expired")), + It.IsAny(), + (Func)It.IsAny()), + Times.Once); } private static Stream CreateMessageActivityStream(string userId, string channelId, string conversationId, string recipient, string relatesToActivityId)