Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,25 @@ public async Task ExpiredTokenShouldThrowUnauthorizedAccessException()
var httpResponseMock = new Mock<HttpResponse>().SetupAllProperties();
httpResponseMock.Setup(r => r.Body).Returns(response);

var loggerMock = new Mock<ILogger<CloudAdapter>>();

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<EventId>(),
It.Is<It.IsAnyType>((o, t) => o.ToString().Contains("The token has expired")),
It.IsAny<Exception>(),
(Func<It.IsAnyType, Exception, string>)It.IsAny<object>()),
Times.Once);
}

private static Stream CreateMessageActivityStream(string userId, string channelId, string conversationId, string recipient, string relatesToActivityId)
Expand Down