fs/fshttp: fix TestCertificates leaking client cert/key onto global config

This was fixed in this commit in an inelegant way

399bc6a6a6 fshttp: don't send --header values to other hosts on redirect

The current commit fixes it properly with AddConfig.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Shane McCarron
2026-09-05 12:02:36 +01:00
committed by Nick Craig-Wood
co-authored by Claude Opus 5
parent 73119d368f
commit 1b4dea8dac
+2 -8
View File
@@ -172,14 +172,8 @@ func TestCertificates(t *testing.T) {
// Set --client-cert and --client-key in config to // Set --client-cert and --client-key in config to
// a pair of temp files // a pair of temp files
// create a test cert/key pair and write it to the files // create a test cert/key pair and write it to the files
ctx := context.TODO() // Use a private config so the cert paths don't leak into other tests
ci := fs.GetConfig(ctx) ctx, ci := fs.AddConfig(context.TODO())
// Restore the global config for later tests as the temp files
// are removed when this test finishes
oldCert, oldKey := ci.ClientCert, ci.ClientKey
t.Cleanup(func() {
ci.ClientCert, ci.ClientKey = oldCert, oldKey
})
// Create a test certificate and write it to a temp file // Create a test certificate and write it to a temp file
ci.ClientCert = t.TempDir() + "client.cert" ci.ClientCert = t.TempDir() + "client.cert"
ci.ClientKey = t.TempDir() + "client.key" ci.ClientKey = t.TempDir() + "client.key"