(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func TestOriginRequestConfigDefaults(t *testing.T) { |
| 273 | validate := func(ing Ingress) { |
| 274 | // Rule 0 didn't override anything, so it inherits the cloudflared defaults |
| 275 | actual0 := ing.Rules[0].Config |
| 276 | expected0 := OriginRequestConfig{ |
| 277 | ConnectTimeout: defaultHTTPConnectTimeout, |
| 278 | TLSTimeout: defaultTLSTimeout, |
| 279 | TCPKeepAlive: defaultTCPKeepAlive, |
| 280 | KeepAliveConnections: defaultKeepAliveConnections, |
| 281 | KeepAliveTimeout: defaultKeepAliveTimeout, |
| 282 | ProxyAddress: defaultProxyAddress, |
| 283 | } |
| 284 | require.Equal(t, expected0, actual0) |
| 285 | |
| 286 | // Rule 1 overrode all defaults. |
| 287 | actual1 := ing.Rules[1].Config |
| 288 | expected1 := OriginRequestConfig{ |
| 289 | ConnectTimeout: config.CustomDuration{Duration: 2 * time.Minute}, |
| 290 | TLSTimeout: config.CustomDuration{Duration: 2 * time.Second}, |
| 291 | TCPKeepAlive: config.CustomDuration{Duration: 2 * time.Second}, |
| 292 | NoHappyEyeballs: false, |
| 293 | KeepAliveTimeout: config.CustomDuration{Duration: 2 * time.Second}, |
| 294 | KeepAliveConnections: 2, |
| 295 | HTTPHostHeader: "def", |
| 296 | OriginServerName: "b2", |
| 297 | CAPool: "/tmp/path1", |
| 298 | NoTLSVerify: false, |
| 299 | DisableChunkedEncoding: false, |
| 300 | BastionMode: false, |
| 301 | ProxyAddress: "interface", |
| 302 | ProxyPort: uint(200), |
| 303 | ProxyType: "", |
| 304 | IPRules: []ipaccess.Rule{ |
| 305 | newIPRule(t, "10.0.0.0/16", []int{3000, 3030}, false), |
| 306 | newIPRule(t, "192.16.0.0/24", []int{5000, 5050}, true), |
| 307 | }, |
| 308 | } |
| 309 | require.Equal(t, expected1, actual1) |
| 310 | } |
| 311 | |
| 312 | rulesYAML := ` |
| 313 | ingress: |
| 314 | - hostname: tun.example.com |
| 315 | service: https://localhost:8000 |
| 316 | - hostname: "*" |
| 317 | service: https://localhost:8001 |
| 318 | originRequest: |
| 319 | connectTimeout: 2m |
| 320 | tlsTimeout: 2s |
| 321 | noHappyEyeballs: false |
| 322 | tcpKeepAlive: 2s |
| 323 | keepAliveConnections: 2 |
| 324 | keepAliveTimeout: 2s |
| 325 | httpHostHeader: def |
| 326 | originServerName: b2 |
| 327 | caPool: /tmp/path1 |
| 328 | noTLSVerify: false |
| 329 | disableChunkedEncoding: false |
nothing calls this directly
no test coverage detected