diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 91cbe6cad..4a6e9ebdc 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,8 +1,31 @@ -Technical release, version {0} +## đŸ”Ĩ Hot fixing v[23.3](https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0) (version {0}) aka [Blue Olympic Balumbes](https://www.youtube.com/live/j-Ou-ggS718?si=fPPwmOwjYEZq70H9&t=9518) release +> Codenamed: **[Blue Olympic Fiend](https://www.youtube.com/live/j-Ou-ggS718?si=fPPwmOwjYEZq70H9&t=9518)** +> Read the Docs: [Ocelot 23.3](https://ocelot.readthedocs.io/en/{0}/) +> Hot fixed versions: [23.3.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0), [23.3.3](https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.3) +> Milestone: [v23.3 Hotfixes](https://github.com/ThreeMammals/Ocelot/milestone/8) -### Breaking changes +❤ī¸ A heartfelt "Thank You" to [Roman Shevchik](https://github.com/antikorol) and [Massimiliano Innocenti](https://github.com/minnocenti901) for their contributions in testing and reporting the [Service Discovery](https://github.com/ThreeMammals/Ocelot/labels/Service%20Discovery) issues, #2110 and #2119, respectively! -- The `ILoadBalancer` interface: The `Lease` method was renamed to `LeaseAsync`. +### ℹī¸ About +This release delivers a number of bug fixes for the predecessor's [23.3.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0) release, which is full of new features but was not tested well. All bugs were combined into the [v23.3 Hotfixes](https://github.com/ThreeMammals/Ocelot/milestone/8) milestone. + +Following the substantial refactoring of [Service Discovery](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst) providers in the [23.3.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0) release, the community identified and we have acknowledged several [critical service discovery defects](https://github.com/ThreeMammals/Ocelot/issues?q=is%3Aissue+milestone%3A%22v23.3+Hotfixes%22+label%3A%22Service+Discovery%22) with providers such as [Kube](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/kubernetes.rst) and [Consul](https://github.com/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst#consul). The `Kube` provider, while somewhat unstable, remained operational; however, the `Consul` provider was entirely non-functional. + +📓 If your projects rely on the [Service Discovery](https://ocelot.readthedocs.io/en/latest/features/servicediscovery.html) feature and cannot function without it, please upgrade to this version to utilize the full list of features of version [23.3.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0). + +### 🧑‍đŸ’ģ Technical Information +A comprehensive explanation of the technical details would span several pages; therefore, it is advisable for fans of Ocelot to review all pertinent technical information within the issue descriptions associated with [the milestone](https://github.com/ThreeMammals/Ocelot/milestone/8). +Our team has implemented some **Breaking Changes** which we urge you to review carefully (details follow). + +### ⚠ī¸ Breaking Changes +Listed by priority: +- `ILoadBalancer` interface alteration: Method `Lease` is now `LeaseAsync`. Interface FQN: `Ocelot.LoadBalancer.LoadBalancers.ILoadBalancer` - Method FQN: `Ocelot.LoadBalancer.LoadBalancers.ILoadBalancer.LeaseAsync` -- TO BE Written \ No newline at end of file + Method FQN: `Ocelot.LoadBalancer.LoadBalancers.ILoadBalancer.LeaseAsync` +- `DefaultConsulServiceBuilder` constructor modification: The first parameter's type has been changed from `Func` to `IHttpContextAccessor`. + Class FQN: `Ocelot.Provider.Consul.DefaultConsulServiceBuilder` + Constructor signature: `public DefaultConsulServiceBuilder(IHttpContextAccessor contextAccessor, IConsulClientFactory clientFactory, IOcelotLoggerFactory loggerFactory)` +- Adjustments to `Lease` type: The `Lease` has been restructured from a class to a structure and elevated in the namespace hierarchy. + Struct FQN: `Ocelot.LoadBalancer.Lease` + +📓 Should your [custom solutions](https://ocelot.readthedocs.io/en/latest/search.html?q=custom) involve overriding default Ocelot classes and their behavior, redevelopment or at least recompilation of the solution, followed by deployment, will be necessary. diff --git a/build.cake b/build.cake index f37ee080f..e72e7425d 100644 --- a/build.cake +++ b/build.cake @@ -3,7 +3,7 @@ #tool nuget:?package=ReportGenerator&version=5.2.4 #addin nuget:?package=Newtonsoft.Json&version=13.0.3 #addin nuget:?package=System.Text.Encodings.Web&version=8.0.0 -#addin nuget:?package=Cake.Coveralls&version=1.1.0 +#addin nuget:?package=Cake.Coveralls&version=4.0.0 #r "Spectre.Console" using Spectre.Console diff --git a/docs/index.rst b/docs/index.rst index d208ae6d3..562646151 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,9 +12,11 @@ .. _@thiagoloureiro: https://github.com/thiagoloureiro .. _@bbenameur: https://github.com/bbenameur -.. _23.3: https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0 -.. _23.3.0: https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0 .. _23.2.0: https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0 +.. _23.3.0: https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.0 +.. _23.3.3: https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.3 +.. _23.3.4: https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.4 +.. _23.3: https://github.com/ThreeMammals/Ocelot/releases/tag/23.3.4 .. _954: https://github.com/ThreeMammals/Ocelot/issues/954 .. _957: https://github.com/ThreeMammals/Ocelot/issues/957 @@ -53,14 +55,34 @@ The main features are :doc:`../features/configuration` and :doc:`../features/rou We **do** follow development process which is described in :doc:`../building/releaseprocess`. +Patches +------- + +- `23.3.3`_, on Jun 11, 2024. Technical release with DevOps patch. +- `23.3.4`_, on Oct 3, 2024. Hot fixing version `23.3.0`_, codenamed `Blue Olympic Balumbes `_ release. + + :htm:`
Codename decoding links` + + - **for men** :htm:`→` naked `Blue Olympic Fiend `_ + - **for women** :htm:`→` not a well-dressed woman sings at the opening ceremony, so "Not `Celine Dion `_" + - **for black men** :htm:`→` don't care about White movements, so enjoy `Black Men's Basketball Final `_ in `Paris 2024 `_: + be proud of Stephen Curry, "just give me a ball" boy, as an absolute rockstar, made `shot 1 `_, `shot 2 `_, `shot 3 `_ and final `shot 4 `_. + + :htm:`
` + Release Notes ------------- | Release Tag: `23.3.0`_ -| Release Codename: **Twilight Texas** - :htm:`→` `for men `_ - :htm:`→` `for women `_ - :htm:`→` `for black men `_ +| Release Codename: `Twilight Texas `_ + + :htm:`
Codename decoding links` + + - `for men `_ + - `for women `_ + - `for black men `_ + + :htm:`
` What's new? ^^^^^^^^^^^ @@ -133,8 +155,8 @@ Ocelot extra packages If both `Circuit Breaker`_ and `Timeout`_ have :ref:`qos-configuration` with their respective properties in the ``QoSOptions`` of the route JSON, then the :ref:`qos-circuit-breaker-strategy` will take precedence in the constructed resilience pipeline. For more details, refer to PR `2086`_. -Stabilization aka bug fixing -"""""""""""""""""""""""""""" +Stabilization (bug fixing) +^^^^^^^^^^^^^^^^^^^^^^^^^^ - Fixed `2034`_ in PR `2045`_ by `@raman-m`_ - Fixed `2039`_ in PR `2050`_ by `@PaulARoy`_ @@ -146,8 +168,8 @@ Stabilization aka bug fixing See `all bugs `_ of the `Spring'24 `_ milestone -Documentation for version `23.3`_ -""""""""""""""""""""""""""""""""" +Documentation Summary +^^^^^^^^^^^^^^^^^^^^^ - :doc:`../features/caching`: New :ref:`cch-enablecontenthashing-option` and :ref:`cch-global-configuration` sections - :doc:`../features/configuration`: New :ref:`config-version-policy` and :ref:`config-route-metadata` sections diff --git a/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj b/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj index a05368868..a6733a358 100644 --- a/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj +++ b/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj @@ -7,7 +7,6 @@ - @@ -23,7 +22,7 @@ - + diff --git a/src/Ocelot.Administration/Ocelot.Administration.csproj b/src/Ocelot.Administration/Ocelot.Administration.csproj index 4bb397ab3..e2b8ed463 100644 --- a/src/Ocelot.Administration/Ocelot.Administration.csproj +++ b/src/Ocelot.Administration/Ocelot.Administration.csproj @@ -31,28 +31,28 @@ - + all - + - + - + - + diff --git a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj index 4636540bc..0e8d704ee 100644 --- a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj +++ b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj @@ -31,7 +31,7 @@ - + all @@ -39,7 +39,7 @@ - + @@ -47,12 +47,12 @@ - + - + @@ -60,7 +60,7 @@ - + diff --git a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj index f8149b859..ce4f544bf 100644 --- a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj +++ b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj @@ -30,12 +30,12 @@ - - + + all - + diff --git a/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj b/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj index 826126199..cf9955a40 100644 --- a/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj +++ b/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj @@ -33,11 +33,11 @@ - + all - + diff --git a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj index f45dd07dd..4941194e9 100644 --- a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj +++ b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj @@ -29,9 +29,9 @@ - - - + + + all @@ -39,6 +39,6 @@ - + diff --git a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj index 0d9c84e67..f39ebd8bd 100644 --- a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj +++ b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj @@ -31,12 +31,12 @@ - + all - + - + diff --git a/src/Ocelot.Provider.Polly/OcelotResiliencePipelineKey.cs b/src/Ocelot.Provider.Polly/OcelotResiliencePipelineKey.cs index 528df61ee..0d4a02c71 100644 --- a/src/Ocelot.Provider.Polly/OcelotResiliencePipelineKey.cs +++ b/src/Ocelot.Provider.Polly/OcelotResiliencePipelineKey.cs @@ -5,8 +5,5 @@ namespace Ocelot.Provider.Polly; /// /// Object used to identify a resilience pipeline in . /// -/// -/// Object used to identify a resilience pipeline in -/// /// The key for the resilience pipeline. public record OcelotResiliencePipelineKey(string Key); diff --git a/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj b/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj index 68b90652f..03a57aec8 100644 --- a/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj +++ b/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj @@ -33,11 +33,11 @@ - + all - + diff --git a/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj b/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj index 635e3c77d..14ee22ae9 100644 --- a/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj +++ b/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj @@ -20,7 +20,7 @@ - + all diff --git a/src/Ocelot/Configuration/Validator/RouteFluentValidator.cs b/src/Ocelot/Configuration/Validator/RouteFluentValidator.cs index 900c53189..fbcbd57d2 100644 --- a/src/Ocelot/Configuration/Validator/RouteFluentValidator.cs +++ b/src/Ocelot/Configuration/Validator/RouteFluentValidator.cs @@ -27,7 +27,7 @@ public RouteFluentValidator(IAuthenticationSchemeProvider authenticationSchemePr When(route => !string.IsNullOrEmpty(route.DownstreamPathTemplate), () => { RuleFor(route => route.DownstreamPathTemplate) - .Must(path => path.StartsWith("/")) + .Must(path => path.StartsWith('/')) .WithMessage("{PropertyName} {PropertyValue} doesnt start with forward slash"); RuleFor(route => route.DownstreamPathTemplate) @@ -46,7 +46,7 @@ public RouteFluentValidator(IAuthenticationSchemeProvider authenticationSchemePr .WithMessage("{PropertyName} {PropertyValue} contains double forward slash, Ocelot does not support this at the moment. Please raise an issue in GitHib if you need this feature."); RuleFor(route => route.UpstreamPathTemplate) - .Must(path => path.StartsWith("/")) + .Must(path => path.StartsWith('/')) .WithMessage("{PropertyName} {PropertyValue} doesnt start with forward slash"); RuleFor(route => route.UpstreamPathTemplate) diff --git a/src/Ocelot/DependencyInjection/OcelotBuilder.cs b/src/Ocelot/DependencyInjection/OcelotBuilder.cs index 146ba3c65..1e21081ad 100644 --- a/src/Ocelot/DependencyInjection/OcelotBuilder.cs +++ b/src/Ocelot/DependencyInjection/OcelotBuilder.cs @@ -313,7 +313,6 @@ public IOcelotBuilder AddConfigPlaceholders() return this; } - /// For local implementation purposes, so it MUST NOT be public!.. private IServiceProvider _serviceProvider; // TODO Reuse ActivatorUtilities factories? diff --git a/src/Ocelot/Ocelot.csproj b/src/Ocelot/Ocelot.csproj index b876ca4b7..2171a5f62 100644 --- a/src/Ocelot/Ocelot.csproj +++ b/src/Ocelot/Ocelot.csproj @@ -29,32 +29,32 @@ - + NU1701 - + all - + - - + + - - + + - - + + diff --git a/src/Ocelot/RateLimiting/RateLimiting.cs b/src/Ocelot/RateLimiting/RateLimiting.cs index 9edf4a310..c62e95382 100644 --- a/src/Ocelot/RateLimiting/RateLimiting.cs +++ b/src/Ocelot/RateLimiting/RateLimiting.cs @@ -65,15 +65,18 @@ public virtual RateLimitCounter ProcessRequest(ClientRequestIdentity identity, R public virtual RateLimitCounter Count(RateLimitCounter? entry, RateLimitRule rule) { var now = DateTime.UtcNow; - if (!entry.HasValue) // no entry, start counting + if (!entry.HasValue) { + // no entry, start counting return new RateLimitCounter(now, null, 1); // current request is the 1st one } var counter = entry.Value; var total = counter.TotalRequests + 1; // increment request count var startedAt = counter.StartedAt; - if (startedAt + ToTimespan(rule.Period) >= now) // counting Period is active + + // Counting Period is active + if (startedAt + ToTimespan(rule.Period) >= now) { var exceededAt = total >= rule.Limit && !counter.ExceededAt.HasValue // current request number equals to the limit ? now // the exceeding moment is now, the next request will fail but the current one doesn't @@ -144,7 +147,9 @@ public virtual double RetryAfter(RateLimitCounter counter, RateLimitRule rule) ? defaultSeconds // allow values which are greater or equal to 1 second : rule.PeriodTimespan; // good value var now = DateTime.UtcNow; - if (counter.StartedAt + ToTimespan(rule.Period) >= now) // counting Period is active + + // Counting Period is active + if (counter.StartedAt + ToTimespan(rule.Period) >= now) { return counter.TotalRequests < rule.Limit ? 0.0D // happy path, no need to retry, current request is valid @@ -153,8 +158,8 @@ public virtual double RetryAfter(RateLimitCounter counter, RateLimitRule rule) : periodTimespan; // exceeding not yet detected -> let's ban for whole period } - if (counter.ExceededAt.HasValue && // limit exceeding was happen - counter.ExceededAt + TimeSpan.FromSeconds(periodTimespan) >= now) // ban PeriodTimespan is active + // Limit exceeding was happen && ban PeriodTimespan is active + if (counter.ExceededAt.HasValue && counter.ExceededAt + TimeSpan.FromSeconds(periodTimespan) >= now) { var startedAt = counter.ExceededAt.Value; // ban period was started at double secondsPast = (now - startedAt).TotalSeconds; diff --git a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj index c2b3e01bf..968fd5e79 100644 --- a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj +++ b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj @@ -45,36 +45,36 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - all - + - + - + + - + + + all + - + @@ -87,7 +87,7 @@ - + @@ -100,18 +100,18 @@ - + - + - + - + diff --git a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj index 288d79019..eb906e816 100644 --- a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj +++ b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj @@ -21,24 +21,24 @@ - - + + all - - - - - - - - - - - - + + + + + + + + + + + + - + diff --git a/test/Ocelot.IntegrationTests/AdministrationTests.cs b/test/Ocelot.IntegrationTests/AdministrationTests.cs index 5ae8d0819..d9222c539 100644 --- a/test/Ocelot.IntegrationTests/AdministrationTests.cs +++ b/test/Ocelot.IntegrationTests/AdministrationTests.cs @@ -48,12 +48,10 @@ public AdministrationTests() public void Should_return_response_401_with_call_re_routes_controller() { var configuration = new FileConfiguration(); - - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotIsRunning()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.Unauthorized)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenOcelotIsRunning(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.Unauthorized); } //this seems to be be answer https://github.com/IdentityServer/IdentityServer4/issues/4914 @@ -61,14 +59,12 @@ public void Should_return_response_401_with_call_re_routes_controller() public void Should_return_response_200_with_call_re_routes_controller() { var configuration = new FileConfiguration(); - - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); } [Fact] @@ -87,13 +83,12 @@ public void Should_return_response_200_with_call_re_routes_controller_using_base }, }; - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotIsRunningWithNoWebHostBuilder(_ocelotBaseUrl)) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenOcelotIsRunningWithNoWebHostBuilder(_ocelotBaseUrl); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); } [Fact] @@ -109,14 +104,13 @@ public void Should_return_OK_status_and_multiline_indented_json_response_with_js .AddJsonOptions(options => { options.JsonSerializerOptions.WriteIndented = true; }); }; - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotUsingBuilderIsRunning(customBuilder)) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .Then(x => ThenTheResultHaveMultiLineIndentedJson()) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenOcelotUsingBuilderIsRunning(customBuilder); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + ThenTheResultHaveMultiLineIndentedJson(); } [Fact] @@ -124,15 +118,13 @@ public void Should_be_able_to_use_token_from_ocelot_a_on_ocelot_b() { var configuration = new FileConfiguration(); var port = PortFinder.GetRandomPort(); - - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenIdentityServerSigningEnvironmentalVariablesAreSet()) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenAnotherOcelotIsRunning($"http://localhost:{port}")) - .When(x => WhenIGetUrlOnTheSecondOcelot("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenIdentityServerSigningEnvironmentalVariablesAreSet(); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenAnotherOcelotIsRunning($"http://localhost:{port}"); + WhenIGetUrlOnTheSecondOcelot("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); } [Fact] @@ -194,14 +186,13 @@ public void Should_return_file_configuration() }, }; - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .And(x => ThenTheResponseShouldBe(configuration)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + ThenTheResponseShouldBe(configuration); } [Fact] @@ -283,18 +274,17 @@ public void Should_get_file_configuration_edit_and_post_updated_version() }, }; - this.Given(x => GivenThereIsAConfiguration(initialConfiguration)) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .When(x => WhenIPostOnTheApiGateway("/administration/configuration", updatedConfiguration)) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .And(x => ThenTheResponseShouldBe(updatedConfiguration)) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .And(x => ThenTheResponseShouldBe(updatedConfiguration)) - .And(_ => ThenTheConfigurationIsSavedCorrectly(updatedConfiguration)) - .BDDfy(); + GivenThereIsAConfiguration(initialConfiguration); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + WhenIPostOnTheApiGateway("/administration/configuration", updatedConfiguration); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + ThenTheResponseShouldBe(updatedConfiguration); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheResponseShouldBe(updatedConfiguration); + ThenTheConfigurationIsSavedCorrectly(updatedConfiguration); } [Fact] @@ -323,18 +313,17 @@ public void Should_activate_change_token_when_configuration_is_updated() }, }; - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIPostOnTheApiGateway("/administration/configuration", configuration)) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .And(x => TheChangeTokenShouldBeActive()) - .And(x => ThenTheResponseShouldBe(configuration)) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .And(x => ThenTheResponseShouldBe(configuration)) - .And(_ => ThenTheConfigurationIsSavedCorrectly(configuration)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIPostOnTheApiGateway("/administration/configuration", configuration); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + TheChangeTokenShouldBeActive(); + ThenTheResponseShouldBe(configuration); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheResponseShouldBe(configuration); + ThenTheConfigurationIsSavedCorrectly(configuration); } private void TheChangeTokenShouldBeActive() @@ -406,25 +395,24 @@ public void Should_get_file_configuration_edit_and_post_updated_version_redirect }, }; - this.Given(x => GivenThereIsAConfiguration(initialConfiguration)) - .And(x => GivenThereIsAFooServiceRunningOn($"http://localhost:{fooPort}")) - .And(x => GivenThereIsABarServiceRunningOn($"http://localhost:{barPort}")) - .And(x => GivenOcelotIsRunning()) - .And(x => WhenIGetUrlOnTheApiGateway("/foo")) - .Then(x => ThenTheResponseBodyShouldBe("foo")) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIPostOnTheApiGateway("/administration/configuration", updatedConfiguration)) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .And(x => ThenTheResponseShouldBe(updatedConfiguration)) - .And(x => WhenIGetUrlOnTheApiGateway("/foo")) - .Then(x => ThenTheResponseBodyShouldBe("bar")) - .When(x => WhenIPostOnTheApiGateway("/administration/configuration", initialConfiguration)) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .And(x => ThenTheResponseShouldBe(initialConfiguration)) - .And(x => WhenIGetUrlOnTheApiGateway("/foo")) - .Then(x => ThenTheResponseBodyShouldBe("foo")) - .BDDfy(); + GivenThereIsAConfiguration(initialConfiguration); + GivenThereIsAFooServiceRunningOn($"http://localhost:{fooPort}"); + GivenThereIsABarServiceRunningOn($"http://localhost:{barPort}"); + GivenOcelotIsRunning(); + WhenIGetUrlOnTheApiGateway("/foo"); + ThenTheResponseBodyShouldBe("foo"); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIPostOnTheApiGateway("/administration/configuration", updatedConfiguration); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + ThenTheResponseShouldBe(updatedConfiguration); + WhenIGetUrlOnTheApiGateway("/foo"); + ThenTheResponseBodyShouldBe("bar"); + WhenIPostOnTheApiGateway("/administration/configuration", initialConfiguration); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + ThenTheResponseShouldBe(initialConfiguration); + WhenIGetUrlOnTheApiGateway("/foo"); + ThenTheResponseBodyShouldBe("foo"); } [Fact] @@ -477,14 +465,12 @@ public void Should_clear_region() }; var regionToClear = "gettest"; - - this.Given(x => GivenThereIsAConfiguration(initialConfiguration)) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIDeleteOnTheApiGateway($"/administration/outputcache/{regionToClear}")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.NoContent)) - .BDDfy(); + GivenThereIsAConfiguration(initialConfiguration); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIDeleteOnTheApiGateway($"/administration/outputcache/{regionToClear}"); + ThenTheStatusCodeShouldBe(HttpStatusCode.NoContent); } [Fact] @@ -505,14 +491,13 @@ public void Should_return_response_200_with_call_re_routes_controller_when_using }; }; - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenThereIsAnIdentityServerOn(identityServerRootUrl, "api")) - .And(x => GivenOcelotIsRunningWithIdentityServerSettings(options)) - .And(x => GivenIHaveAToken(identityServerRootUrl)) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIGetUrlOnTheApiGateway("/administration/configuration")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenThereIsAnIdentityServerOn(identityServerRootUrl, "api"); + GivenOcelotIsRunningWithIdentityServerSettings(options); + GivenIHaveAToken(identityServerRootUrl); + GivenIHaveAddedATokenToMyRequest(); + WhenIGetUrlOnTheApiGateway("/administration/configuration"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); } private void GivenIHaveAToken(string url) diff --git a/test/Ocelot.IntegrationTests/CacheManagerTests.cs b/test/Ocelot.IntegrationTests/CacheManagerTests.cs index 6af698854..e0a71672b 100644 --- a/test/Ocelot.IntegrationTests/CacheManagerTests.cs +++ b/test/Ocelot.IntegrationTests/CacheManagerTests.cs @@ -83,13 +83,12 @@ public void should_clear_region() var regionToClear = "gettest"; - this.Given(x => GivenThereIsAConfiguration(initialConfiguration)) - .And(x => GivenOcelotIsRunning()) - .And(x => GivenIHaveAnOcelotToken("/administration")) - .And(x => GivenIHaveAddedATokenToMyRequest()) - .When(x => WhenIDeleteOnTheApiGateway($"/administration/outputcache/{regionToClear}")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.NoContent)) - .BDDfy(); + GivenThereIsAConfiguration(initialConfiguration); + GivenOcelotIsRunning(); + GivenIHaveAnOcelotToken("/administration"); + GivenIHaveAddedATokenToMyRequest(); + WhenIDeleteOnTheApiGateway($"/administration/outputcache/{regionToClear}"); + ThenTheStatusCodeShouldBe(HttpStatusCode.NoContent); } private void GivenIHaveAddedATokenToMyRequest() diff --git a/test/Ocelot.IntegrationTests/HeaderTests.cs b/test/Ocelot.IntegrationTests/HeaderTests.cs index 9072f3189..acef644b4 100644 --- a/test/Ocelot.IntegrationTests/HeaderTests.cs +++ b/test/Ocelot.IntegrationTests/HeaderTests.cs @@ -30,7 +30,7 @@ public HeaderTests() } [Fact] - public void Should_pass_remote_ip_address_if_as_x_forwarded_for_header() + public async Task Should_pass_remote_ip_address_if_as_x_forwarded_for_header() { var port = PortFinder.GetRandomPort(); var configuration = new FileConfiguration @@ -63,13 +63,12 @@ public void Should_pass_remote_ip_address_if_as_x_forwarded_for_header() }, }; - this.Given(x => GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, "X-Forwarded-For")) - .And(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenOcelotIsRunning()) - .When(x => WhenIGetUrlOnTheApiGateway("/")) - .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) - .And(x => ThenXForwardedForIsSet()) - .BDDfy(); + GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, "X-Forwarded-For"); + GivenThereIsAConfiguration(configuration); + GivenOcelotIsRunning(); + await WhenIGetUrlOnTheApiGateway("/"); + ThenTheStatusCodeShouldBe(HttpStatusCode.OK); + ThenXForwardedForIsSet(); } private void GivenThereIsAServiceRunningOn(string url, int statusCode, string headerKey) diff --git a/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj b/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj index 857f2c0b5..0b5f20d0e 100644 --- a/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj +++ b/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj @@ -36,27 +36,27 @@ - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all - - + - + @@ -67,7 +67,7 @@ - + @@ -78,9 +78,9 @@ - + - + @@ -88,6 +88,6 @@ - + diff --git a/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs b/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs index 48eac3686..8e2fc8a51 100644 --- a/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs +++ b/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs @@ -55,12 +55,11 @@ public void Should_return_same_response_for_each_different_header_under_load_to_ }, }; - this.Given(x => GivenThereIsAConfiguration(configuration)) - .And(x => GivenThereIsAServiceRunningOn($"http://localhost:{port}")) - .And(x => GivenOcelotIsRunning()) - .When(x => WhenIGetUrlOnTheApiGatewayMultipleTimesWithDifferentHeaderValues("/", 300)) - .Then(x => ThenTheSameHeaderValuesAreReturnedByTheDownstreamService()) - .BDDfy(); + GivenThereIsAConfiguration(configuration); + GivenThereIsAServiceRunningOn($"http://localhost:{port}"); + GivenOcelotIsRunning(); + WhenIGetUrlOnTheApiGatewayMultipleTimesWithDifferentHeaderValues("/", 300); + ThenTheSameHeaderValuesAreReturnedByTheDownstreamService(); } private void GivenThereIsAServiceRunningOn(string url) diff --git a/test/Ocelot.IntegrationTests/Usings.cs b/test/Ocelot.IntegrationTests/Usings.cs index 504bb7314..5f3d6a446 100644 --- a/test/Ocelot.IntegrationTests/Usings.cs +++ b/test/Ocelot.IntegrationTests/Usings.cs @@ -11,5 +11,4 @@ global using Ocelot; global using Ocelot.Testing; global using Shouldly; -global using TestStack.BDDfy; global using Xunit; diff --git a/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj b/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj index 919f6b913..45b21c6a5 100644 --- a/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj +++ b/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj @@ -32,7 +32,7 @@ - + all @@ -59,7 +59,7 @@ - + @@ -67,6 +67,6 @@ - + diff --git a/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj b/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj index bb3a32301..2ba5a4959 100644 --- a/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj +++ b/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj @@ -49,38 +49,38 @@ - + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all - + - + - + - - + + - + @@ -92,7 +92,7 @@ - + @@ -104,14 +104,17 @@ - + - + + + + diff --git a/test/Ocelot.UnitTests/Polly/PollyResiliencePipelineDelegatingHandlerTests.cs b/test/Ocelot.UnitTests/Polly/PollyResiliencePipelineDelegatingHandlerTests.cs index f144fe305..ec0da4286 100644 --- a/test/Ocelot.UnitTests/Polly/PollyResiliencePipelineDelegatingHandlerTests.cs +++ b/test/Ocelot.UnitTests/Polly/PollyResiliencePipelineDelegatingHandlerTests.cs @@ -33,7 +33,7 @@ public PollyResiliencePipelineDelegatingHandlerTests() } [Fact] - public async void SendAsync_OnePolicy() + public async Task SendAsync_OnePolicy() { // Arrange var fakeResponse = new HttpResponseMessage(HttpStatusCode.NoContent);