Skip to content

Commit

Permalink
chore: simplify test tempdir (argoproj#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>
Signed-off-by: wojtekidd <wojtek.cichon@protonmail.com>
  • Loading branch information
crenshaw-dev authored and wojtekidd committed Apr 25, 2022
1 parent 3f9c939 commit 61cf52f
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 61cf52f

Please sign in to comment.