-
Notifications
You must be signed in to change notification settings - Fork 1.7k
#1288 Query string char missing #1335
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
Merged
raman-m
merged 8 commits into
ThreeMammals:develop
from
jlukawska:fix/1288-query-string-char-missing
Sep 22, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c56d079
fix char missing when query string contains the placeholder name and …
jlukawska 5cb55ec
fix the regex problem with removing a query param when it is not the …
jlukawska 1b43f19
Remove and Sort Usings
raman-m b8d748e
CA1845 Use span-based 'string.Concat' and 'AsSpan' instead of 'Substr…
raman-m b147b43
IDE0057 Substring can be simplified.
raman-m d531718
IDE0057 Substring can be simplified.
raman-m 69c950a
IDE0042 Variable declaration can be deconstructed.
raman-m 48e65da
Merge branch 'develop' into fix/1288-query-string-char-missing
raman-m 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,12 +1,5 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Net.Http; | ||
| using System.Threading.Tasks; | ||
|
|
||
| using Microsoft.AspNetCore.Http; | ||
|
|
||
| using Microsoft.AspNetCore.Http; | ||
| using Moq; | ||
|
|
||
| using Ocelot.Configuration; | ||
| using Ocelot.Configuration.Builder; | ||
| using Ocelot.DownstreamRouteFinder; | ||
|
|
@@ -17,15 +10,14 @@ | |
| using Ocelot.Logging; | ||
| using Ocelot.Middleware; | ||
| using Ocelot.Request.Middleware; | ||
|
|
||
| using Ocelot.Responses; | ||
|
|
||
| using Ocelot.Values; | ||
| using Shouldly; | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Net.Http; | ||
| using System.Threading.Tasks; | ||
| using TestStack.BDDfy; | ||
|
|
||
| using Ocelot.Values; | ||
|
|
||
| using Xunit; | ||
|
|
||
| namespace Ocelot.UnitTests.DownstreamUrlCreator | ||
|
|
@@ -137,7 +129,39 @@ public void should_replace_query_string_but_leave_non_placeholder_queries() | |
| .WithDownstreamRoute(downstreamRoute) | ||
| .WithUpstreamHttpMethod(new List<string> { "Get" }) | ||
| .Build()))) | ||
| .And(x => x.GivenTheDownstreamRequestUriIs("http://localhost:5000/api/subscriptions/1/updates?unitId=2&productId=2")) | ||
| .And(x => x.GivenTheDownstreamRequestUriIs("http://localhost:5000/api/subscriptions/1/updates?unitId=2&productId=2")) // unitId is the first | ||
| .And(x => GivenTheServiceProviderConfigIs(config)) | ||
| .And(x => x.GivenTheUrlReplacerWillReturn("api/units/1/2/updates")) | ||
| .When(x => x.WhenICallTheMiddleware()) | ||
| .Then(x => x.ThenTheDownstreamRequestUriIs("https://localhost:5000/api/units/1/2/updates?productId=2")) | ||
| .And(x => ThenTheQueryStringIs("?productId=2")) | ||
| .BDDfy(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void should_replace_query_string_but_leave_non_placeholder_queries_2() | ||
|
Member
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. Do we cover the user scenario reported in 1288 by this test? |
||
| { | ||
| var downstreamRoute = new DownstreamRouteBuilder() | ||
| .WithDownstreamPathTemplate("/api/units/{subscriptionId}/{unitId}/updates") | ||
| .WithUpstreamHttpMethod(new List<string> { "Get" }) | ||
| .WithDownstreamScheme("https") | ||
| .Build(); | ||
|
|
||
| var config = new ServiceProviderConfigurationBuilder() | ||
| .Build(); | ||
|
|
||
| this.Given(x => x.GivenTheDownStreamRouteIs( | ||
| new DownstreamRouteHolder( | ||
| new List<PlaceholderNameAndValue> | ||
| { | ||
| new PlaceholderNameAndValue("{subscriptionId}", "1"), | ||
| new PlaceholderNameAndValue("{unitId}", "2"), | ||
| }, | ||
| new RouteBuilder() | ||
| .WithDownstreamRoute(downstreamRoute) | ||
| .WithUpstreamHttpMethod(new List<string> { "Get" }) | ||
| .Build()))) | ||
| .And(x => x.GivenTheDownstreamRequestUriIs("http://localhost:5000/api/subscriptions/1/updates?productId=2&unitId=2")) // unitId is the second | ||
| .And(x => GivenTheServiceProviderConfigIs(config)) | ||
| .And(x => x.GivenTheUrlReplacerWillReturn("api/units/1/2/updates")) | ||
| .When(x => x.WhenICallTheMiddleware()) | ||
|
|
||
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.
OK. But where is a And-check that the query string was copied?
Where is And-check that expected
queryNameis in query string?What is the predicate of "copying"?
Does it mean if copying failed then the step
ThenTheStatusCodeShouldBe(HttpStatusCode.OK))fails too?