Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<ActionResult<CustomerBasket>> GetBasketByIdAsync(string id)

[HttpPost]
[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));
}
Expand All @@ -55,7 +55,7 @@ public async Task<ActionResult<CustomerBasket>> UpdateBasketAsync([FromBody]Cust
[HttpPost]
[ProducesResponseType((int)HttpStatusCode.Accepted)]
[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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task Invoke(HttpContext context)
new Claim("name", "Test user"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Test user"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("sub", currentUserId),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class FailingMiddleware
private bool _mustFail;
private readonly FailingOptions _options;
private readonly ILogger _logger;

public FailingMiddleware(RequestDelegate next, ILogger<FailingMiddleware> logger, FailingOptions options)
{
_next = next;
_options = options;
_mustFail = false;
_logger = logger;
}

public async Task Invoke(HttpContext context)
{
var path = context.Request.Path;
Expand All @@ -44,7 +46,7 @@ public async Task Invoke(HttpContext context)
private async Task ProcessConfigRequest(HttpContext context)
{
var enable = context.Request.Query.Keys.Any(k => k == "enable");
var disable = context.Request.Query.Keys.Any(k => k == "disable");
var disable = context.Request.Query.Keys.Any(k => k == "disable");

if (enable && disable)
{
Expand Down Expand Up @@ -86,7 +88,7 @@ private bool MustFail(HttpContext context)
}

return _mustFail &&
(_options.EndpointPaths.Any(x => x == rpath)
(_options.EndpointPaths.Any(x => x == rpath)
|| _options.EndpointPaths.Count == 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class FailingOptions
public string ConfigPath = "/Failing";
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>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class OrderStartedIntegrationEvent : IntegrationEvent
public string UserId { get; set; }

public OrderStartedIntegrationEvent(string userId)
=> UserId = userId;
=> UserId = userId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even
// An Event is “something that has happened in the past”, therefore its name has to be
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
public class ProductPriceChangedIntegrationEvent : IntegrationEvent
{
{
public int ProductId { get; private set; }

public decimal NewPrice { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Basket/Basket.API/Model/BasketItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex

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;
Expand Down
5 changes: 3 additions & 2 deletions src/Services/Basket/Basket.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ private static IWebHost BuildWebHost(IConfiguration configuration, string[] args

})
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
.UseFailing(options => {
.UseFailing(options =>
{
options.ConfigPath = "/Failing";
options.NotFilteredPaths.AddRange(new[] {"/hc","/liveness"});
options.NotFilteredPaths.AddRange(new[] { "/hc", "/liveness" });
})
.UseStartup<Startup>()
.UseContentRoot(Directory.GetCurrentDirectory())
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Basket/Basket.API/Services/IdentityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Services
{
public class IdentityService : IIdentityService
{
private IHttpContextAccessor _context;
private IHttpContextAccessor _context;

public IdentityService(IHttpContextAccessor context)
{
Expand Down
34 changes: 17 additions & 17 deletions src/Services/Basket/Basket.API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
ConfigureAuth(app);

app.UseStaticFiles();

app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<BasketService>();
Expand Down Expand Up @@ -253,22 +253,22 @@ private void RegisterAppInsights(IServiceCollection services)

private void ConfigureAuthService(IServiceCollection services)
{
// prevent from mapping "sub" claim to nameidentifier.
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");

var identityUrl = Configuration.GetValue<string>("IdentityUrl");

services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

}).AddJwtBearer(options =>
{
options.Authority = identityUrl;
options.RequireHttpsMetadata = false;
options.Audience = "basket";
});
// prevent from mapping "sub" claim to nameidentifier.
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");

var identityUrl = Configuration.GetValue<string>("IdentityUrl");

services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

}).AddJwtBearer(options =>
{
options.Authority = identityUrl;
options.RequireHttpsMetadata = false;
options.Audience = "basket";
});
}

protected virtual void ConfigureAuth(IApplicationBuilder app)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.eShopOnContainers.Services.Basket.API;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace Basket.FunctionalTests.Base
{
Expand All @@ -20,7 +20,7 @@ public override IServiceProvider ConfigureServices(IServiceCollection services)
services.Configure<RouteOptions>(Configuration);
return base.ConfigureServices(services);
}

protected override void ConfigureAuth(IApplicationBuilder app)
{
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ string BuildBasket()

string BuildCheckout()
{
var checkoutBasket = new
var checkoutBasket = new
{
City = "city",
Street = "street",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task UpdateBasket_return_and_add_basket()
Assert.Single(basket.Items);
}


}

[Fact]
Expand All @@ -58,7 +58,7 @@ public async Task Delete_Basket_return_null()

Assert.True(deleteResult);
Assert.Null(result);
}
}
}

RedisBasketRepository BuildBasketRepository(ConnectionMultiplexer connMux)
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CatalogService : CatalogBase
private readonly CatalogContext _catalogContext;
private readonly CatalogSettings _settings;
private readonly ILogger _logger;

public CatalogService(CatalogContext dbContext, IOptions<CatalogSettings> settings, ILogger<CatalogService> logger)
{
_settings = settings.Value;
Expand Down