File tree Expand file tree Collapse file tree 4 files changed +36
-4
lines changed
Ocelot.UnitTests/Responder Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public int Map(List<Error> errors)
42
42
43
43
if ( errors . Any ( e => e . Code == OcelotErrorCode . UnableToCompleteRequestError ) )
44
44
{
45
- return 500 ;
45
+ return 502 ;
46
46
}
47
47
48
48
return 404 ;
Original file line number Diff line number Diff line change @@ -16,6 +16,38 @@ public ReturnsErrorTests()
16
16
{
17
17
_serviceHandler = new ServiceHandler ( ) ;
18
18
_steps = new Steps ( ) ;
19
+ }
20
+
21
+ [ Fact ]
22
+ public void should_return_bad_gateway_error_if_downstream_service_doesnt_respond ( )
23
+ {
24
+ var configuration = new FileConfiguration
25
+ {
26
+ ReRoutes = new List < FileReRoute >
27
+ {
28
+ new FileReRoute
29
+ {
30
+ DownstreamPathTemplate = "/" ,
31
+ UpstreamPathTemplate = "/" ,
32
+ UpstreamHttpMethod = new List < string > { "Get" } ,
33
+ DownstreamHostAndPorts = new List < FileHostAndPort >
34
+ {
35
+ new FileHostAndPort
36
+ {
37
+ Host = "localhost" ,
38
+ Port = 53876 ,
39
+ } ,
40
+ } ,
41
+ DownstreamScheme = "http" ,
42
+ } ,
43
+ } ,
44
+ } ;
45
+
46
+ this . Given ( x => _steps . GivenThereIsAConfiguration ( configuration ) )
47
+ . And ( x => _steps . GivenOcelotIsRunning ( ) )
48
+ . When ( x => _steps . WhenIGetUrlOnTheApiGateway ( "/" ) )
49
+ . Then ( x => _steps . ThenTheStatusCodeShouldBe ( HttpStatusCode . BadGateway ) )
50
+ . BDDfy ( ) ;
19
51
}
20
52
21
53
[ Fact ]
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public void should_not_dangerous_accept_any_server_certificate_validator()
89
89
. And ( x => _steps . GivenThereIsAConfiguration ( configuration ) )
90
90
. And ( x => _steps . GivenOcelotIsRunning ( ) )
91
91
. When ( x => _steps . WhenIGetUrlOnTheApiGateway ( "/" ) )
92
- . Then ( x => _steps . ThenTheStatusCodeShouldBe ( HttpStatusCode . InternalServerError ) )
92
+ . Then ( x => _steps . ThenTheStatusCodeShouldBe ( HttpStatusCode . BadGateway ) )
93
93
. BDDfy ( ) ;
94
94
}
95
95
Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ public void should_return_service_unavailable(OcelotErrorCode errorCode)
47
47
48
48
[ Theory ]
49
49
[ InlineData ( OcelotErrorCode . UnableToCompleteRequestError ) ]
50
- public void should_return_internal_server_error ( OcelotErrorCode errorCode )
50
+ public void should_return_bad_gateway_error ( OcelotErrorCode errorCode )
51
51
{
52
- ShouldMapErrorToStatusCode ( errorCode , HttpStatusCode . InternalServerError ) ;
52
+ ShouldMapErrorToStatusCode ( errorCode , HttpStatusCode . BadGateway ) ;
53
53
}
54
54
55
55
[ Theory ]
You can’t perform that action at this time.
0 commit comments