Skip to content

Commit

Permalink
chore: simplify test tempdir (#9152)
Browse files Browse the repository at this point in the history
* chore: simplify test tempdir

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* test: add test for traversal

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
  • Loading branch information
crenshaw-dev authored Apr 20, 2022
1 parent d2f5060 commit 248929c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/apis/application/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand All @@ -2627,6 +2623,7 @@ func TestGetCAPath(t *testing.T) {
"../another/invalid/thing",
"./also/invalid",
"$invalid/as/well",
"..",
}

for _, str := range validcert {
Expand Down

0 comments on commit 248929c

Please sign in to comment.