From 7827a6d428914a63d3a27b49c855ffa7b9ab8a41 Mon Sep 17 00:00:00 2001 From: kfirh Date: Wed, 4 Feb 2026 16:08:14 +0200 Subject: [PATCH 1/3] Added e2e tests for new release bundle finalize command --- go.mod | 2 +- go.sum | 4 +-- lifecycle_test.go | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4ab4625e5..57b723f88 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/jfrog/build-info-go v1.13.1-0.20260130140656-2d0d5593fccf github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-cli-application v1.0.2-0.20260127112223-c5078af84b5a - github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260203090305-f5f8aed71eaf + github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260204122910-dcfb1d59b122 github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260128134755-624b659a398e github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260125120022-1c6f4f382dbb github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e diff --git a/go.sum b/go.sum index e92dc9886..572196e11 100644 --- a/go.sum +++ b/go.sum @@ -1218,8 +1218,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.20260127112223-c5078af84b5a h1:Yvl7XuMoI1cXk3jzB1oWcZvFy5K3aUAIin9o5GRaqzE= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260127112223-c5078af84b5a/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260203090305-f5f8aed71eaf h1:3W7qIxrkJkC1K0vB/By3fVyCkU3qgY9SdHQs7o5RNRo= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260203090305-f5f8aed71eaf/go.mod h1:DkLAN+AvZ4v6jcuUStufi9DuhAS1dvSRJhILJyRa9kg= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260204122910-dcfb1d59b122 h1:fapP2b7hTJbrYuy8P/WSo84nwzYK5FnRaxNonD2NOvc= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260204122910-dcfb1d59b122/go.mod h1:1GKFtQs/5/3HRp1JyMHMQVT9lxzXR+YecO6dWdRThNs= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260128134755-624b659a398e h1:jGtYjWMMfCINDl1JbRtvAijtVwD+j+yvR5BuYMZvRrA= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260128134755-624b659a398e/go.mod h1:+Hnaikp/xCSPD/q7txxRy4Zc0wzjW/usrCSf+6uONSQ= github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260125120022-1c6f4f382dbb h1:4nGzxRxVcXxkFg95jr+zMjESisZGqSYecXfHsA37rpA= diff --git a/lifecycle_test.go b/lifecycle_test.go index e61e76aa2..87ae4b6a7 100644 --- a/lifecycle_test.go +++ b/lifecycle_test.go @@ -569,6 +569,33 @@ func TestReleaseBundleUpdateWithFlags(t *testing.T) { assertRbArtifacts(t, lcManager, tests.LcRbName2, number2, tests.GetExpectedLifecycleUpdateBuild2Artifacts()) } +func TestReleaseBundleFinalize(t *testing.T) { + cleanCallback := initLifecycleTest(t, draftBundleArtifactoryMinVersion) + defer cleanCallback() + lcManager := getLcServiceManager(t) + + deleteBuilds := uploadBuilds(t) + defer deleteBuilds() + + // Create a draft bundle from build 1 + createRbWithFlags(t, "", "", tests.LcBuildName1, number1, tests.LcRbName1, number1, "default", true, true, true) + defer deleteReleaseBundle(t, lcManager, tests.LcRbName1, number1) + assertStatusDraft(t, lcManager, tests.LcRbName1, number1) + assertRbArtifacts(t, lcManager, tests.LcRbName1, number1, tests.GetExpectedLifecycleBuild1Artifacts()) + + // Finalize the draft bundle (the command prints "Release Bundle successfully finalized" on success) + finalizeRbWithFlags(t, tests.LcRbName1, number1, "default", gpgKeyPairName, true) + + // Verify the bundle's current status is COMPLETED after finalize + // Note: We use assertCurrentBundleStatusCompleted (not assertStatusCompleted) because + // the creation status endpoint returns the audit status of the creation operation (DRAFT), + // while we want to verify the bundle's actual current state (COMPLETED after finalize). + assertCurrentBundleStatusCompleted(t, lcManager, tests.LcRbName1, number1) + + // Verify the bundle still exists and contains the same artifacts after finalize + assertRbArtifacts(t, lcManager, tests.LcRbName1, number1, tests.GetExpectedLifecycleBuild1Artifacts()) +} + /*func deleteExportedReleaseBundle(t *testing.T, rbName string) { assert.NoError(t, os.RemoveAll(rbName)) }*/ @@ -719,6 +746,26 @@ func updateRbWithFlags(t *testing.T, specFilePath, rbName, rbVersion, project, s assert.NoError(t, lcCli.Exec(argsAndOptions...)) } +func finalizeRbWithFlags(t *testing.T, rbName, rbVersion, project, signingKey string, sync bool) { + argsAndOptions := []string{ + "rbf", + rbName, + rbVersion, + } + + if signingKey != "" { + argsAndOptions = append(argsAndOptions, getOption(cliutils.SigningKey, signingKey)) + } + + if project != "" { + argsAndOptions = append(argsAndOptions, getOption(cliutils.Project, project)) + } + + argsAndOptions = append(argsAndOptions, getOption(cliutils.Sync, strconv.FormatBool(sync))) + + assert.NoError(t, lcCli.Exec(argsAndOptions...)) +} + /*func exportRb(t *testing.T, rbName, rbVersion, targetPath string) { lcCli.RunCliCmdWithOutput(t, "rbe", rbName, rbVersion, targetPath+"/") exists, err := fileutils.IsDirExists(path.Join(targetPath, rbName), false) @@ -799,6 +846,35 @@ func assertStatusCompletedWithProject(t *testing.T, lcManager *lifecycle.Lifecyc assert.Equal(t, services.Completed, resp.Status) } +// assertCurrentBundleStatusCompleted asserts the bundle's current record status is COMPLETED. +// This differs from assertStatusCompleted which checks the creation operation's audit status. +// Use this after finalize to verify the bundle is now in COMPLETED state. +func assertCurrentBundleStatusCompleted(t *testing.T, lcManager *lifecycle.LifecycleServicesManager, rbName, rbVersion string) { + status, err := getCurrentBundleRecordStatus(lcManager, rbName, rbVersion) + if !assert.NoError(t, err) { + return + } + assert.Equal(t, "COMPLETED", status, "Expected bundle current status to be COMPLETED after finalize") +} + +// getCurrentBundleRecordStatus fetches the current bundle status from the bundle record. +// This returns the actual current state of the bundle, not the creation operation status. +func getCurrentBundleRecordStatus(lcManager *lifecycle.LifecycleServicesManager, rbName, rbVersion string) (string, error) { + params := services.GetSearchOptionalQueryParams{ + Limit: 100, + } + resp, err := lcManager.ReleaseBundlesSearchVersions(rbName, params) + if err != nil { + return "", err + } + for _, bundle := range resp.ReleaseBundles { + if bundle.ReleaseBundleVersion == rbVersion { + return bundle.Status, nil + } + } + return "", fmt.Errorf("bundle version %s/%s not found", rbName, rbVersion) +} + func getLcServiceManager(t *testing.T) *lifecycle.LifecycleServicesManager { lcManager, err := utils.CreateLifecycleServiceManager(lcDetails, false) assert.NoError(t, err) From 8871b200ac38abea0c994d4f65cdbcf8f8c0fa07 Mon Sep 17 00:00:00 2001 From: kfirh Date: Wed, 4 Feb 2026 16:09:03 +0200 Subject: [PATCH 2/3] Added e2e test for finalize release bundle command --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 57b723f88..ed6259aef 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260125120022-1c6f4f382dbb github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e github.com/jfrog/jfrog-cli-security v1.26.0 - github.com/jfrog/jfrog-client-go v1.55.1-0.20260202100450-1b20bddfdb3f + github.com/jfrog/jfrog-client-go v1.55.1-0.20260203140014-21fa138b604e github.com/jszwec/csvutil v1.10.0 github.com/manifoldco/promptui v0.9.0 github.com/spf13/viper v1.21.0 diff --git a/go.sum b/go.sum index 572196e11..18ef2b6a8 100644 --- a/go.sum +++ b/go.sum @@ -1228,8 +1228,8 @@ github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b000 github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e/go.mod h1:qbu4iqBST9x8LgD8HhzUm91iOB3vHqtoGmaxOnmw0ok= github.com/jfrog/jfrog-cli-security v1.26.0 h1:FcLshS1Ahm0++nV5q7UluFTCVRxH2wEIbqO7ZBag++I= github.com/jfrog/jfrog-cli-security v1.26.0/go.mod h1:r9E0BdlNy6mq6gkRGslZRZaYe6WeGhLkpUm8+oEUOvU= -github.com/jfrog/jfrog-client-go v1.55.1-0.20260202100450-1b20bddfdb3f h1:A/5DenqKB4zv9jWhG777/UwhoGL8hCzIndKj0sJ7QSM= -github.com/jfrog/jfrog-client-go v1.55.1-0.20260202100450-1b20bddfdb3f/go.mod h1:sCE06+GngPoyrGO0c+vmhgMoVSP83UMNiZnIuNPzU8U= +github.com/jfrog/jfrog-client-go v1.55.1-0.20260203140014-21fa138b604e h1:BIQlRLDNcuZhoMctvktukmUFkeF2Uj2E1E/ucQMMKeg= +github.com/jfrog/jfrog-client-go v1.55.1-0.20260203140014-21fa138b604e/go.mod h1:sCE06+GngPoyrGO0c+vmhgMoVSP83UMNiZnIuNPzU8U= github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 h1:liMMTbpW34dhU4az1GN0pTPADwNmvoRSeoZ6PItiqnY= From 51f15358cad8959100226217ccf7d674218b7616 Mon Sep 17 00:00:00 2001 From: Kfir Harel Date: Fri, 6 Feb 2026 15:48:49 +0200 Subject: [PATCH 3/3] Update lifecycle_test.go Co-authored-by: Bhanu Reddy --- lifecycle_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lifecycle_test.go b/lifecycle_test.go index 87ae4b6a7..fb5212254 100644 --- a/lifecycle_test.go +++ b/lifecycle_test.go @@ -752,17 +752,13 @@ func finalizeRbWithFlags(t *testing.T, rbName, rbVersion, project, signingKey st rbName, rbVersion, } - if signingKey != "" { argsAndOptions = append(argsAndOptions, getOption(cliutils.SigningKey, signingKey)) } - if project != "" { argsAndOptions = append(argsAndOptions, getOption(cliutils.Project, project)) } - argsAndOptions = append(argsAndOptions, getOption(cliutils.Sync, strconv.FormatBool(sync))) - assert.NoError(t, lcCli.Exec(argsAndOptions...)) }