Skip to content

Commit 0c7e1cf

Browse files
Fixes handling disabling mocking in GraphMockResponsePlugin. Closes #446 (#452)
1 parent 4003985 commit 0c7e1cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

dev-proxy-plugins/MockResponses/GraphMockResponsePlugin.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public class GraphMockResponsePlugin : MockResponsePlugin
1414

1515
protected override async Task OnRequest(object? sender, ProxyRequestArgs e)
1616
{
17+
if (_configuration.NoMocks)
18+
{
19+
// mocking has been disabled. Nothing to do
20+
return;
21+
}
22+
1723
if (!ProxyUtils.IsGraphBatchUrl(e.Session.HttpClient.Request.RequestUri))
1824
{
1925
// not a batch request, use the basic mock functionality
@@ -130,6 +136,8 @@ protected override async Task OnRequest(object? sender, ProxyRequestArgs e)
130136
Responses = responses.ToArray()
131137
};
132138
e.Session.GenericResponse(JsonSerializer.Serialize(batchResponse), HttpStatusCode.OK, batchHeaders);
139+
_logger?.LogRequest([$"200 {e.Session.HttpClient.Request.RequestUri}"], MessageType.Mocked, new LoggingContext(e.Session));
140+
e.ResponseState.HasBeenSet = true;
133141
}
134142

135143
protected MockResponse? GetMatchingMockResponse(GraphBatchRequestPayloadRequest request, Uri batchRequestUri)

0 commit comments

Comments
 (0)