Merge branch 'dev' of https://github.com/dotnet-architecture/eShopOnContainers into dev
This commit is contained in:
commit
bf34bff8dd
@ -9,6 +9,7 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
public class BasketService : IBasketService
|
||||
{
|
||||
private readonly IRequestProvider _requestProvider;
|
||||
private const string ApiUrlBase = "api/v1/basket";
|
||||
|
||||
public BasketService(IRequestProvider requestProvider)
|
||||
{
|
||||
@ -16,12 +17,13 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
}
|
||||
|
||||
public async Task<CustomerBasket> GetBasketAsync(string guidUser, string token)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
|
||||
{
|
||||
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
|
||||
{
|
||||
Path = $"{ApiUrlBase}/{guidUser}"
|
||||
};
|
||||
|
||||
builder.Path = guidUser;
|
||||
|
||||
string uri = builder.ToString();
|
||||
var uri = builder.ToString();
|
||||
|
||||
CustomerBasket basket =
|
||||
await _requestProvider.GetAsync<CustomerBasket>(uri, token);
|
||||
@ -33,9 +35,12 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
|
||||
public async Task<CustomerBasket> UpdateBasketAsync(CustomerBasket customerBasket, string token)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
|
||||
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
|
||||
{
|
||||
Path = ApiUrlBase
|
||||
};
|
||||
|
||||
string uri = builder.ToString();
|
||||
var uri = builder.ToString();
|
||||
|
||||
var result = await _requestProvider.PostAsync(uri, customerBasket, token);
|
||||
|
||||
@ -44,20 +49,24 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
|
||||
public async Task CheckoutAsync(BasketCheckout basketCheckout, string token)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint + "/checkout");
|
||||
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
|
||||
{
|
||||
Path = $"{ApiUrlBase}/checkout"
|
||||
};
|
||||
|
||||
string uri = builder.ToString();
|
||||
var uri = builder.ToString();
|
||||
|
||||
await _requestProvider.PostAsync(uri, basketCheckout, token);
|
||||
}
|
||||
|
||||
public async Task ClearBasketAsync(string guidUser, string token)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
|
||||
var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint)
|
||||
{
|
||||
Path = $"{ApiUrlBase}/{guidUser}"
|
||||
};
|
||||
|
||||
builder.Path = guidUser;
|
||||
|
||||
string uri = builder.ToString();
|
||||
var uri = builder.ToString();
|
||||
|
||||
await _requestProvider.DeleteAsync(uri, token);
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace FunctionalTests.Services.Basket
|
||||
namespace FunctionalTests.Services.Basket
|
||||
{
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using System.IO;
|
||||
|
||||
public class BasketScenariosBase
|
||||
{
|
||||
private const string ApiUrlBase = "api/v1/basket";
|
||||
|
||||
public TestServer CreateServer()
|
||||
{
|
||||
var webHostBuilder = new WebHostBuilder();
|
||||
@ -22,14 +21,14 @@ namespace FunctionalTests.Services.Basket
|
||||
{
|
||||
public static string GetBasketByCustomer(string customerId)
|
||||
{
|
||||
return $"/{customerId}";
|
||||
return $"{ApiUrlBase}/{customerId}";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Post
|
||||
{
|
||||
public static string CreateBasket = "/";
|
||||
public static string Checkout = "/checkout";
|
||||
public static string CreateBasket = $"{ApiUrlBase}/";
|
||||
public static string Checkout = $"{ApiUrlBase}/checkout";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.eShopOnContainers.Services.Basket.API;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace IntegrationTests.Services.Basket
|
||||
{
|
||||
public class BasketScenarioBase
|
||||
{
|
||||
private const string ApiUrlBase = "api/v1/basket";
|
||||
|
||||
public TestServer CreateServer()
|
||||
{
|
||||
var webHostBuilder = new WebHostBuilder();
|
||||
@ -23,14 +21,14 @@ namespace IntegrationTests.Services.Basket
|
||||
{
|
||||
public static string GetBasket(int id)
|
||||
{
|
||||
return $"{id}";
|
||||
return $"{ApiUrlBase}/{id}";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Post
|
||||
{
|
||||
public static string Basket = "";
|
||||
public static string CheckoutOrder = "checkout";
|
||||
public static string Basket = $"{ApiUrlBase}/";
|
||||
public static string CheckoutOrder = $"{ApiUrlBase}/checkout";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@
|
||||
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
|
||||
</FormPostHttpBody>
|
||||
</Request>
|
||||
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/basket" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Headers>
|
||||
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}} " />
|
||||
<Header Name="Accept" Value="application/json" />
|
||||
@ -80,6 +80,7 @@
|
||||
<ContextParameter Name="IdentityApiServer" Value="http://" />
|
||||
<ContextParameter Name="BasketApiServer" Value="http://" />
|
||||
<ContextParameter Name="UserId" Value="" />
|
||||
<ContextParameter Name="ApiVersion" Value="v1" />
|
||||
</ContextParameters>
|
||||
<ValidationRules>
|
||||
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />
|
||||
|
@ -65,7 +65,7 @@
|
||||
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
|
||||
</FormPostHttpBody>
|
||||
</Request>
|
||||
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/checkout" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Request Method="POST" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/checkout" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Headers>
|
||||
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}}" />
|
||||
<Header Name="Accept" Value="application/json" />
|
||||
|
@ -65,7 +65,7 @@
|
||||
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
|
||||
</FormPostHttpBody>
|
||||
</Request>
|
||||
<Request Method="DELETE" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Request Method="DELETE" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Headers>
|
||||
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}} " />
|
||||
<Header Name="Accept" Value="application/json" />
|
||||
@ -79,6 +79,7 @@
|
||||
<ContextParameter Name="IdentityApiServer" Value="http://" />
|
||||
<ContextParameter Name="BasketApiServer" Value="http://" />
|
||||
<ContextParameter Name="UserId" Value="" />
|
||||
<ContextParameter Name="ApiVersion" Value="v1" />
|
||||
</ContextParameters>
|
||||
<ValidationRules>
|
||||
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />
|
||||
|
@ -65,7 +65,7 @@
|
||||
<FormPostParameter Name="session_state" Value="{{$HIDDEN1.session_state}}" RecordedValue="ZxRKRHGaGBxyciYNO7yxXNcHb8MxcvGDfUWuUVaCkNo.5de6fc3970ef99b7b67328e1df0e93ce" CorrelationBinding="" UrlEncode="True" />
|
||||
</FormPostHttpBody>
|
||||
</Request>
|
||||
<Request Method="GET" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Request Method="GET" Guid="d24fe957-0cbb-46d4-8478-974de57e5cba" Version="1.1" Url="{{BasketApiServer}}/api/{{ApiVersion}}/{{UserId}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
|
||||
<Headers>
|
||||
<Header Name="Authorization" Value="Bearer {{$HIDDEN1.access_token}} " />
|
||||
<Header Name="Accept" Value="application/json" />
|
||||
@ -79,6 +79,7 @@
|
||||
<ContextParameter Name="IdentityApiServer" Value="http://" />
|
||||
<ContextParameter Name="BasketApiServer" Value="http://" />
|
||||
<ContextParameter Name="UserId" Value="" />
|
||||
<ContextParameter Name="ApiVersion" Value="v1" />
|
||||
</ContextParameters>
|
||||
<ValidationRules>
|
||||
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user