From f6cc7b71708bd07b7170c3156757913e6d61fc80 Mon Sep 17 00:00:00 2001 From: Michael Crenshaw Date: Wed, 20 Apr 2022 10:10:00 -0400 Subject: [PATCH 1/2] chore: simplify test tempdir Signed-off-by: Michael Crenshaw --- pkg/apis/application/v1alpha1/types_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/apis/application/v1alpha1/types_test.go b/pkg/apis/application/v1alpha1/types_test.go index 40d66c0ab2719..152e149f0eff4 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", From 29bb39e7f9bce56c6ad4e723fa371e0ecdd95703 Mon Sep 17 00:00:00 2001 From: Michael Crenshaw Date: Wed, 20 Apr 2022 10:15:16 -0400 Subject: [PATCH 2/2] test: add test for traversal Signed-off-by: Michael Crenshaw --- pkg/apis/application/v1alpha1/types_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/apis/application/v1alpha1/types_test.go b/pkg/apis/application/v1alpha1/types_test.go index 152e149f0eff4..bfefa2c935594 100644 --- a/pkg/apis/application/v1alpha1/types_test.go +++ b/pkg/apis/application/v1alpha1/types_test.go @@ -2623,6 +2623,7 @@ func TestGetCAPath(t *testing.T) { "../another/invalid/thing", "./also/invalid", "$invalid/as/well", + "..", } for _, str := range validcert {