Skip to content

Commit 313135d

Browse files
committed
Pull request 2614: AGDNS-3799-h2c-vuln-test
Squashed commit of the following: commit 43c0748 Merge: 1a9c78d 35f9101 Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 23 17:21:12 2026 +0300 Merge branch 'master' into AGDNS-3799-h2c-vuln-test commit 1a9c78d Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 23 17:09:55 2026 +0300 home: imp docs commit 729d41a Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 23 14:18:26 2026 +0300 home: rm temp logs commit 4ad68ef Merge: 4e33bab b08e587 Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 23 14:04:37 2026 +0300 Merge branch 'master' into AGDNS-3799-h2c-vuln-test commit 4e33bab Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 23 13:41:13 2026 +0300 home: print stack commit 7bcd543 Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 23 13:33:06 2026 +0300 home: add temp log commit cb21e81 Author: f.setrakov <f.setrakov@adguard.com> Date: Tue Apr 21 18:10:30 2026 +0300 home: enable h2c test logs commit f0785d9 Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 16 17:59:40 2026 +0300 home: rm querylog, imp code commit 98fea60 Author: f.setrakov <f.setrakov@adguard.com> Date: Wed Apr 15 19:00:38 2026 +0300 home: use static files for healthcheck commit b01973e Author: f.setrakov <f.setrakov@adguard.com> Date: Wed Apr 15 11:56:26 2026 +0300 home: disable conn reuse commit 4b7ce72 Author: f.setrakov <f.setrakov@adguard.com> Date: Tue Apr 14 23:42:12 2026 +0300 home: increase timeout commit 7ffbc64 Author: f.setrakov <f.setrakov@adguard.com> Date: Tue Apr 14 23:27:02 2026 +0300 home: use /control/status for healthcheck commit bc45ee8 Author: f.setrakov <f.setrakov@adguard.com> Date: Tue Apr 14 18:39:28 2026 +0300 web: fix req body, increase timeouts commit 9130442 Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 9 20:30:30 2026 +0300 home: fix ci, imp style commit be70c8f Author: f.setrakov <f.setrakov@adguard.com> Date: Mon Apr 6 15:51:42 2026 +0300 home: imp test commit 0bff130 Author: f.setrakov <f.setrakov@adguard.com> Date: Thu Apr 2 19:08:44 2026 +0300 home: impl upgrade requests commit 483ed1f Author: f.setrakov <f.setrakov@adguard.com> Date: Fri Mar 27 13:07:07 2026 +0300 home: h2c vuln test draft
1 parent 35f9101 commit 313135d

4 files changed

Lines changed: 384 additions & 37 deletions

File tree

internal/home/clientshttp_internal_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"net/url"
1212
"slices"
1313
"testing"
14-
"time"
1514

1615
"github.com/AdguardTeam/AdGuardHome/internal/client"
1716
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
@@ -22,9 +21,6 @@ import (
2221
"github.com/stretchr/testify/require"
2322
)
2423

25-
// testTimeout is the common timeout for tests and contexts.
26-
const testTimeout = 1 * time.Second
27-
2824
const (
2925
testClientIP1 = "1.1.1.1"
3026
testClientIP2 = "2.2.2.2"

internal/home/home_internal_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66
"net/netip"
77
"testing"
8+
"time"
89

910
"github.com/AdguardTeam/AdGuardHome/internal/agh"
1011
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
@@ -14,6 +15,9 @@ import (
1415
"github.com/stretchr/testify/require"
1516
)
1617

18+
// testTimeout is the common timeout for tests and contexts.
19+
const testTimeout = 1 * time.Second
20+
1721
// testLogger is a common logger for tests.
1822
var testLogger = slogutil.NewDiscardLogger()
1923

@@ -52,7 +56,38 @@ func newTestWeb(
5256
return web
5357
}
5458

59+
// storeGlobals is a test helper function that saves global variables and
60+
// restores them once the test is complete.
61+
//
62+
// The global variables are:
63+
// - [config]
64+
// - [glFilePrefix]
65+
// - [globalContext.clients.storage]
66+
// - [globalContext.dnsServer]
67+
// - [globalContext.web]
68+
//
69+
// TODO(s.chzhen): Remove this once the TLS manager no longer accesses global
70+
// variables. Make tests that use this helper concurrent.
71+
func storeGlobals(tb testing.TB) {
72+
tb.Helper()
73+
74+
prevConfig := config
75+
prefGLFilePrefix := glFilePrefix
76+
storage := globalContext.clients.storage
77+
dnsServer := globalContext.dnsServer
78+
web := globalContext.web
79+
80+
tb.Cleanup(func() {
81+
config = prevConfig
82+
glFilePrefix = prefGLFilePrefix
83+
globalContext.clients.storage = storage
84+
globalContext.dnsServer = dnsServer
85+
globalContext.web = web
86+
})
87+
}
88+
5589
func TestMain(m *testing.M) {
5690
initCmdLineOpts()
91+
5792
testutil.DiscardLogOutput(m)
5893
}

internal/home/tls_internal_test.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -133,39 +133,6 @@ func TestValidateCertificates(t *testing.T) {
133133
})
134134
}
135135

136-
// storeGlobals is a test helper function that saves global variables and
137-
// restores them once the test is complete.
138-
//
139-
// The global variables are:
140-
// - [config]
141-
// - [glFilePrefix]
142-
// - [globalContext.auth]
143-
// - [globalContext.clients.storage]
144-
// - [globalContext.dnsServer]
145-
// - [globalContext.firstRun]
146-
// - [globalContext.mux]
147-
// - [globalContext.web]
148-
//
149-
// TODO(s.chzhen): Remove this once the TLS manager no longer accesses global
150-
// variables. Make tests that use this helper concurrent.
151-
func storeGlobals(tb testing.TB) {
152-
tb.Helper()
153-
154-
prevConfig := config
155-
prefGLFilePrefix := glFilePrefix
156-
storage := globalContext.clients.storage
157-
dnsServer := globalContext.dnsServer
158-
web := globalContext.web
159-
160-
tb.Cleanup(func() {
161-
config = prevConfig
162-
glFilePrefix = prefGLFilePrefix
163-
globalContext.clients.storage = storage
164-
globalContext.dnsServer = dnsServer
165-
globalContext.web = web
166-
})
167-
}
168-
169136
// newCertWithoutIP generates a CA certificate, a leaf certificate without an IP
170137
// address, and the PEM-encoded leaf private key.
171138
func newCertWithoutIP(tb testing.TB) (

0 commit comments

Comments
 (0)