Skip to content

Commit

Permalink
Merge b9ddb17 into 397aa48
Browse files Browse the repository at this point in the history
  • Loading branch information
erquirogasw committed Feb 10, 2023
2 parents 397aa48 + b9ddb17 commit b169fa8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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

0 comments on commit b169fa8

Please sign in to comment.