Swamy/15jan2021 small refactoring (#1580)
* Small Refactoring inside Basket Service folder * Small Refactoring
This commit is contained in:
parent
afb4534acc
commit
130e46ccdf
@ -46,7 +46,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)]
|
||||||
public async Task<ActionResult<CustomerBasket>> UpdateBasketAsync([FromBody]CustomerBasket value)
|
public async Task<ActionResult<CustomerBasket>> UpdateBasketAsync([FromBody] CustomerBasket value)
|
||||||
{
|
{
|
||||||
return Ok(await _repository.UpdateBasketAsync(value));
|
return Ok(await _repository.UpdateBasketAsync(value));
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType((int)HttpStatusCode.Accepted)]
|
[ProducesResponseType((int)HttpStatusCode.Accepted)]
|
||||||
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
|
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
|
||||||
public async Task<ActionResult> CheckoutAsync([FromBody]BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId)
|
public async Task<ActionResult> CheckoutAsync([FromBody] BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId)
|
||||||
{
|
{
|
||||||
var userId = _identityService.GetUserIdentity();
|
var userId = _identityService.GetUserIdentity();
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ namespace Basket.API.Infrastructure.Middlewares
|
|||||||
private bool _mustFail;
|
private bool _mustFail;
|
||||||
private readonly FailingOptions _options;
|
private readonly FailingOptions _options;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public FailingMiddleware(RequestDelegate next, ILogger<FailingMiddleware> logger, FailingOptions options)
|
public FailingMiddleware(RequestDelegate next, ILogger<FailingMiddleware> logger, FailingOptions options)
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
@ -19,6 +20,7 @@ namespace Basket.API.Infrastructure.Middlewares
|
|||||||
_mustFail = false;
|
_mustFail = false;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
public async Task Invoke(HttpContext context)
|
||||||
{
|
{
|
||||||
var path = context.Request.Path;
|
var path = context.Request.Path;
|
||||||
|
@ -7,6 +7,6 @@ namespace Basket.API.Infrastructure.Middlewares
|
|||||||
public string ConfigPath = "/Failing";
|
public string ConfigPath = "/Failing";
|
||||||
public List<string> EndpointPaths { get; set; } = new List<string>();
|
public List<string> EndpointPaths { get; set; } = new List<string>();
|
||||||
|
|
||||||
public List<string> NotFilteredPaths {get; set;} = new List<string>();
|
public List<string> NotFilteredPaths { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
|
|||||||
|
|
||||||
if (Quantity < 1)
|
if (Quantity < 1)
|
||||||
{
|
{
|
||||||
results.Add(new ValidationResult("Invalid number of units", new []{ "Quantity" }));
|
results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
@ -61,9 +61,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
|
|
||||||
})
|
})
|
||||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||||
.UseFailing(options => {
|
.UseFailing(options =>
|
||||||
|
{
|
||||||
options.ConfigPath = "/Failing";
|
options.ConfigPath = "/Failing";
|
||||||
options.NotFilteredPaths.AddRange(new[] {"/hc","/liveness"});
|
options.NotFilteredPaths.AddRange(new[] { "/hc", "/liveness" });
|
||||||
})
|
})
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
@ -253,22 +253,22 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
|
|
||||||
private void ConfigureAuthService(IServiceCollection services)
|
private void ConfigureAuthService(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// prevent from mapping "sub" claim to nameidentifier.
|
// prevent from mapping "sub" claim to nameidentifier.
|
||||||
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
|
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
|
||||||
|
|
||||||
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
|
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
|
||||||
|
|
||||||
services.AddAuthentication(options =>
|
services.AddAuthentication(options =>
|
||||||
{
|
{
|
||||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
|
||||||
}).AddJwtBearer(options =>
|
}).AddJwtBearer(options =>
|
||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "basket";
|
options.Audience = "basket";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ConfigureAuth(IApplicationBuilder app)
|
protected virtual void ConfigureAuth(IApplicationBuilder app)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API;
|
using Microsoft.eShopOnContainers.Services.Basket.API;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Basket.FunctionalTests.Base
|
namespace Basket.FunctionalTests.Base
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user