mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-25 08:12:50 +08:00

* #568 Ocelot wont start if QoSOptions specified and no QoS DelegatingHandler registered e.g. no use of Ocelot.Provider.Polly. Also adds a NoQosDelegatingHandler and logs an error if ive missed something and the user can get to making the request * #568 sadly something wierd with IServiceProvider and FluentValidation so I'm just defaulting to warning and noqosdelegatinghandler if someone doesnt register but provides options, also added basic in memory cache in case people dont use a specific package
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
namespace Ocelot.AcceptanceTests
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Ocelot.Configuration.File;
|
|
using TestStack.BDDfy;
|
|
using Xunit;
|
|
|
|
public class ReturnsErrorTests : IDisposable
|
|
{
|
|
private readonly Steps _steps;
|
|
private readonly ServiceHandler _serviceHandler;
|
|
|
|
public ReturnsErrorTests()
|
|
{
|
|
_serviceHandler = new ServiceHandler();
|
|
_steps = new Steps();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_return_internal_server_error_if_downstream_service_returns_internal_server_error()
|
|
{
|
|
var configuration = new FileConfiguration
|
|
{
|
|
ReRoutes = new List<FileReRoute>
|
|
{
|
|
new FileReRoute
|
|
{
|
|
DownstreamPathTemplate = "/",
|
|
UpstreamPathTemplate = "/",
|
|
UpstreamHttpMethod = new List<string> { "Get" },
|
|
DownstreamHostAndPorts = new List<FileHostAndPort>
|
|
{
|
|
new FileHostAndPort
|
|
{
|
|
Host = "localhost",
|
|
Port = 53876,
|
|
}
|
|
},
|
|
DownstreamScheme = "http",
|
|
}
|
|
}
|
|
};
|
|
|
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53876"))
|
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
|
.And(x => _steps.GivenOcelotIsRunning())
|
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.InternalServerError))
|
|
.BDDfy();
|
|
}
|
|
|
|
private void GivenThereIsAServiceRunningOn(string url)
|
|
{
|
|
_serviceHandler.GivenThereIsAServiceRunningOn(url, context => throw new Exception("BLAMMMM"));
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_serviceHandler?.Dispose();
|
|
_steps.Dispose();
|
|
}
|
|
}
|
|
}
|