Skip to content

Commit 93dfc99

Browse files
authored
chore(customdomains): fail on TCP_DENIED (#2041)
* chore(customdomains): fail on TCP_DENIED * chore(customdomains): fail on TCP_DENIED
1 parent 126f66e commit 93dfc99

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

e2e/proxy_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestProxiedEnvironment(t *testing.T) {
5656
}
5757

5858
t.Cleanup(func() {
59-
outputTCPDeniedLogs(t, tc)
59+
failOnProxyTCPDenied(t, tc)
6060
})
6161

6262
// bootstrap the first node and makes sure it is healthy. also executes the kots
@@ -147,7 +147,7 @@ func TestProxiedCustomCIDR(t *testing.T) {
147147
}
148148

149149
t.Cleanup(func() {
150-
outputTCPDeniedLogs(t, tc)
150+
failOnProxyTCPDenied(t, tc)
151151
})
152152

153153
// bootstrap the first node and makes sure it is healthy. also executes the kots
@@ -246,7 +246,7 @@ func TestInstallWithMITMProxy(t *testing.T) {
246246
}
247247

248248
t.Cleanup(func() {
249-
outputTCPDeniedLogs(t, tc)
249+
failOnProxyTCPDenied(t, tc)
250250
})
251251

252252
// bootstrap the first node and makes sure it is healthy. also executes the kots
@@ -288,11 +288,15 @@ func TestInstallWithMITMProxy(t *testing.T) {
288288
t.Logf("%s: test complete", time.Now().Format(time.RFC3339))
289289
}
290290

291-
func outputTCPDeniedLogs(t *testing.T, tc *lxd.Cluster) {
292-
stdout, _, err := tc.RunCommandOnProxyNode(t, []string{"sh", "-c", "grep -A4 -B4 TCP_DENIED /var/log/squid/access.log || true"})
291+
func failOnProxyTCPDenied(t *testing.T, tc *lxd.Cluster) {
292+
line := []string{"sh", "-c", `grep -A1 TCP_DENIED /var/log/squid/access.log | grep -v speedtest\.net`}
293+
stdout, _, err := tc.RunCommandOnProxyNode(t, line)
293294
if err != nil {
294295
t.Fatalf("fail to check squid access log: %v", err)
295296
}
296297
t.Logf("TCP_DENIED logs:")
297298
t.Log(stdout)
299+
if strings.Contains(stdout, "TCP_DENIED") {
300+
t.Fatalf("TCP_DENIED logs found")
301+
}
298302
}

e2e/restore_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func TestSingleNodeDisasterRecoveryWithProxy(t *testing.T) {
237237
}
238238

239239
t.Cleanup(func() {
240-
outputTCPDeniedLogs(t, tc)
240+
failOnProxyTCPDenied(t, tc)
241241
})
242242

243243
installSingleNodeWithOptions(t, tc, installOptions{

e2e/scripts/enable-squid-whitelist.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ function validate_whitelist() {
6262
fi
6363

6464
# validate that we cannot access google.com (should be blocked)
65-
status_code=$(curl -s -o /dev/null -w "%{http_connect}" -x http://10.0.0.254:3128 https://google.com)
65+
status_code=$(curl -s -o /dev/null -w "%{http_connect}" -x http://10.0.0.254:3128 https://speedtest.net)
6666
if [ "$status_code" -ne 403 ] && [ "$status_code" -ne 407 ]; then
67-
echo "Error: google.com expected status code 403 or 407 (blocked), got $status_code"
67+
echo "Error: speedtest.net expected status code 403 or 407 (blocked), got $status_code"
6868
return 1
6969
fi
7070

0 commit comments

Comments
 (0)