From 248929cacdc322411337140895daa1bddf8239dc Mon Sep 17 00:00:00 2001 From: Michael Crenshaw Date: Wed, 20 Apr 2022 08:12:39 -0700 Subject: [PATCH] chore: simplify test tempdir (#9152) * chore: simplify test tempdir Signed-off-by: Michael Crenshaw * test: add test for traversal Signed-off-by: Michael Crenshaw --- pkg/apis/application/v1alpha1/types_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/apis/application/v1alpha1/types_test.go b/pkg/apis/application/v1alpha1/types_test.go index 40d66c0ab2719..bfefa2c935594 100644 --- a/pkg/apis/application/v1alpha1/types_test.go +++ b/pkg/apis/application/v1alpha1/types_test.go @@ -2599,10 +2599,7 @@ func Test_validateGroupName(t *testing.T) { func TestGetCAPath(t *testing.T) { - temppath, err := ioutil.TempDir("", "argocd-cert-test") - if err != nil { - panic(err) - } + temppath := t.TempDir() cert, err := ioutil.ReadFile("../../../../test/fixture/certs/argocd-test-server.crt") if err != nil { panic(err) @@ -2611,7 +2608,6 @@ func TestGetCAPath(t *testing.T) { if err != nil { panic(err) } - defer os.RemoveAll(temppath) os.Setenv(argocdcommon.EnvVarTLSDataPath, temppath) validcert := []string{ "https://foo.example.com", @@ -2627,6 +2623,7 @@ func TestGetCAPath(t *testing.T) { "../another/invalid/thing", "./also/invalid", "$invalid/as/well", + "..", } for _, str := range validcert {