Skip to content

Commit bb3329f

Browse files
committed
Make the signing key optinal jf release-bundle-create (jfrog#2762)
1 parent cbf2b00 commit bb3329f

2 files changed

Lines changed: 32 additions & 25 deletions

File tree

lifecycle_test.go

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ import (
2929
)
3030

3131
const (
32-
artifactoryLifecycleMinVersion = "7.68.3"
33-
gpgKeyPairName = "lc-tests-key-pair"
34-
lcTestdataPath = "lifecycle"
35-
releaseBundlesSpec = "release-bundles-spec.json"
36-
buildsSpec12 = "builds-spec-1-2.json"
37-
buildsSpec3 = "builds-spec-3.json"
38-
prodEnvironment = "PROD"
39-
number1, number2, number3 = "111", "222", "333"
32+
artifactoryLifecycleMinVersion = "7.68.3"
33+
signingKeyOptionalArtifactoryMinVersion = "7.101.1"
34+
gpgKeyPairName = "lc-tests-key-pair"
35+
lcTestdataPath = "lifecycle"
36+
releaseBundlesSpec = "release-bundles-spec.json"
37+
buildsSpec12 = "builds-spec-1-2.json"
38+
buildsSpec3 = "builds-spec-3.json"
39+
prodEnvironment = "PROD"
40+
number1, number2, number3 = "111", "222", "333"
41+
withoutSigningKey = true
4042
)
4143

4244
var (
@@ -45,7 +47,7 @@ var (
4547
)
4648

4749
func TestBackwardCompatibleReleaseBundleCreation(t *testing.T) {
48-
cleanCallback := initLifecycleTest(t)
50+
cleanCallback := initLifecycleTest(t, artifactoryLifecycleMinVersion)
4951
defer cleanCallback()
5052
lcManager := getLcServiceManager(t)
5153

@@ -95,26 +97,31 @@ func TestReleaseBundleCreationFromArtifacts(t *testing.T) {
9597
}
9698

9799
func TestReleaseBundleCreationFromArtifactsWithoutSigningKey(t *testing.T) {
98-
testReleaseBundleCreation(t, tests.UploadDevSpec, tests.LifecycleArtifacts, tests.GetExpectedLifecycleCreationByArtifacts(), true)
100+
testReleaseBundleCreation(t, tests.UploadDevSpec, tests.LifecycleArtifacts, tests.GetExpectedLifecycleCreationByArtifacts(), withoutSigningKey)
99101
}
100102

101-
func testReleaseBundleCreation(t *testing.T, uploadSpec, creationSpec string, expected []string, withoutKey bool) {
102-
cleanCallback := initLifecycleTest(t)
103-
defer cleanCallback()
104-
lcManager := getLcServiceManager(t)
103+
func testReleaseBundleCreation(t *testing.T, uploadSpec, creationSpec string, expected []string, withoutSigningKey bool) {
104+
if withoutSigningKey {
105+
cleanCallback := initLifecycleTest(t, signingKeyOptionalArtifactoryMinVersion)
106+
defer cleanCallback()
107+
} else {
108+
cleanCallback := initLifecycleTest(t, artifactoryLifecycleMinVersion)
109+
defer cleanCallback()
110+
}
105111

112+
lcManager := getLcServiceManager(t)
106113
specFile, err := tests.CreateSpec(uploadSpec)
107114
assert.NoError(t, err)
108115
runRt(t, "upload", "--spec="+specFile)
109116

110-
createRbFromSpec(t, creationSpec, tests.LcRbName1, number1, true, withoutKey)
117+
createRbFromSpec(t, creationSpec, tests.LcRbName1, number1, true, withoutSigningKey)
111118
defer deleteReleaseBundle(t, lcManager, tests.LcRbName1, number1)
112119

113120
assertRbArtifacts(t, lcManager, tests.LcRbName1, number1, expected)
114121
}
115122

116123
func TestLifecycleFullFlow(t *testing.T) {
117-
cleanCallback := initLifecycleTest(t)
124+
cleanCallback := initLifecycleTest(t, signingKeyOptionalArtifactoryMinVersion)
118125
defer cleanCallback()
119126
lcManager := getLcServiceManager(t)
120127

@@ -165,7 +172,7 @@ func TestLifecycleFullFlow(t *testing.T) {
165172

166173
// Import bundles only work on onPerm platforms
167174
func TestImportReleaseBundle(t *testing.T) {
168-
cleanCallback := initLifecycleTest(t)
175+
cleanCallback := initLifecycleTest(t, artifactoryLifecycleMinVersion)
169176
defer cleanCallback()
170177
wd, err := os.Getwd()
171178
assert.NoError(t, err)
@@ -202,24 +209,23 @@ func createRbBackwardCompatible(t *testing.T, specName, sourceOption, rbName, rb
202209
createRb(t, specFile, sourceOption, rbName, rbVersion, sync, false)
203210
}
204211

205-
func createRbFromSpec(t *testing.T, specName, rbName, rbVersion string, sync bool, withoutKey bool) {
212+
func createRbFromSpec(t *testing.T, specName, rbName, rbVersion string, sync bool, withoutSigningKey bool) {
206213
specFile, err := tests.CreateSpec(specName)
207214
assert.NoError(t, err)
208-
createRb(t, specFile, "spec", rbName, rbVersion, sync, withoutKey)
215+
createRb(t, specFile, "spec", rbName, rbVersion, sync, withoutSigningKey)
209216
}
210217

211-
func createRb(t *testing.T, specFilePath, sourceOption, rbName, rbVersion string, sync bool, withoutKey bool) {
218+
func createRb(t *testing.T, specFilePath, sourceOption, rbName, rbVersion string, sync bool, withoutSigningKey bool) {
212219
argsAndOptions := []string{
213220
"rbc",
214221
rbName,
215222
rbVersion,
216223
getOption(sourceOption, specFilePath),
217224
}
218225

219-
if !withoutKey {
226+
if !withoutSigningKey {
220227
argsAndOptions = append(argsAndOptions, getOption(cliutils.SigningKey, gpgKeyPairName))
221228
}
222-
223229
// Add the --sync option only if requested, to test the default value.
224230
if sync {
225231
argsAndOptions = append(argsAndOptions, getOption(cliutils.Sync, "true"))
@@ -371,11 +377,12 @@ func uploadBuildWithDeps(t *testing.T, buildName, buildNumber string) {
371377
runRt(t, "build-publish", buildName, buildNumber)
372378
}
373379

374-
func initLifecycleTest(t *testing.T) (cleanCallback func()) {
380+
func initLifecycleTest(t *testing.T, minVersion string) (cleanCallback func()) {
375381
if !*tests.TestLifecycle {
376382
t.Skip("Skipping lifecycle test. To run release bundle test add the '-test.lc=true' option.")
377383
}
378-
validateArtifactoryVersion(t, artifactoryLifecycleMinVersion)
384+
385+
validateArtifactoryVersion(t, minVersion)
379386

380387
if !isLifecycleSupported(t) {
381388
t.Skip("Skipping lifecycle test because the functionality is not enabled on the provided JPD.")

utils/cliutils/commandsflags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ var flagsMap = map[string]cli.Flag{
16501650
},
16511651
lcSigningKey: cli.StringFlag{
16521652
Name: SigningKey,
1653-
Usage: "[Mandatory] The GPG/RSA key-pair name given in Artifactory.` `",
1653+
Usage: "[Optional] The GPG/RSA key-pair name given in Artifactory. If the key isn't provided, the command creates or uses the default key.` `",
16541654
},
16551655
lcPathMappingPattern: cli.StringFlag{
16561656
Name: PathMappingPattern,

0 commit comments

Comments
 (0)