MCPcopy
hub / github.com/cloudflare/cloudflared / TestOriginRequestConfigOverrides

Function TestOriginRequestConfigOverrides

ingress/config_test.go:71–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestOriginRequestConfigOverrides(t *testing.T) {
72 validate := func(ing Ingress) {
73 // Rule 0 didn't override anything, so it inherits the user-specified
74 // root-level configuration.
75 actual0 := ing.Rules[0].Config
76 expected0 := OriginRequestConfig{
77 ConnectTimeout: config.CustomDuration{Duration: 1 * time.Minute},
78 TLSTimeout: config.CustomDuration{Duration: 1 * time.Second},
79 TCPKeepAlive: config.CustomDuration{Duration: 1 * time.Second},
80 NoHappyEyeballs: true,
81 KeepAliveTimeout: config.CustomDuration{Duration: 1 * time.Second},
82 KeepAliveConnections: 1,
83 HTTPHostHeader: "abc",
84 OriginServerName: "a1",
85 CAPool: "/tmp/path0",
86 NoTLSVerify: true,
87 DisableChunkedEncoding: true,
88 BastionMode: true,
89 ProxyAddress: "127.1.2.3",
90 ProxyPort: uint(100),
91 ProxyType: "socks5",
92 IPRules: []ipaccess.Rule{
93 newIPRule(t, "10.0.0.0/8", []int{80, 8080}, false),
94 newIPRule(t, "fc00::/7", []int{443, 4443}, true),
95 },
96 }
97 require.Equal(t, expected0, actual0)
98
99 // Rule 1 overrode all the root-level config.
100 actual1 := ing.Rules[1].Config
101 expected1 := OriginRequestConfig{
102 ConnectTimeout: config.CustomDuration{Duration: 2 * time.Minute},
103 TLSTimeout: config.CustomDuration{Duration: 2 * time.Second},
104 TCPKeepAlive: config.CustomDuration{Duration: 2 * time.Second},
105 NoHappyEyeballs: false,
106 KeepAliveTimeout: config.CustomDuration{Duration: 2 * time.Second},
107 KeepAliveConnections: 2,
108 HTTPHostHeader: "def",
109 OriginServerName: "b2",
110 CAPool: "/tmp/path1",
111 NoTLSVerify: false,
112 DisableChunkedEncoding: false,
113 BastionMode: false,
114 ProxyAddress: "interface",
115 ProxyPort: uint(200),
116 ProxyType: "",
117 IPRules: []ipaccess.Rule{
118 newIPRule(t, "10.0.0.0/16", []int{3000, 3030}, false),
119 newIPRule(t, "192.16.0.0/24", []int{5000, 5050}, true),
120 },
121 }
122 require.Equal(t, expected1, actual1)
123 }
124
125 rulesYAML := `
126originRequest:
127 connectTimeout: 1m
128 tlsTimeout: 1s

Callers

nothing calls this directly

Calls 5

newIPRuleFunction · 0.85
ParseIngressFunction · 0.85
MustReadIngressFunction · 0.85
EqualMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected