From 6ac34cbdaaf51a8e15dee1ddc36b7a77c1016ff8 Mon Sep 17 00:00:00 2001 From: Unai Zorrilla Castro Date: Tue, 29 Aug 2017 12:48:04 +0200 Subject: [PATCH] Update functional tests --- src/Services/Basket/Basket.API/Startup.cs | 9 ++++++++- src/Services/Location/Locations.API/Startup.cs | 7 ++++++- src/Services/Marketing/Marketing.API/Startup.cs | 7 ++++++- test/Services/FunctionalTests/FunctionalTests.csproj | 7 +++---- .../Services/Basket/BasketTestsStartup.cs | 3 ++- .../Services/Location/LocationsTestsStartup.cs | 5 ++++- .../Services/Marketing/MarketingTestsStartup.cs | 8 ++++---- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index e2a2b6e3e..01314b38e 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -167,7 +167,9 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API { app.UseStaticFiles(); app.UseCors("CorsPolicy"); - app.UseAuthentication(); + + ConfigureAuth(app); + app.UseMvcWithDefaultRoute(); app.UseSwagger() @@ -216,5 +218,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API eventBus.Subscribe(); eventBus.Subscribe(); } + + protected virtual void ConfigureAuth(IApplicationBuilder app) + { + app.UseAuthentication(); + } } } diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs index 7d235ed0f..9c2881f07 100644 --- a/src/Services/Location/Locations.API/Startup.cs +++ b/src/Services/Location/Locations.API/Startup.cs @@ -138,7 +138,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API { app.UseCors("CorsPolicy"); - app.UseAuthentication(); + ConfigureAuth(app); app.UseMvcWithDefaultRoute(); @@ -176,5 +176,10 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API services.AddSingleton(); } + + protected virtual void ConfigureAuth(IApplicationBuilder app) + { + app.UseAuthentication(); + } } } diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs index 952594556..76ff4b380 100644 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ b/src/Services/Marketing/Marketing.API/Startup.cs @@ -171,7 +171,7 @@ { app.UseCors("CorsPolicy"); - app.UseAuthentication(); + ConfigureAuth(app); app.UseMvcWithDefaultRoute(); @@ -243,5 +243,10 @@ } ); } + + protected virtual void ConfigureAuth(IApplicationBuilder app) + { + app.UseAuthentication(); + } } } diff --git a/test/Services/FunctionalTests/FunctionalTests.csproj b/test/Services/FunctionalTests/FunctionalTests.csproj index f9f58a318..99cf123a2 100644 --- a/test/Services/FunctionalTests/FunctionalTests.csproj +++ b/test/Services/FunctionalTests/FunctionalTests.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 true - $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + false false false @@ -45,9 +45,8 @@ - - - + + diff --git a/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs b/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs index 2beb73bd1..a6695c12f 100644 --- a/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs +++ b/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs @@ -2,12 +2,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.eShopOnContainers.Services.Basket.API; +using Microsoft.Extensions.Configuration; namespace FunctionalTests.Services.Basket { public class BasketTestsStartup : Startup { - public BasketTestsStartup(IHostingEnvironment env) : base(env) + public BasketTestsStartup(IConfiguration configuration) : base(configuration) { } diff --git a/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs b/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs index b80408388..fce808759 100644 --- a/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs +++ b/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs @@ -4,12 +4,13 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.eShopOnContainers.Services.Locations.API; + using Microsoft.Extensions.Configuration; using System.Security.Claims; using System.Threading.Tasks; public class LocationsTestsStartup : Startup { - public LocationsTestsStartup(IHostingEnvironment env) : base(env) + public LocationsTestsStartup(IConfiguration configuration) : base(configuration) { } @@ -28,6 +29,7 @@ class LocationAuthorizeMiddleware { private readonly RequestDelegate _next; + public LocationAuthorizeMiddleware(RequestDelegate rd) { _next = rd; @@ -38,6 +40,7 @@ var identity = new ClaimsIdentity("cookies"); identity.AddClaim(new Claim("sub", "4611ce3f-380d-4db5-8d76-87a8689058ed")); httpContext.User.AddIdentity(identity); + await _next.Invoke(httpContext); } } diff --git a/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs b/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs index e43db6646..ae5f4453b 100644 --- a/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs +++ b/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs @@ -1,13 +1,13 @@ namespace FunctionalTests.Services.Marketing { - using Microsoft.eShopOnContainers.Services.Marketing.API; - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Builder; using FunctionalTests.Middleware; + using Microsoft.AspNetCore.Builder; + using Microsoft.eShopOnContainers.Services.Marketing.API; + using Microsoft.Extensions.Configuration; public class MarketingTestsStartup : Startup { - public MarketingTestsStartup(IHostingEnvironment env) : base(env) + public MarketingTestsStartup(IConfiguration configuration) : base(configuration) { }