diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs index 55b25cd62..8ece91d56 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs @@ -92,6 +92,7 @@ public static class ServiceCollectionExtensions Version = "v1", Description = "Shopping Aggregator for Mobile Clients" }); + var identityUrl = configuration.GetSection("Identity").GetValue("ExternalUrl"); options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { Type = SecuritySchemeType.OAuth2, @@ -99,8 +100,8 @@ public static class ServiceCollectionExtensions { Implicit = new OpenApiOAuthFlow() { - AuthorizationUrl = new Uri($"{configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), - TokenUrl = new Uri($"{configuration.GetValue("IdentityUrlExternal")}/connect/token"), + AuthorizationUrl = new Uri($"{identityUrl}/connect/authorize"), + TokenUrl = new Uri($"{identityUrl}/connect/token"), Scopes = new Dictionary() { diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json index e240b78f9..b5a1dcc87 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json @@ -1,4 +1,8 @@ { + "Identity": { + "Url": "http://localhost:5105", + "Audience": "mobileshoppingagg" + }, "Logging": { "Debug": { "IncludeScopes": false, diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json index 9f033c482..ce1d6cfbd 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json @@ -8,8 +8,10 @@ "grpcCatalog": "http://localhost:81", "grpcOrdering": "http://localhost:5581" }, - "IdentityUrlExternal": "http://localhost:5105", - "IdentityUrl": "http://localhost:5105", + "Identity": { + "ExternalUrl": "http://localhost:5105", + "Url": "http://localhost:5105", + }, "Logging": { "Debug": { "IncludeScopes": false, diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs index 50df67c3e..691f8975a 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs @@ -96,6 +96,7 @@ public static class ServiceCollectionExtensions Version = "v1", Description = "Shopping Aggregator for Web Clients" }); + var identityUrl = configuration.GetSection("Identity").GetValue("ExternalUrl"); options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { Type = SecuritySchemeType.OAuth2, @@ -103,8 +104,8 @@ public static class ServiceCollectionExtensions { Implicit = new OpenApiOAuthFlow() { - AuthorizationUrl = new Uri($"{configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), - TokenUrl = new Uri($"{configuration.GetValue("IdentityUrlExternal")}/connect/token"), + AuthorizationUrl = new Uri($"{identityUrl}/connect/authorize"), + TokenUrl = new Uri($"{identityUrl}/connect/token"), Scopes = new Dictionary() { { "webshoppingagg", "Shopping Aggregator for Web Clients" } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json index e240b78f9..67de4d78b 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json @@ -1,4 +1,8 @@ { + "Identity": { + "Url": "http://localhost:5105", + "Audience": "webshoppingagg" + }, "Logging": { "Debug": { "IncludeScopes": false, diff --git a/src/Services/Basket/Basket.API/appsettings.Development.json b/src/Services/Basket/Basket.API/appsettings.Development.json index 0c8e39c3c..4088044ae 100644 --- a/src/Services/Basket/Basket.API/appsettings.Development.json +++ b/src/Services/Basket/Basket.API/appsettings.Development.json @@ -1,6 +1,4 @@ { - "IdentityUrlExternal": "http://localhost:5105", - "IdentityUrl": "http://localhost:5105", "ConnectionString": "127.0.0.1", "AzureServiceBusEnabled": false, "EventBusConnection": "localhost" diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index f425b8f17..158aa6809 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -25,6 +25,8 @@ }, "Identity": { "Audience": "basket", + "Url": "http://localhost:5105", + "ExternalUrl": "http://localhost:5105", "Scopes": { "basket": "Basket API" } diff --git a/src/Services/Basket/Basket.FunctionalTests/Base/BasketScenarioBase.cs b/src/Services/Basket/Basket.FunctionalTests/Base/BasketScenarioBase.cs index 8f56d94c3..9f72fec75 100644 --- a/src/Services/Basket/Basket.FunctionalTests/Base/BasketScenarioBase.cs +++ b/src/Services/Basket/Basket.FunctionalTests/Base/BasketScenarioBase.cs @@ -19,6 +19,11 @@ public class BasketScenarioBase { return $"{ApiUrlBase}/{id}"; } + + public static string GetBasketByCustomer(string customerId) + { + return $"{ApiUrlBase}/{customerId}"; + } } public static class Post diff --git a/src/Services/Catalog/Catalog.API/appsettings.json b/src/Services/Catalog/Catalog.API/appsettings.json index 35596836f..3711850cc 100644 --- a/src/Services/Catalog/Catalog.API/appsettings.json +++ b/src/Services/Catalog/Catalog.API/appsettings.json @@ -5,6 +5,14 @@ "ApplicationInsights": { "InstrumentationKey": "" }, + "Identity": { + "Url": "http://localhost:5105", + "ExternalUrl": "http://localhost:5105", + "Audience": "catalog", + "Scopes": { + "catalog": "Catalog API" + } + }, "OpenApi": { "Endpoint": { "Name": "" diff --git a/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs b/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs index ee7bb21a8..c8bd8806b 100644 --- a/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs +++ b/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs @@ -83,4 +83,9 @@ public class CatalogScenariosBase return $"?pageIndex={pageIndex}&pageSize={pageCount}"; } } + + public static class Put + { + public static string UpdateCatalogProduct = "api/v1/catalog/items"; + } } diff --git a/src/Services/Catalog/Catalog.FunctionalTests/appsettings.json b/src/Services/Catalog/Catalog.FunctionalTests/appsettings.json index 2f05bebc8..65abc02e2 100644 --- a/src/Services/Catalog/Catalog.FunctionalTests/appsettings.json +++ b/src/Services/Catalog/Catalog.FunctionalTests/appsettings.json @@ -1,6 +1,10 @@ { "ExternalCatalogBaseUrl": "http://localhost:5101", - "IdentityUrl": "http://localhost:5105", + "Identity": { + "Url": "http://localhost:5105", + "ExternalUrl": "http://localhost:5105", + "Audience": "catalog" + }, "isTest": "true", "PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/", diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index 26ab83a3a..a65e7a246 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -255,7 +255,7 @@ static class CustomExtensionsMethods Description = "The Ordering Service HTTP API" }); - var identityUrl = configuration["IdentityUrlExternal"]; + var identityUrl = configuration.GetSection("Identity")["ExternalUrl"]; options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { diff --git a/src/Services/Ordering/Ordering.API/appsettings.json b/src/Services/Ordering/Ordering.API/appsettings.json index 19a922b58..d920b2d86 100644 --- a/src/Services/Ordering/Ordering.API/appsettings.json +++ b/src/Services/Ordering/Ordering.API/appsettings.json @@ -1,6 +1,10 @@ { "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;TrustServerCertificate=true", - "IdentityUrl": "http://localhost:5105", + "Identity": { + "Url": "http://localhost:5105", + "ExternalUrl": "http://localhost:5105", + "Audience": "orders" + }, "UseCustomizationData": false, "AzureServiceBusEnabled": false, "SubscriptionClientName": "Ordering", @@ -17,4 +21,4 @@ "ClientId": "your-client-id", "ClientSecret": "your-client-secret" } -} + } diff --git a/src/Services/Webhooks/Webhooks.API/Startup.cs b/src/Services/Webhooks/Webhooks.API/Startup.cs index 64cfe62e3..32153a5cf 100644 --- a/src/Services/Webhooks/Webhooks.API/Startup.cs +++ b/src/Services/Webhooks/Webhooks.API/Startup.cs @@ -142,6 +142,7 @@ internal static class CustomExtensionMethods Description = "The Webhooks Microservice HTTP API. This is a simple webhooks CRUD registration entrypoint" }); + var identityUrl = configuration.GetSection("Identity").GetValue("ExternalUrl"); options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { Type = SecuritySchemeType.OAuth2, @@ -149,8 +150,8 @@ internal static class CustomExtensionMethods { Implicit = new OpenApiOAuthFlow() { - AuthorizationUrl = new Uri($"{configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), - TokenUrl = new Uri($"{configuration.GetValue("IdentityUrlExternal")}/connect/token"), + AuthorizationUrl = new Uri($"{identityUrl}/connect/authorize"), + TokenUrl = new Uri($"{identityUrl}/connect/token"), Scopes = new Dictionary() { { "webhooks", "Webhooks API" } diff --git a/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj b/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj index dab397d78..e4b6e2c89 100644 --- a/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj +++ b/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj @@ -11,12 +11,10 @@ - - @@ -32,15 +30,6 @@ Always - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - @@ -56,8 +45,11 @@ + + + diff --git a/src/Tests/Services/Application.FunctionalTests/GlobalUsings.cs b/src/Tests/Services/Application.FunctionalTests/GlobalUsings.cs index 493b29f63..a56d1d34b 100644 --- a/src/Tests/Services/Application.FunctionalTests/GlobalUsings.cs +++ b/src/Tests/Services/Application.FunctionalTests/GlobalUsings.cs @@ -1,19 +1,8 @@ -global using Microsoft.AspNetCore.TestHost; -global using System; +global using System; global using System.Net.Http; global using Microsoft.AspNetCore.Http; global using System.Security.Claims; global using System.Threading.Tasks; -global using Microsoft.AspNetCore.Hosting; -global using Microsoft.Extensions.Configuration; -global using System.IO; -global using System.Reflection; -global using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; -global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; -global using Microsoft.Extensions.DependencyInjection; -global using Microsoft.Extensions.Logging; -global using Microsoft.Extensions.Options; -global using FunctionalTests.Services.Basket; global using Microsoft.eShopOnContainers.Services.Basket.API.Model; global using Microsoft.eShopOnContainers.WebMVC.ViewModels; global using System.Text.Json; @@ -22,12 +11,4 @@ global using System.Linq; global using System.Text; global using WebMVC.Services.ModelDTOs; global using Xunit; -global using Microsoft.eShopOnContainers.Services.Ordering.API; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure; -global using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; -global using FunctionalTests.Services.Catalog; -// This is a bit of a hack, since we need to differentiate each of these app's program -global using BasketProgram = Microsoft.eShopOnContainers.Services.Basket.API.BasketSettings; -global using CatalogProgram = Microsoft.eShopOnContainers.Services.Catalog.API.CatalogSettings; -global using OrderingProgram = Microsoft.eShopOnContainers.Services.Ordering.API.OrderingSettings; diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Basket/BasketScenariosBase.cs b/src/Tests/Services/Application.FunctionalTests/Services/Basket/BasketScenariosBase.cs deleted file mode 100644 index 88ab903bf..000000000 --- a/src/Tests/Services/Application.FunctionalTests/Services/Basket/BasketScenariosBase.cs +++ /dev/null @@ -1,66 +0,0 @@ -using FunctionalTests.Middleware; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.Extensions.Hosting; - -namespace FunctionalTests.Services.Basket; - -public class BasketScenariosBase : WebApplicationFactory -{ - private const string ApiUrlBase = "api/v1/basket"; - - public TestServer CreateServer() - { - return Server; - } - - - protected override IHost CreateHost(IHostBuilder builder) - { - builder.ConfigureServices(servies => - { - servies.AddSingleton(); - }); - - builder.ConfigureAppConfiguration(c => - { - var directory = Path.GetDirectoryName(typeof(BasketScenariosBase).Assembly.Location)!; - - c.AddJsonFile(Path.Combine(directory, "Services/Basket/appsettings.json"), optional: false); - }); - - return base.CreateHost(builder); - } - - public static class Get - { - public static string GetBasket(int id) - { - return $"{ApiUrlBase}/{id}"; - } - - public static string GetBasketByCustomer(string customerId) - { - return $"{ApiUrlBase}/{customerId}"; - } - } - - public static class Post - { - public static string CreateBasket = $"{ApiUrlBase}/"; - public static string CheckoutOrder = $"{ApiUrlBase}/checkout"; - } - - private class AuthStartupFilter : IStartupFilter - { - public Action Configure(Action next) - { - return app => - { - app.UseMiddleware(); - - next(app); - }; - } - } -} diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Basket/appsettings.json b/src/Tests/Services/Application.FunctionalTests/Services/Basket/appsettings.json deleted file mode 100644 index 3ed325899..000000000 --- a/src/Tests/Services/Application.FunctionalTests/Services/Basket/appsettings.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - }, - "IdentityUrl": "http://localhost:5105", - "IdentityUrlExternal": "http://localhost:5105", - "ConnectionString": "127.0.0.1", - "isTest": "true", - "EventBusConnection": "localhost", - "SubscriptionClientName": "Basket" -} diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Catalog/CatalogScenariosBase.cs b/src/Tests/Services/Application.FunctionalTests/Services/Catalog/CatalogScenariosBase.cs deleted file mode 100644 index 830d24d97..000000000 --- a/src/Tests/Services/Application.FunctionalTests/Services/Catalog/CatalogScenariosBase.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace FunctionalTests.Services.Catalog; - -using FunctionalTests.Services.Ordering; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.eShopOnContainers.Services.Catalog.API; -using Microsoft.Extensions.Hosting; - -public class CatalogScenariosBase : WebApplicationFactory -{ - public TestServer CreateServer() - { - Services.MigrateDbContext((context, services) => - { - var env = services.GetService(); - var settings = services.GetService>(); - var logger = services.GetService>(); - - new CatalogContextSeed() - .SeedAsync(context, env, settings, logger) - .Wait(); - }) - .MigrateDbContext((_, __) => { }); - - return Server; - } - - protected override IHost CreateHost(IHostBuilder builder) - { - builder.ConfigureAppConfiguration(c => - { - var directory = Path.GetDirectoryName(typeof(CatalogScenariosBase).Assembly.Location)!; - - c.AddJsonFile(Path.Combine(directory, "Services/Catalog/appsettings.json"), optional: false); - }); - - return base.CreateHost(builder); - } - - public static class Get - { - public static string Orders = "api/v1/orders"; - - public static string Items = "api/v1/catalog/items"; - - public static string ProductByName(string name) - { - return $"api/v1/catalog/items/withname/{name}"; - } - } - - public static class Put - { - public static string UpdateCatalogProduct = "api/v1/catalog/items"; - } -} diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Catalog/appsettings.json b/src/Tests/Services/Application.FunctionalTests/Services/Catalog/appsettings.json deleted file mode 100644 index 708598b8a..000000000 --- a/src/Tests/Services/Application.FunctionalTests/Services/Catalog/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word;Encrypt=False;TrustServerCertificate=true", - "ExternalCatalogBaseUrl": "http://localhost:5101", - "IdentityUrl": "http://localhost:5105", - "isTest": "true", - "EventBusConnection": "localhost", - "PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/", - "SubscriptionClientName": "Catalog" -} diff --git a/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs b/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs index 86466766f..f7b348631 100644 --- a/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs +++ b/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs @@ -1,4 +1,7 @@ namespace FunctionalTests.Services; + +using global::Basket.FunctionalTests.Base; +using global::Catalog.FunctionalTests; using Microsoft.eShopOnContainers.Services.Basket.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel; @@ -12,7 +15,7 @@ public class IntegrationEventsScenarios string userId = "JohnId"; using var catalogServer = new CatalogScenariosBase().CreateServer(); - using var basketServer = new BasketScenariosBase().CreateServer(); + using var basketServer = new BasketScenarioBase().CreateServer(); var catalogClient = catalogServer.CreateClient(); var basketClient = basketServer.CreateClient(); @@ -22,7 +25,7 @@ public class IntegrationEventsScenarios // AND a user basket filled with products var basket = ComposeBasket(userId, originalCatalogProducts.Data.Take(3)); var res = await basketClient.PostAsync( - BasketScenariosBase.Post.CreateBasket, + BasketScenarioBase.Post.Basket, new StringContent(JsonSerializer.Serialize(basket), UTF8Encoding.UTF8, "application/json") ); @@ -60,7 +63,7 @@ public class IntegrationEventsScenarios while (continueLoop && counter < 20) { //get the basket and verify that the price of the modified product is updated - var basketGetResponse = await basketClient.GetAsync(BasketScenariosBase.Get.GetBasketByCustomer(userId)); + var basketGetResponse = await basketClient.GetAsync(BasketScenarioBase.Get.GetBasketByCustomer(userId)); var basketUpdated = JsonSerializer.Deserialize(await basketGetResponse.Content.ReadAsStringAsync(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true @@ -84,7 +87,7 @@ public class IntegrationEventsScenarios private async Task> GetCatalogAsync(HttpClient catalogClient) { - var response = await catalogClient.GetAsync(CatalogScenariosBase.Get.Items); + var response = await catalogClient.GetAsync(CatalogScenariosBase.Get.Items(paginated: false)); var items = await response.Content.ReadAsStringAsync(); return JsonSerializer.Deserialize>(items, new JsonSerializerOptions { diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingScenariosBase.cs b/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingScenariosBase.cs deleted file mode 100644 index 906cf70a5..000000000 --- a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingScenariosBase.cs +++ /dev/null @@ -1,85 +0,0 @@ -using FunctionalTests.Middleware; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.Extensions.Hosting; - -namespace FunctionalTests.Services.Ordering; - -public class OrderingScenariosBase : WebApplicationFactory -{ - public TestServer CreateServer() - { - Services - .MigrateDbContext((context, services) => - { - var env = services.GetService(); - var settings = services.GetService>(); - var logger = services.GetService>(); - - new OrderingContextSeed() - .SeedAsync(context, env, settings, logger) - .Wait(); - }) - .MigrateDbContext((_, __) => { }); - - return Server; - } - - protected override IHost CreateHost(IHostBuilder builder) - { - builder.ConfigureServices(servies => - { - servies.AddSingleton(); - }); - - builder.ConfigureAppConfiguration(c => - { - var directory = Path.GetDirectoryName(typeof(OrderingScenariosBase).Assembly.Location)!; - - c.AddJsonFile(Path.Combine(directory, "Services/Ordering/appsettings.json"), optional: false); - }); - - return base.CreateHost(builder); - } - - public static class Get - { - public static string Orders = "api/v1/orders"; - - public static string OrderBy(int id) - { - return $"api/v1/orders/{id}"; - } - } - - public static class Post - { - public static string AddNewOrder = "api/v1/orders/new"; - } - - public static class Put - { - public static string CancelOrder = "api/v1/orders/cancel"; - } - - public static class Delete - { - public static string OrderBy(int id) - { - return $"api/v1/orders/{id}"; - } - } - - private class AuthStartupFilter : IStartupFilter - { - public Action Configure(Action next) - { - return app => - { - app.UseMiddleware(); - - next(app); - }; - } - } -} diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json b/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json deleted file mode 100644 index 18efe0185..000000000 --- a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/appsettings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;Encrypt=False;TrustServerCertificate=true", - "ExternalCatalogBaseUrl": "http://localhost:5101", - "IdentityUrl": "http://localhost:5105", - "isTest": "true", - "EventBusConnection": "localhost", - "CheckUpdateTime": "30000", - "GracePeriodTime": "1", - "SubscriptionClientName": "Ordering", - "IdentityUrlExternal": "http://localhost:5105" -} diff --git a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingScenarios.cs b/src/Tests/Services/Application.FunctionalTests/Services/OrderingScenarios.cs similarity index 85% rename from src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingScenarios.cs rename to src/Tests/Services/Application.FunctionalTests/Services/OrderingScenarios.cs index 35ee35f1a..e006a6998 100644 --- a/src/Tests/Services/Application.FunctionalTests/Services/Ordering/OrderingScenarios.cs +++ b/src/Tests/Services/Application.FunctionalTests/Services/OrderingScenarios.cs @@ -1,12 +1,15 @@ -namespace FunctionalTests.Services.Ordering; +using Basket.FunctionalTests.Base; +using Ordering.FunctionalTests; -public class OrderingScenarios : OrderingScenariosBase +namespace FunctionalTests.Services.Ordering; + +public class OrderingScenarios { [Fact] public async Task Cancel_basket_and_check_order_status_cancelled() { - using var orderServer = new OrderingScenariosBase().CreateServer(); - using var basketServer = new BasketScenariosBase().CreateServer(); + using var orderServer = new OrderingScenarioBase().CreateServer(); + using var basketServer = new BasketScenarioBase().CreateServer(); // Expected data var cityExpected = $"city-{Guid.NewGuid()}"; var orderStatusExpected = "cancelled"; @@ -19,11 +22,11 @@ public class OrderingScenarios : OrderingScenariosBase { Headers = { { "x-requestid", Guid.NewGuid().ToString() } } }; - await basketClient.PostAsync(BasketScenariosBase.Post.CreateBasket, contentBasket); + await basketClient.PostAsync(BasketScenarioBase.Post.Basket, contentBasket); // AND basket checkout is sent await basketClient.PostAsync( - BasketScenariosBase.Post.CheckoutOrder, + BasketScenarioBase.Post.CheckoutOrder, new StringContent(BuildCheckout(cityExpected), UTF8Encoding.UTF8, "application/json") { Headers = { { "x-requestid", Guid.NewGuid().ToString() } } @@ -31,9 +34,10 @@ public class OrderingScenarios : OrderingScenariosBase // WHEN Order is created in Ordering.api var newOrder = await TryGetNewOrderCreated(cityExpected, orderClient); + Assert.NotNull(newOrder); // AND Order is cancelled in Ordering.api - await orderClient.PutAsync(OrderingScenariosBase.Put.CancelOrder, new StringContent(BuildCancelOrder(newOrder.OrderNumber), UTF8Encoding.UTF8, "application/json") + await orderClient.PutAsync(OrderingScenarioBase.Put.CancelOrder, new StringContent(BuildCancelOrder(newOrder.OrderNumber), UTF8Encoding.UTF8, "application/json") { Headers = { { "x-requestid", Guid.NewGuid().ToString() } } }); @@ -47,7 +51,7 @@ public class OrderingScenarios : OrderingScenariosBase async Task TryGetOrder(string orderNumber, HttpClient orderClient) { - var ordersGetResponse = await orderClient.GetStringAsync(OrderingScenariosBase.Get.Orders); + var ordersGetResponse = await orderClient.GetStringAsync(OrderingScenarioBase.Get.Orders); var orders = JsonSerializer.Deserialize>(ordersGetResponse, new JsonSerializerOptions { PropertyNameCaseInsensitive = true @@ -64,7 +68,7 @@ public class OrderingScenarios : OrderingScenariosBase while (counter < 20) { //get the orders and verify that the new order has been created - var ordersGetResponse = await orderClient.GetStringAsync(OrderingScenariosBase.Get.Orders); + var ordersGetResponse = await orderClient.GetStringAsync(OrderingScenarioBase.Get.Orders); var orders = JsonSerializer.Deserialize>(ordersGetResponse, new JsonSerializerOptions { PropertyNameCaseInsensitive = true @@ -79,7 +83,7 @@ public class OrderingScenarios : OrderingScenariosBase var lastOrder = orders.OrderByDescending(o => o.Date).First(); int.TryParse(lastOrder.OrderNumber, out int id); - var orderDetails = await orderClient.GetStringAsync(OrderingScenariosBase.Get.OrderBy(id)); + var orderDetails = await orderClient.GetStringAsync(OrderingScenarioBase.Get.OrderBy(id)); order = JsonSerializer.Deserialize(orderDetails, new JsonSerializerOptions { PropertyNameCaseInsensitive = true diff --git a/src/docker-compose.override.yml b/src/docker-compose.override.yml index 20dfee96f..ac2c1872c 100644 --- a/src/docker-compose.override.yml +++ b/src/docker-compose.override.yml @@ -63,8 +63,8 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=${ESHOP_AZURE_REDIS_BASKET_DB:-basketdata} - - identityUrl=http://identity-api - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://identity-api + - Identity__ExternalUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} @@ -106,8 +106,8 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=${ESHOP_AZURE_ORDERING_DB:-Server=sqldata;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;Encrypt=False;TrustServerCertificate=true} - - identityUrl=http://identity-api - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://identity-api + - Identity__ExternalUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} @@ -163,8 +163,8 @@ services: - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - - IdentityUrl=http://identity-api - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://identity-api + - Identity__ExternalUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 ports: - "5113:80" @@ -197,7 +197,8 @@ services: - IdentityUrlHC=http://identity-api/hc - BasketUrlHC=http://basket-api/hc - PaymentUrlHC=http://payment-api/hc - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://identity-api + - Identity__ExternalUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 ports: - "5120:80" @@ -216,7 +217,8 @@ services: - IdentityUrlHC=http://identity-api/hc - BasketUrlHC=http://basket-api/hc - PaymentUrlHC=http://payment-api/hc - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://identity-api + - Identity__ExternalUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 ports: - "5121:80" @@ -269,7 +271,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_URLS=http://0.0.0.0:80 - - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202 - IdentityUrlHC=http://identity-api/hc - UseCustomizationData=True @@ -284,7 +286,7 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - PurchaseUrl=http://webshoppingapigw - - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - SignalrHubUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202 - IdentityUrlHC=http://identity-api/hc - UseCustomizationData=True @@ -298,7 +300,7 @@ services: environment: - ASPNETCORE_URLS=http://0.0.0.0:80 - Token=6168DB8D-DC58-4094-AF24-483278923590 # Webhooks are registered with this token (any value is valid) but the client won't check it - - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - CallBackUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5114 - WebhooksUrl=http://webhooks-api - SelfUrl=http://webhooks-client/ diff --git a/src/docker-compose.prod.yml b/src/docker-compose.prod.yml index 3ff3aa2f2..0bc2cd1d2 100644 --- a/src/docker-compose.prod.yml +++ b/src/docker-compose.prod.yml @@ -21,7 +21,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=${ESHOP_AZURE_REDIS_BASKET_DB:-basket.data} - identityUrl=http://identity-api #Local: You need to open your local dev-machine firewall at range 5100-5110. - - IdentityUrlExternal=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} @@ -75,8 +75,8 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=${ESHOP_AZURE_ORDERING_DB:-Server=sqldata;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word} - - identityUrl=http://identity-api #Local: You need to open your local dev-machine firewall at range 5100-5110. - - IdentityUrlExternal=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 + - Identity__ExternalUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} @@ -111,7 +111,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - IdentityUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. + - Identity__Url=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - PurchaseUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5202 - CatalogUrlHC=http://catalog-api/hc - OrderingUrlHC=http://ordering-api/hc