Skip to content

Commit

Permalink
When instantiating steps, creating a custom ocelot config file name. …
Browse files Browse the repository at this point in the history
…Finally deleting the newly created config file when disposing the Step instance.
  • Loading branch information
ggnaegi committed Sep 24, 2023
1 parent b7976fc commit 13b4565
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 120 deletions.
16 changes: 7 additions & 9 deletions test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Ocelot.AcceptanceTests
{
public class CustomMiddlewareTests : IDisposable
{
private readonly string _configurationPath;
private readonly Steps _steps;
private int _counter;
private readonly ServiceHandler _serviceHandler;
Expand All @@ -30,7 +29,6 @@ public CustomMiddlewareTests()
_serviceHandler = new ServiceHandler();
_counter = 0;
_steps = new Steps();
_configurationPath = "ocelot.json";
}

[Fact]
Expand Down Expand Up @@ -70,7 +68,7 @@ public void should_call_pre_query_string_builder_middleware()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, string.Empty))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
Expand Down Expand Up @@ -115,7 +113,7 @@ public void should_call_authorization_middleware()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, string.Empty))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
Expand Down Expand Up @@ -160,7 +158,7 @@ public void should_call_authentication_middleware()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, string.Empty))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
Expand Down Expand Up @@ -205,7 +203,7 @@ public void should_call_pre_error_middleware()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, string.Empty))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
Expand Down Expand Up @@ -250,7 +248,7 @@ public void should_call_pre_authorization_middleware()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, string.Empty))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
Expand Down Expand Up @@ -295,7 +293,7 @@ public void should_call_pre_http_authentication_middleware()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, string.Empty))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
Expand Down Expand Up @@ -344,7 +342,7 @@ public void should_fix_issue_237()
};

this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, "/test"))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenThereIsAConfiguration(fileConfiguration))
.And(x => _steps.GivenOcelotIsRunningWithMiddleareBeforePipeline<FakeMiddleware>(callback))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.NotFound))
Expand Down
Loading

0 comments on commit 13b4565

Please sign in to comment.