-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #358 MockGeneratorPlugin errors if the response headers have a duplicate #372
Merged
+17
−24
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
467a668
Fixes #358 MockGeneratorPlugin errors if the response has a duplicate…
9336f00
Merge branch 'microsoft:main' into main
mosoftwareenterprises 8b297c5
Fixes #358 MockGeneratorPlugin errors if the response has a duplicate…
8c45e7e
Merge branch 'main' of https://github.com/mosoftwareenterprises/m365-…
a96a4ba
Merge remote-tracking branch 'upstream/main'
ccd2f98
Revert some styling changes
36ffe07
Merge branch 'main' into main
mosoftwareenterprises 01fa17a
Fixes #358 MockGeneratorPlugin errors if the response headers have a …
d7e3a6b
Merge branch 'main' of https://github.com/mosoftwareenterprises/m365-…
3898fe7
Fixes #358 MockGeneratorPlugin errors if the response headers have a …
200d52e
Fixes #358 MockGeneratorPlugin errors if the response headers have a …
596b036
Merge branch 'main' into main
waldekmastykarz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
using System.Net; | ||
using System.Text.Json; | ||
using System.Text.RegularExpressions; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we using EntityFrmeworkCore for something or is this a leftover? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must be a leftover. Removed |
||
using Microsoft.EntityFrameworkCore.Metadata.Internal; | ||
using Microsoft365.DeveloperProxy.Abstractions; | ||
|
||
namespace Microsoft365.DeveloperProxy.Plugins.MockResponses; | ||
|
@@ -34,7 +36,7 @@ protected override async Task OnRequest(object? sender, ProxyRequestArgs e) | |
GraphBatchResponsePayloadResponse? response = null; | ||
var requestId = Guid.NewGuid().ToString(); | ||
var requestDate = DateTime.Now.ToString(); | ||
var headers = ProxyUtils | ||
Dictionary<string, string> headers = ProxyUtils | ||
.BuildGraphResponseHeaders(e.Session.HttpClient.Request, requestId, requestDate) | ||
.ToDictionary(h => h.Name, h => h.Value); | ||
|
||
|
@@ -45,7 +47,7 @@ protected override async Task OnRequest(object? sender, ProxyRequestArgs e) | |
{ | ||
Id = request.Id, | ||
Status = (int)HttpStatusCode.BadGateway, | ||
Headers = headers, | ||
Headers = new List<Dictionary<string, string>> { headers }, | ||
Body = new GraphBatchResponsePayloadResponseBody | ||
{ | ||
Error = new GraphBatchResponsePayloadResponseBodyError | ||
|
@@ -69,10 +71,7 @@ protected override async Task OnRequest(object? sender, ProxyRequestArgs e) | |
|
||
if (mockResponse.ResponseHeaders is not null) | ||
{ | ||
foreach (var key in mockResponse.ResponseHeaders.Keys) | ||
{ | ||
headers[key] = mockResponse.ResponseHeaders[key]; | ||
} | ||
mockResponse.ResponseHeaders.SelectMany(dict => dict.Select(kv => headers[kv.Key] = kv.Value)); | ||
} | ||
// default the content type to application/json unless set in the mock response | ||
if (!headers.Any(h => h.Key.Equals("content-type", StringComparison.OrdinalIgnoreCase))) | ||
|
@@ -112,7 +111,7 @@ protected override async Task OnRequest(object? sender, ProxyRequestArgs e) | |
{ | ||
Id = request.Id, | ||
Status = (int)statusCode, | ||
Headers = headers, | ||
Headers = new List<Dictionary<string, string>> { headers }, | ||
Body = body | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to define headers as a list of dictionaries. Shouldn't it be a list of key-value pairs instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a Dictionary (which is in effect the same thing AFAIK), means we can use Linq to do "ToDictionary()"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has now changed to a List<KeyValuePair<string,string>> due to the dictionary complicating some other areas.