@@ -5,14 +5,14 @@ namespace Ocelot.AcceptanceTests
5
5
using System . IO ;
6
6
using System . Net ;
7
7
using System . Net . Http ;
8
-
8
+
9
9
using Configuration . File ;
10
-
10
+
11
11
using Microsoft . AspNetCore . Http ;
12
12
using Microsoft . AspNetCore . Server . Kestrel . Core ;
13
-
13
+
14
14
using TestStack . BDDfy ;
15
-
15
+
16
16
using Xunit ;
17
17
18
18
public class HttpTests : IDisposable
@@ -38,7 +38,7 @@ public void should_return_response_200_when_using_http_one()
38
38
new ( )
39
39
{
40
40
DownstreamPathTemplate = "/{url}" ,
41
- DownstreamScheme = "https " ,
41
+ DownstreamScheme = "http " ,
42
42
UpstreamPathTemplate = "/{url}" ,
43
43
UpstreamHttpMethod = new List < string > { "Get" } ,
44
44
DownstreamHostAndPorts = new List < FileHostAndPort >
@@ -51,7 +51,6 @@ public void should_return_response_200_when_using_http_one()
51
51
} ,
52
52
DownstreamHttpMethod = "POST" ,
53
53
DownstreamHttpVersion = "1.0" ,
54
- DangerousAcceptAnyServerCertificateValidator = true
55
54
} ,
56
55
} ,
57
56
} ;
@@ -76,7 +75,7 @@ public void should_return_response_200_when_using_http_one_point_one()
76
75
new ( )
77
76
{
78
77
DownstreamPathTemplate = "/{url}" ,
79
- DownstreamScheme = "https " ,
78
+ DownstreamScheme = "http " ,
80
79
UpstreamPathTemplate = "/{url}" ,
81
80
UpstreamHttpMethod = new List < string > { "Get" } ,
82
81
DownstreamHostAndPorts = new List < FileHostAndPort >
@@ -89,7 +88,6 @@ public void should_return_response_200_when_using_http_one_point_one()
89
88
} ,
90
89
DownstreamHttpMethod = "POST" ,
91
90
DownstreamHttpVersion = "1.1" ,
92
- DangerousAcceptAnyServerCertificateValidator = true
93
91
} ,
94
92
} ,
95
93
} ;
@@ -135,7 +133,7 @@ public void should_return_response_200_when_using_http_two_point_zero()
135
133
const string expected = "here is some content" ;
136
134
var httpContent = new StringContent ( expected ) ;
137
135
138
- this . Given ( x => x . GivenThereIsAServiceRunningOn ( $ "http://localhost:{ port } /", "/" , port , HttpProtocols . Http2 ) )
136
+ this . Given ( x => x . GivenThereIsAServiceUsingHttpsRunningOn ( $ "http://localhost:{ port } /", "/" , port , HttpProtocols . Http2 ) )
139
137
. And ( x => _steps . GivenThereIsAConfiguration ( configuration ) )
140
138
. And ( x => _steps . GivenOcelotIsRunning ( ) )
141
139
. When ( x => _steps . WhenIGetUrlOnTheApiGateway ( "/" , httpContent ) )
@@ -185,6 +183,7 @@ public void should_return_response_502_when_using_http_one_to_talk_to_server_run
185
183
. BDDfy ( ) ;
186
184
}
187
185
186
+ //TODO: does this test make any sense?
188
187
[ Fact ]
189
188
public void should_return_response_200_when_using_http_two_to_talk_to_server_running_http_one_point_one ( )
190
189
{
@@ -197,7 +196,7 @@ public void should_return_response_200_when_using_http_two_to_talk_to_server_run
197
196
new ( )
198
197
{
199
198
DownstreamPathTemplate = "/{url}" ,
200
- DownstreamScheme = "https " ,
199
+ DownstreamScheme = "http " ,
201
200
UpstreamPathTemplate = "/{url}" ,
202
201
UpstreamHttpMethod = new List < string > { "Get" } ,
203
202
DownstreamHostAndPorts = new List < FileHostAndPort >
@@ -209,7 +208,7 @@ public void should_return_response_200_when_using_http_two_to_talk_to_server_run
209
208
} ,
210
209
} ,
211
210
DownstreamHttpMethod = "POST" ,
212
- DownstreamHttpVersion = "2.0 " ,
211
+ DownstreamHttpVersion = "1.1 " ,
213
212
DangerousAcceptAnyServerCertificateValidator = true
214
213
} ,
215
214
} ,
@@ -238,6 +237,17 @@ private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath, int
238
237
} , port , protocols ) ;
239
238
}
240
239
240
+ private void GivenThereIsAServiceUsingHttpsRunningOn ( string baseUrl , string basePath , int port , HttpProtocols protocols )
241
+ {
242
+ _serviceHandler . GivenThereIsAServiceRunningOnUsingHttps ( baseUrl , basePath , async context =>
243
+ {
244
+ context . Response . StatusCode = 200 ;
245
+ var reader = new StreamReader ( context . Request . Body ) ;
246
+ var body = await reader . ReadToEndAsync ( ) ;
247
+ await context . Response . WriteAsync ( body ) ;
248
+ } , port , protocols ) ;
249
+ }
250
+
241
251
public void Dispose ( )
242
252
{
243
253
_serviceHandler . Dispose ( ) ;
0 commit comments