Skip to content

Commit

Permalink
Fixes handling disabling mocking in GraphMockResponsePlugin. Closes #446
Browse files Browse the repository at this point in the history
 (#452)
  • Loading branch information
waldekmastykarz authored Dec 21, 2023
1 parent 4003985 commit 0c7e1cf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dev-proxy-plugins/MockResponses/GraphMockResponsePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public class GraphMockResponsePlugin : MockResponsePlugin

protected override async Task OnRequest(object? sender, ProxyRequestArgs e)
{
if (_configuration.NoMocks)
{
// mocking has been disabled. Nothing to do
return;
}

if (!ProxyUtils.IsGraphBatchUrl(e.Session.HttpClient.Request.RequestUri))
{
// not a batch request, use the basic mock functionality
Expand Down Expand Up @@ -130,6 +136,8 @@ protected override async Task OnRequest(object? sender, ProxyRequestArgs e)
Responses = responses.ToArray()
};
e.Session.GenericResponse(JsonSerializer.Serialize(batchResponse), HttpStatusCode.OK, batchHeaders);
_logger?.LogRequest([$"200 {e.Session.HttpClient.Request.RequestUri}"], MessageType.Mocked, new LoggingContext(e.Session));
e.ResponseState.HasBeenSet = true;
}

protected MockResponse? GetMatchingMockResponse(GraphBatchRequestPayloadRequest request, Uri batchRequestUri)
Expand Down

0 comments on commit 0c7e1cf

Please sign in to comment.