Skip to content

Commit 798fd2e

Browse files
committed
proxy: fix ci
1 parent 0dd3054 commit 798fd2e

3 files changed

Lines changed: 55 additions & 19 deletions

File tree

proxy/proxy_darwin_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build darwin
2+
3+
package proxy_test
4+
5+
import "testing"
6+
7+
// SkipDarwin skips test on macOS systems.
8+
func skipDarwin(tb testing.TB) {
9+
tb.Skipf("skipping; not supported for darwin")
10+
}

proxy/proxy_other_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build !darwin
2+
3+
package proxy_test
4+
5+
import "testing"
6+
7+
// SkipDarwin skips test on macOS systems.
8+
func skipDarwin(tb testing.TB) {}

proxy/proxy_test.go

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ func TestProxy_jiggleVulnerability(t *testing.T) {
231231
Upstreams: []upstream.Upstream{ups},
232232
}
233233

234-
// TODO(f.setrakov): !! Improve test case names or consider not using
235-
// testdata.
234+
// TODO(f.setrakov): !! Imp test case names or consider not using testdata.
236235
testCases := []string{
237236
"1004_client_subnet_option_ecs_with_private_ip_but_querying_public_dns",
238237
"1086_query_for_dnssec_chain_validation_but_cd_1_disables_chain_checking",
@@ -250,7 +249,6 @@ func TestProxy_jiggleVulnerability(t *testing.T) {
250249
"1294_ecs_source_prefix_length_set_to_255_exceeds_ip_address_bits",
251250
"1325_edns_padding_option_at_the_beginning_instead_of_end",
252251
"1326_edns_options_with_duplicate_option_codes",
253-
"1367_query_with_multiple_edns_options_each_claiming_large_lengths",
254252
"1370_query_with_opt_rr_header_complete_but_rdata_truncated",
255253
"1372_query_with_edns_option_option_length_extending_beyond_packet",
256254
"1435_edns_option_chain_with_backward_option_code_ordering",
@@ -290,29 +288,49 @@ func TestProxy_jiggleVulnerability(t *testing.T) {
290288
"996_tiny_udp_payload_size_64_declared_but_rdlength_claims_1000_bytes_of_options",
291289
}
292290

291+
testDataPath := filepath.Join("testdata", t.Name())
293292
for _, name := range testCases {
294-
testDataPath := filepath.Join("testdata", t.Name())
295-
296293
t.Run(name, func(t *testing.T) {
297294
t.Parallel()
298295

299-
p, err := proxy.New(&proxy.Config{
300-
UDPListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)},
301-
UpstreamConfig: upsConf,
302-
Logger: testLogger,
303-
})
304-
require.NoError(t, err)
305-
require.NotNil(t, p)
296+
testJiggleVulnerability(t, filepath.Join(testDataPath, name+".bin"), upsConf)
297+
})
298+
}
306299

307-
servicetest.RequireRun(t, p, testTimeout)
300+
// NOTE: This case must not run on darwin systems by default, because the
301+
// default maximum value of UDP datagrams on such systems is less than the
302+
// actual maximum UDP message size.
303+
//
304+
// TODO(f.setrakov): !! Imp name.
305+
tc := "1367_query_with_multiple_edns_options_each_claiming_large_lengths"
306+
t.Run(tc, func(t *testing.T) {
307+
t.Parallel()
308+
309+
skipDarwin(t)
310+
testJiggleVulnerability(t, filepath.Join(testDataPath, tc+".bin"), upsConf)
311+
})
312+
}
308313

309-
data, err := os.ReadFile(filepath.Join(testDataPath, name+".bin"))
310-
require.NoError(t, err)
314+
// testJiggleVulnerability is a helper that makes sure that proxy correctly
315+
// responds to malformed DNS packets without crashing.
316+
func testJiggleVulnerability(tb testing.TB, dataPath string, upsConf *proxy.UpstreamConfig) {
317+
tb.Helper()
311318

312-
addr := p.Addr(proxy.ProtoUDP)
313-
exchangeData(t, addr.String(), data)
314-
})
315-
}
319+
p, err := proxy.New(&proxy.Config{
320+
UDPListenAddr: []*net.UDPAddr{net.UDPAddrFromAddrPort(localhostAnyPort)},
321+
UpstreamConfig: upsConf,
322+
Logger: testLogger,
323+
})
324+
require.NoError(tb, err)
325+
require.NotNil(tb, p)
326+
327+
servicetest.RequireRun(tb, p, testTimeout)
328+
329+
data, err := os.ReadFile(dataPath)
330+
require.NoError(tb, err)
331+
332+
addr := p.Addr(proxy.ProtoUDP)
333+
exchangeData(tb, addr.String(), data)
316334
}
317335

318336
// exchangeData sends the provided data to a proxy running on addr and checks

0 commit comments

Comments
 (0)