From 9dcbb3d25d8d3e688981d0c8215bd07f38a41557 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Mon, 31 Jul 2023 11:50:44 +0300 Subject: [PATCH 1/4] Upload - Add timezones to each zip file before uploading --- artifactory_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/artifactory_test.go b/artifactory_test.go index bda9e3736..4131a61e8 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -1,6 +1,7 @@ package main import ( + "archive/zip" "bytes" "crypto/tls" "encoding/csv" @@ -4166,6 +4167,38 @@ func TestUploadDeploymentViewWithArchive(t *testing.T) { cleanArtifactoryTest() } +func TestUploadZipAndCheckDeploymentViewWithArchive(t *testing.T) { + initArtifactoryTest(t, "") + + // Create tmp dir + assert.NoError(t, os.Mkdir(tests.Out, 0755)) + wd, err := os.Getwd() + assert.NoError(t, err) + chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, tests.Out) + defer chdirCallback() + + // Create file and a zip + fileName := "dummy_file.txt" + zipName := "test.zip" + assert.NoError(t, os.WriteFile(fileName, nil, 0644)) + + // Upload & download zip file + assert.NoError(t, artifactoryCli.Exec("upload", fileName, path.Join(tests.RtRepo1, zipName), "--archive", "zip")) + assert.NoError(t, artifactoryCli.Exec("download", path.Join(tests.RtRepo1, zipName))) + + // Check for time-zone offset for each file in the zip + r, err := zip.OpenReader(zipName) + assert.NoError(t, err) + defer func() { assert.NoError(t, r.Close()) }() + _, sysTimezoneOffset := time.Now().Zone() + for _, file := range r.File { + _, fileTimezoneOffset := file.Modified.Zone() + assert.Equal(t, sysTimezoneOffset, fileTimezoneOffset) + } + + cleanArtifactoryTest() +} + func TestUploadDetailedSummary(t *testing.T) { initArtifactoryTest(t, "") uploadCmd := generic.NewUploadCommand() From 7aa4815f9f5d01809541dd0cc7f0c6f7a84cd687 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Mon, 31 Jul 2023 12:56:29 +0300 Subject: [PATCH 2/4] Replace to my fork --- go.sum | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.sum b/go.sum index 98162a241..dabaf7043 100644 --- a/go.sum +++ b/go.sum @@ -315,6 +315,8 @@ github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/ github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= +github.com/or-geva/jfrog-client-go v0.5.1-0.20230731084716-4faa9868c57d h1:/jhhsCLIe9C7WDG3aq2bWJ4Z1cYPhQf7SaXja3c4UaE= +github.com/or-geva/jfrog-client-go v0.5.1-0.20230731084716-4faa9868c57d/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U= github.com/owenrumney/go-sarif/v2 v2.2.0 h1:1DmZaijK0HBZCR1fgcDSGa7VzYkU9NDmbZ7qC2QfUjE= github.com/owenrumney/go-sarif/v2 v2.2.0/go.mod h1:MSqMMx9WqlBSY7pXoOZWgEsVB4FDNfhcaXDA1j6Sr+w= From dc06dce3412f9a37bb55220c839db336cd927975 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Mon, 31 Jul 2023 15:34:04 +0300 Subject: [PATCH 3/4] Fix test --- artifactory_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artifactory_test.go b/artifactory_test.go index 4131a61e8..1ec968a82 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -4174,6 +4174,7 @@ func TestUploadZipAndCheckDeploymentViewWithArchive(t *testing.T) { assert.NoError(t, os.Mkdir(tests.Out, 0755)) wd, err := os.Getwd() assert.NoError(t, err) + defer cleanArtifactoryTest() chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, tests.Out) defer chdirCallback() @@ -4196,7 +4197,6 @@ func TestUploadZipAndCheckDeploymentViewWithArchive(t *testing.T) { assert.Equal(t, sysTimezoneOffset, fileTimezoneOffset) } - cleanArtifactoryTest() } func TestUploadDetailedSummary(t *testing.T) { From 6fa0e2edbbe09fd3792085082cd593d5c0300901 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Wed, 27 Sep 2023 09:32:23 +0300 Subject: [PATCH 4/4] Update go.sum --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index dabaf7043..98162a241 100644 --- a/go.sum +++ b/go.sum @@ -315,8 +315,6 @@ github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/ github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= -github.com/or-geva/jfrog-client-go v0.5.1-0.20230731084716-4faa9868c57d h1:/jhhsCLIe9C7WDG3aq2bWJ4Z1cYPhQf7SaXja3c4UaE= -github.com/or-geva/jfrog-client-go v0.5.1-0.20230731084716-4faa9868c57d/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U= github.com/owenrumney/go-sarif/v2 v2.2.0 h1:1DmZaijK0HBZCR1fgcDSGa7VzYkU9NDmbZ7qC2QfUjE= github.com/owenrumney/go-sarif/v2 v2.2.0/go.mod h1:MSqMMx9WqlBSY7pXoOZWgEsVB4FDNfhcaXDA1j6Sr+w=