test(tls): make keylog path test portable (#8311)

Directory permission checks can be bypassed by privileged users and may
behave differently on filesystems with nonstandard permission semantics.

Make the bad-path case deterministic so TLS keylog tests remain portable
across supported environments.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
Ville Vesilehto
2026-07-19 06:11:48 +03:00
committed by GitHub
parent e1f4d0cb90
commit c1fe47bc3a

View File

@@ -2,7 +2,6 @@ package tls
import (
"crypto/tls"
"os"
"path/filepath"
"strings"
"testing"
@@ -102,8 +101,7 @@ func TestTLSKeyLog(t *testing.T) {
t.Run("Bad Path", func(t *testing.T) {
tmpDir := t.TempDir()
os.Chmod(tmpDir, 0000)
input := "tls test_cert.pem test_key.pem test_ca.pem {\nkeylog " + filepath.Join(tmpDir, "tls.log") + "\n}"
input := "tls test_cert.pem test_key.pem test_ca.pem {\nkeylog " + filepath.Join(tmpDir, "missing", "tls.log") + "\n}"
c := caddy.NewTestController("dns", input)
err := setup(c)
if err == nil {