mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 06:48:16 +08:00
I realised we can get rid of the cookie container as cookies are just sent as a header called cookie...
This commit is contained in:
@ -79,7 +79,7 @@ namespace Ocelot.UnitTests.Request
|
||||
this.Given(x => x.GivenTheDownStreamUrlIs("any old string"))
|
||||
.And(x => x.GivenTheQosProviderHouseReturns(new OkResponse<IQoSProvider>(new NoQoSProvider())))
|
||||
.And(x => x.GivenTheDownStreamRouteIs(downstreamRoute))
|
||||
.And(x => x.GivenTheRequestBuilderReturns(new Ocelot.Request.Request(new HttpRequestMessage(), new CookieContainer(), true, new NoQoSProvider())))
|
||||
.And(x => x.GivenTheRequestBuilderReturns(new Ocelot.Request.Request(new HttpRequestMessage(), true, new NoQoSProvider())))
|
||||
.When(x => x.WhenICallTheMiddleware())
|
||||
.Then(x => x.ThenTheScopedDataRepositoryIsCalledCorrectly())
|
||||
.BDDfy();
|
||||
@ -104,8 +104,8 @@ namespace Ocelot.UnitTests.Request
|
||||
{
|
||||
_request = new OkResponse<Ocelot.Request.Request>(request);
|
||||
_requestBuilder
|
||||
.Setup(x => x.Build(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Stream>(), It.IsAny<IHeaderDictionary>(),
|
||||
It.IsAny<IRequestCookieCollection>(), It.IsAny<QueryString>(), It.IsAny<string>(), It.IsAny<Ocelot.RequestId.RequestId>(),It.IsAny<bool>(), It.IsAny<IQoSProvider>()))
|
||||
.Setup(x => x.Build(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Stream>(), It.IsAny<IHeaderDictionary>(),
|
||||
It.IsAny<QueryString>(), It.IsAny<string>(), It.IsAny<Ocelot.RequestId.RequestId>(),It.IsAny<bool>(), It.IsAny<IQoSProvider>()))
|
||||
.ReturnsAsync(_request);
|
||||
}
|
||||
|
||||
|
@ -195,23 +195,6 @@ namespace Ocelot.UnitTests.Request
|
||||
_qoSProvider = qoSProvider;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_use_cookies()
|
||||
{
|
||||
this.Given(x => x.GivenIHaveHttpMethod("GET"))
|
||||
.And(x => x.GivenIHaveDownstreamUrl("http://www.bbc.co.uk"))
|
||||
.And(x => x.GivenTheCookiesAre(new RequestCookieCollection(new Dictionary<string, string>
|
||||
{
|
||||
{ "TheCookie","Monster" }
|
||||
})))
|
||||
.When(x => x.WhenICreateARequest())
|
||||
.And(x => x.ThenTheCorrectCookiesAreUsed(new RequestCookieCollection(new Dictionary<string, string>
|
||||
{
|
||||
{ "TheCookie","Monster" }
|
||||
})))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_user_query_string()
|
||||
{
|
||||
@ -240,14 +223,14 @@ namespace Ocelot.UnitTests.Request
|
||||
|
||||
private void ThenTheCorrectCookiesAreUsed(IRequestCookieCollection expected)
|
||||
{
|
||||
var resultCookies = _result.Data.CookieContainer.GetCookies(new Uri(_downstreamUrl + _query));
|
||||
/* var resultCookies = _result.Data.CookieContainer.GetCookies(new Uri(_downstreamUrl + _query));
|
||||
var resultDictionary = resultCookies.Cast<Cookie>().ToDictionary(cook => cook.Name, cook => cook.Value);
|
||||
|
||||
foreach (var expectedCookie in expected)
|
||||
{
|
||||
var resultCookie = resultDictionary[expectedCookie.Key];
|
||||
resultCookie.ShouldBe(expectedCookie.Value);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void GivenTheCookiesAre(IRequestCookieCollection cookies)
|
||||
@ -305,7 +288,7 @@ namespace Ocelot.UnitTests.Request
|
||||
private void WhenICreateARequest()
|
||||
{
|
||||
_result = _requestCreator.Build(_httpMethod, _downstreamUrl, _content?.ReadAsStreamAsync().Result, _headers,
|
||||
_cookies, _query, _contentType, _requestId,_isQos,_qoSProvider).Result;
|
||||
_query, _contentType, _requestId,_isQos,_qoSProvider).Result;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user