From cbf1c9b55bb6a2df5c24ef2930ae81896347db78 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Thu, 22 Jan 2026 16:46:52 +0530 Subject: [PATCH 1/5] Added test for upload command with include-dir and dry run --- artifactory_test.go | 53 +++++++++++++++++++++++++++++++++++++++++++++ go.mod | 4 ++-- go.sum | 4 ++-- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/artifactory_test.go b/artifactory_test.go index 2049f3a9f..9a3328f40 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -2920,6 +2920,59 @@ func TestArtifactoryIncludeDirFlatNonEmptyFolderUploadMatchingPattern(t *testing cleanArtifactoryTest() } +func TestArtifactoryUploadWithIncludeDirsAndDryRun(t *testing.T) { + initArtifactoryTest(t, "") + + // Create test directory structure with files and empty directories + dirInnerPath := filepath.Join("inner", "folder") + canonicalPath := tests.Out + fileutils.GetFileSeparator() + dirInnerPath + err := os.MkdirAll(canonicalPath, 0777) + assert.NoError(t, err) + + // Create a test file in the nested directory + testFile := filepath.Join(canonicalPath, "test.txt") + err = os.WriteFile(testFile, []byte("test content"), 0644) + assert.NoError(t, err) + + // Create an empty directory + emptyDirPath := tests.Out + fileutils.GetFileSeparator() + "empty" + err = os.MkdirAll(emptyDirPath, 0777) + assert.NoError(t, err) + + // Upload with include-dirs and dry-run - should not upload anything + runRt(t, "upload", tests.Out+"/", tests.RtRepo1, "--recursive=true", "--include-dirs=true", "--flat=false", "--dry-run") + + // Verify nothing was uploaded by searching for files and directories + searchFilePath, err := tests.CreateSpec(tests.SearchRepo1IncludeDirs) + assert.NoError(t, err) + + // Search should return empty results since dry-run prevents actual upload + resultItems := searchItemsInArtifactory(t, tests.SearchRepo1IncludeDirs) + assert.Empty(t, resultItems, "Files should not be uploaded with dry-run flag") + + // Verify empty directory was not created + verifyDoesntExistInArtifactory(searchFilePath, t) + + // Now upload without dry-run - should upload files and directories + runRt(t, "upload", tests.Out+"/", tests.RtRepo1, "--recursive=true", "--include-dirs=true", "--flat=false") + + // Verify files and directories were uploaded + resultItems = searchItemsInArtifactory(t, tests.SearchRepo1IncludeDirs) + assert.NotEmpty(t, resultItems, "Files and directories should be uploaded without dry-run") + + // Verify we can download the uploaded structure + clientTestUtils.RemoveAllAndAssert(t, tests.Out) + runRt(t, "download", tests.RtRepo1, tests.Out+"/", "--include-dirs=true", "--recursive=true") + + // Verify the directory structure was downloaded + assert.True(t, fileutils.IsPathExists(filepath.Join(tests.Out, "inner", "folder", "test.txt"), false), + "File should exist after download") + assert.True(t, fileutils.IsPathExists(filepath.Join(tests.Out, "empty"), false), + "Empty directory should exist after download") + + cleanArtifactoryTest() +} + func TestArtifactoryDirectDownload(t *testing.T) { initArtifactoryTest(t, "") diff --git a/go.mod b/go.mod index e42be5e90..0ef40358a 100644 --- a/go.mod +++ b/go.mod @@ -284,8 +284,8 @@ replace github.com/gfleury/go-bitbucket-v1 => github.com/gfleury/go-bitbucket-v1 //replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core -// replace github.com/jfrog/jfrog-cli-artifactory => github.com/fluxxBot/jfrog-cli-artifactory v0.0.0-20260105073552-ae4f86048a11 -// +replace github.com/jfrog/jfrog-cli-artifactory => github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260122111128-8279efc20131 + //replace github.com/jfrog/build-info-go => github.com/fluxxBot/build-info-go v1.10.10-0.20260105070825-d3f36f619ba5 // //replace github.com/jfrog/jfrog-cli-core/v2 => github.com/fluxxBot/jfrog-cli-core/v2 v2.58.1-0.20260105065921-c6488910f44c diff --git a/go.sum b/go.sum index d3b15d43c..d23207a71 100644 --- a/go.sum +++ b/go.sum @@ -1216,8 +1216,6 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260107143435-b30ede954432 h1:6eOOs+326IrWLVA+ghDDudJmN3Nt8lxPl11eOu8vtPE= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260107143435-b30ede954432/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260120063955-c654c159290e h1:F/VQ7UJ4jaEr9tLJ8jLfy4BF4Obhhd0pWu007SBSHt8= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260120063955-c654c159290e/go.mod h1:LbhCULfa/eIPSXNgQ5Xw8BIZRmJ0qfF2I4sPa7AHXkY= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260112010739-87fc7275623c h1:K9anqOZ7ASxlsijsl9u4jh92wqqIvJA4kTYfXrcOmJA= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260112010739-87fc7275623c/go.mod h1:+Hnaikp/xCSPD/q7txxRy4Zc0wzjW/usrCSf+6uONSQ= github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251225153025-9d8ac181d615 h1:y5an0bojHL00ipHP1QuBUrVcP+XK+yZHHOJ/r1I0RUM= @@ -1327,6 +1325,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260122111128-8279efc20131 h1:WA0b1SbaAUQWy1V7rDNe21xVhyIpgmglX+LZxXXzOwg= +github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260122111128-8279efc20131/go.mod h1:LbhCULfa/eIPSXNgQ5Xw8BIZRmJ0qfF2I4sPa7AHXkY= github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc= github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= From ea93119729b55920d7a2b9d0dd2dd59360913fd1 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Thu, 22 Jan 2026 18:19:04 +0530 Subject: [PATCH 2/5] Added test for upload command with include-dir and dry run --- artifactory_test.go | 57 +++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/artifactory_test.go b/artifactory_test.go index 9a3328f40..b2c132f67 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -2923,6 +2923,9 @@ func TestArtifactoryIncludeDirFlatNonEmptyFolderUploadMatchingPattern(t *testing func TestArtifactoryUploadWithIncludeDirsAndDryRun(t *testing.T) { initArtifactoryTest(t, "") + // Use a unique subdirectory in the repo to avoid conflicts + uploadPath := "dry-run-test" + // Create test directory structure with files and empty directories dirInnerPath := filepath.Join("inner", "folder") canonicalPath := tests.Out + fileutils.GetFileSeparator() + dirInnerPath @@ -2939,32 +2942,56 @@ func TestArtifactoryUploadWithIncludeDirsAndDryRun(t *testing.T) { err = os.MkdirAll(emptyDirPath, 0777) assert.NoError(t, err) - // Upload with include-dirs and dry-run - should not upload anything - runRt(t, "upload", tests.Out+"/", tests.RtRepo1, "--recursive=true", "--include-dirs=true", "--flat=false", "--dry-run") + // Upload with include-dirs and dry-run - files should not be uploaded + runRt(t, "upload", tests.Out+"/", tests.RtRepo1+"/"+uploadPath+"/", "--recursive=true", "--include-dirs=true", "--flat=false", "--dry-run") - // Verify nothing was uploaded by searching for files and directories - searchFilePath, err := tests.CreateSpec(tests.SearchRepo1IncludeDirs) + // Search for files specifically (not directories) - dry-run should prevent file uploads + searchSpecBuilder := spec.NewBuilder(). + Pattern(tests.RtRepo1 + "/" + uploadPath + "/*"). + Recursive(true) + searchCmd := generic.NewSearchCommand() + searchCmd.SetServerDetails(serverDetails) + searchCmd.SetSpec(searchSpecBuilder.BuildSpec()) + reader, err := searchCmd.Search() assert.NoError(t, err) - // Search should return empty results since dry-run prevents actual upload - resultItems := searchItemsInArtifactory(t, tests.SearchRepo1IncludeDirs) - assert.Empty(t, resultItems, "Files should not be uploaded with dry-run flag") + var fileItems []utils.SearchResult + for resultItem := new(utils.SearchResult); reader.NextRecord(resultItem) == nil; resultItem = new(utils.SearchResult) { + // Only count files, not directories (directories have type "folder" and size 0) + if resultItem.Type != "folder" { + fileItems = append(fileItems, *resultItem) + } + } + readerGetErrorAndAssert(t, reader) + readerCloseAndAssert(t, reader) - // Verify empty directory was not created - verifyDoesntExistInArtifactory(searchFilePath, t) + // Verify no files were uploaded with dry-run (directories might still be created) + assert.Empty(t, fileItems, "Files should not be uploaded with dry-run flag") // Now upload without dry-run - should upload files and directories - runRt(t, "upload", tests.Out+"/", tests.RtRepo1, "--recursive=true", "--include-dirs=true", "--flat=false") + runRt(t, "upload", tests.Out+"/", tests.RtRepo1+"/"+uploadPath+"/", "--recursive=true", "--include-dirs=true", "--flat=false") - // Verify files and directories were uploaded - resultItems = searchItemsInArtifactory(t, tests.SearchRepo1IncludeDirs) - assert.NotEmpty(t, resultItems, "Files and directories should be uploaded without dry-run") + // Verify files were uploaded + reader, err = searchCmd.Search() + assert.NoError(t, err) + + fileItems = []utils.SearchResult{} + for resultItem := new(utils.SearchResult); reader.NextRecord(resultItem) == nil; resultItem = new(utils.SearchResult) { + if resultItem.Type != "folder" { + fileItems = append(fileItems, *resultItem) + } + } + readerGetErrorAndAssert(t, reader) + readerCloseAndAssert(t, reader) + + assert.NotEmpty(t, fileItems, "Files should be uploaded without dry-run") + assert.GreaterOrEqual(t, len(fileItems), 1, "At least one file should be uploaded") // Verify we can download the uploaded structure clientTestUtils.RemoveAllAndAssert(t, tests.Out) - runRt(t, "download", tests.RtRepo1, tests.Out+"/", "--include-dirs=true", "--recursive=true") + runRt(t, "download", tests.RtRepo1+"/"+uploadPath+"/", tests.Out+"/", "--include-dirs=true", "--recursive=true") - // Verify the directory structure was downloaded + // Verify the directory structure was downloaded (accounting for the upload path) assert.True(t, fileutils.IsPathExists(filepath.Join(tests.Out, "inner", "folder", "test.txt"), false), "File should exist after download") assert.True(t, fileutils.IsPathExists(filepath.Join(tests.Out, "empty"), false), From 3ae56e470c0b66bf61cca86e9c872de133511654 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Thu, 22 Jan 2026 20:02:01 +0530 Subject: [PATCH 3/5] Added test for upload command with include-dir and dry run --- artifactory_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/artifactory_test.go b/artifactory_test.go index b2c132f67..9ba575230 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -2991,11 +2991,14 @@ func TestArtifactoryUploadWithIncludeDirsAndDryRun(t *testing.T) { clientTestUtils.RemoveAllAndAssert(t, tests.Out) runRt(t, "download", tests.RtRepo1+"/"+uploadPath+"/", tests.Out+"/", "--include-dirs=true", "--recursive=true") - // Verify the directory structure was downloaded (accounting for the upload path) - assert.True(t, fileutils.IsPathExists(filepath.Join(tests.Out, "inner", "folder", "test.txt"), false), - "File should exist after download") - assert.True(t, fileutils.IsPathExists(filepath.Join(tests.Out, "empty"), false), - "Empty directory should exist after download") + // Verify the directory structure was downloaded + // The upload path preserves the "out/" directory, so files are at dry-run-test/out/... + expectedFilePath := filepath.Join(tests.Out, uploadPath, "out", "inner", "folder", "test.txt") + assert.True(t, fileutils.IsPathExists(expectedFilePath, false), + "File should exist after download at: %s", expectedFilePath) + expectedEmptyDirPath := filepath.Join(tests.Out, uploadPath, "out", "empty") + assert.True(t, fileutils.IsPathExists(expectedEmptyDirPath, false), + "Empty directory should exist after download at: %s", expectedEmptyDirPath) cleanArtifactoryTest() } From 7a6e4617d3ed4804aef474f7506e9a21ddc5cba5 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Fri, 23 Jan 2026 14:08:18 +0530 Subject: [PATCH 4/5] Updating artifactory version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0ef40358a..25c8a3538 100644 --- a/go.mod +++ b/go.mod @@ -284,7 +284,7 @@ replace github.com/gfleury/go-bitbucket-v1 => github.com/gfleury/go-bitbucket-v1 //replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core -replace github.com/jfrog/jfrog-cli-artifactory => github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260122111128-8279efc20131 +replace github.com/jfrog/jfrog-cli-artifactory => github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260123083202-f0e587e52be3 //replace github.com/jfrog/build-info-go => github.com/fluxxBot/build-info-go v1.10.10-0.20260105070825-d3f36f619ba5 // diff --git a/go.sum b/go.sum index d23207a71..df7f771c7 100644 --- a/go.sum +++ b/go.sum @@ -1325,8 +1325,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260122111128-8279efc20131 h1:WA0b1SbaAUQWy1V7rDNe21xVhyIpgmglX+LZxXXzOwg= -github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260122111128-8279efc20131/go.mod h1:LbhCULfa/eIPSXNgQ5Xw8BIZRmJ0qfF2I4sPa7AHXkY= +github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260123083202-f0e587e52be3 h1:hZ7fln9rX37P3iayKw+aB//G7R7oE8YTR+rNSaP/2wk= +github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260123083202-f0e587e52be3/go.mod h1:LbhCULfa/eIPSXNgQ5Xw8BIZRmJ0qfF2I4sPa7AHXkY= github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc= github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= From 9832af6303c0f98f1a96c637205930649020f79d Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Tue, 27 Jan 2026 19:20:22 +0530 Subject: [PATCH 5/5] Updated jfrog-cli-artifactory version in go.mod and go.sum --- go.mod | 6 ++---- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 25c8a3538..ce6223dec 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/jfrog/build-info-go v1.13.1-0.20260120103048-d7f367bfa36e github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-cli-application v1.0.2-0.20260107143435-b30ede954432 - github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260120063955-c654c159290e + github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260127133717-20240af03a4c github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260112010739-87fc7275623c github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251225153025-9d8ac181d615 github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e @@ -284,10 +284,8 @@ replace github.com/gfleury/go-bitbucket-v1 => github.com/gfleury/go-bitbucket-v1 //replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core -replace github.com/jfrog/jfrog-cli-artifactory => github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260123083202-f0e587e52be3 - //replace github.com/jfrog/build-info-go => github.com/fluxxBot/build-info-go v1.10.10-0.20260105070825-d3f36f619ba5 -// + //replace github.com/jfrog/jfrog-cli-core/v2 => github.com/fluxxBot/jfrog-cli-core/v2 v2.58.1-0.20260105065921-c6488910f44c //replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.54.2-0.20251007084958-5eeaa42c31a6 diff --git a/go.sum b/go.sum index df7f771c7..90fcbe00f 100644 --- a/go.sum +++ b/go.sum @@ -1216,6 +1216,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260107143435-b30ede954432 h1:6eOOs+326IrWLVA+ghDDudJmN3Nt8lxPl11eOu8vtPE= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260107143435-b30ede954432/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260127133717-20240af03a4c h1:czaLFCx8wRuO0ixOFgEWYNX2L9UQdcBP71r391LQ3nc= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260127133717-20240af03a4c/go.mod h1:ANFZOB4AX+Voo24l1BO8bVvN76m3ZViR1QaK5u3QDgE= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260112010739-87fc7275623c h1:K9anqOZ7ASxlsijsl9u4jh92wqqIvJA4kTYfXrcOmJA= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260112010739-87fc7275623c/go.mod h1:+Hnaikp/xCSPD/q7txxRy4Zc0wzjW/usrCSf+6uONSQ= github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251225153025-9d8ac181d615 h1:y5an0bojHL00ipHP1QuBUrVcP+XK+yZHHOJ/r1I0RUM= @@ -1325,8 +1327,6 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260123083202-f0e587e52be3 h1:hZ7fln9rX37P3iayKw+aB//G7R7oE8YTR+rNSaP/2wk= -github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260123083202-f0e587e52be3/go.mod h1:LbhCULfa/eIPSXNgQ5Xw8BIZRmJ0qfF2I4sPa7AHXkY= github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc= github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=