github.com/jfrog/jfrog-cli@v1.54.1/distribution_test.go (about) 1 package main 2 3 import ( 4 "errors" 5 "github.com/jfrog/jfrog-client-go/utils/log" 6 "os" 7 "path/filepath" 8 "testing" 9 10 "github.com/jfrog/jfrog-cli-core/utils/coreutils" 11 12 "github.com/jfrog/jfrog-cli-core/utils/config" 13 "github.com/jfrog/jfrog-cli/inttestutils" 14 "github.com/jfrog/jfrog-cli/utils/tests" 15 "github.com/jfrog/jfrog-client-go/auth" 16 clientDistUtils "github.com/jfrog/jfrog-client-go/distribution/services/utils" 17 "github.com/jfrog/jfrog-client-go/utils" 18 "github.com/jfrog/jfrog-client-go/utils/io/fileutils" 19 "github.com/jfrog/jfrog-client-go/utils/io/httputils" 20 "github.com/stretchr/testify/assert" 21 ) 22 23 const bundleVersion = "10" 24 25 var ( 26 distributionDetails *config.ServerDetails 27 distAuth auth.ServiceDetails 28 distHttpDetails httputils.HttpClientDetails 29 // JFrog CLI for Distribution commands 30 distributionCli *tests.JfrogCli 31 ) 32 33 func InitDistributionTests() { 34 initDistributionCli() 35 inttestutils.CleanUpOldBundles(distHttpDetails, bundleVersion, distributionCli) 36 InitArtifactoryTests() 37 inttestutils.SendGpgKeys(artHttpDetails, distHttpDetails) 38 } 39 40 func CleanDistributionTests() { 41 deleteCreatedRepos() 42 } 43 44 func authenticateDistribution() string { 45 // Due to a bug in distribution when authenticate with a multi-scope token, 46 // we must send a username as well as token or password. 47 distributionDetails = &config.ServerDetails{ 48 DistributionUrl: *tests.RtDistributionUrl, 49 User: *tests.RtUser, 50 } 51 cred := "--dist-url=" + *tests.RtDistributionUrl + " --user=" + *tests.RtUser 52 53 // Prefer the distribution token if provided. 54 distributionDetails.AccessToken = *tests.RtDistributionAccessToken 55 if distributionDetails.AccessToken == "" { 56 distributionDetails.AccessToken = *tests.RtAccessToken 57 } 58 59 if distributionDetails.AccessToken != "" { 60 cred += " --access-token=" + distributionDetails.AccessToken 61 } else { 62 distributionDetails.Password = *tests.RtPassword 63 cred += " --password=" + *tests.RtPassword 64 } 65 66 var err error 67 if distAuth, err = distributionDetails.CreateDistAuthConfig(); err != nil { 68 coreutils.ExitOnErr(errors.New("Failed while attempting to authenticate with Artifactory: " + err.Error())) 69 } 70 distributionDetails.DistributionUrl = distAuth.GetUrl() 71 distHttpDetails = distAuth.CreateHttpClientDetails() 72 return cred 73 } 74 75 func initDistributionCli() { 76 if distributionCli != nil { 77 return 78 } 79 *tests.RtDistributionUrl = utils.AddTrailingSlashIfNeeded(*tests.RtDistributionUrl) 80 cred := authenticateDistribution() 81 distributionCli = tests.NewJfrogCli(execMain, "jfrog rt", cred) 82 } 83 84 func initDistributionTest(t *testing.T) { 85 if !*tests.TestDistribution { 86 t.Skip("Skipping distribution test. To run distribution test add the '-test.distribution=true' option.") 87 } 88 } 89 90 func cleanDistributionTest(t *testing.T) { 91 distributionCli.Exec("rbdel", tests.BundleName, bundleVersion, "--site=*", "--delete-from-dist", "--quiet") 92 inttestutils.WaitForDeletion(t, tests.BundleName, bundleVersion, distHttpDetails) 93 inttestutils.CleanDistributionRepositories(t, serverDetails) 94 tests.CleanFileSystem() 95 } 96 97 func TestBundleAsyncDistDownload(t *testing.T) { 98 initDistributionTest(t) 99 100 // Upload files 101 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 102 assert.NoError(t, err) 103 runRt(t, "u", "--spec="+specFile) 104 105 // Create and distribute release bundle 106 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in", "--sign") 107 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*") 108 inttestutils.WaitForDistribution(t, tests.BundleName, bundleVersion, distHttpDetails) 109 110 // Download by bundle version, b2 and b3 should not be downloaded, b1 should 111 runRt(t, "dl", tests.DistRepo1+"/data/*", tests.Out+fileutils.GetFileSeparator()+"download"+fileutils.GetFileSeparator()+"simple_by_build"+fileutils.GetFileSeparator(), "--bundle="+tests.BundleName+"/"+bundleVersion) 112 113 // Validate files are downloaded by bundle version 114 paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 115 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 116 assert.NoError(t, err) 117 118 // Cleanup 119 cleanDistributionTest(t) 120 } 121 122 func TestBundleDownloadUsingSpec(t *testing.T) { 123 initDistributionTest(t) 124 125 // Upload files 126 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 127 assert.NoError(t, err) 128 runRt(t, "u", "--spec="+specFile) 129 130 // Create release bundle 131 distributionRules, err := tests.CreateSpec(tests.DistributionRules) 132 assert.NoError(t, err) 133 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in", "--sign") 134 runRb(t, "rbd", tests.BundleName, bundleVersion, "--dist-rules="+distributionRules, "--sync") 135 136 // Download by bundle version, b2 and b3 should not be downloaded, b1 should 137 specFile, err = tests.CreateSpec(tests.BundleDownloadSpec) 138 assert.NoError(t, err) 139 runRt(t, "dl", "--spec="+specFile) 140 141 // Validate files are downloaded by bundle version 142 paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 143 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 144 assert.NoError(t, err) 145 146 // Cleanup 147 cleanDistributionTest(t) 148 } 149 150 func TestBundleCreateByAql(t *testing.T) { 151 initDistributionTest(t) 152 153 // Upload files 154 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 155 assert.NoError(t, err) 156 runRt(t, "u", "--spec="+specFile) 157 158 // Create release bundle by AQL 159 spec, err := tests.CreateSpec(tests.DistributionCreateByAql) 160 assert.NoError(t, err) 161 runRb(t, "rbc", tests.BundleName, bundleVersion, "--spec="+spec, "--sign") 162 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 163 164 // Download by bundle version, b2 and b3 should not be downloaded, b1 should 165 specFile, err = tests.CreateSpec(tests.BundleDownloadSpec) 166 assert.NoError(t, err) 167 runRt(t, "dl", "--spec="+specFile) 168 169 // Validate files are downloaded by bundle version 170 paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 171 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 172 assert.NoError(t, err) 173 174 // Cleanup 175 cleanDistributionTest(t) 176 } 177 178 func TestBundleDownloadNoPattern(t *testing.T) { 179 initDistributionTest(t) 180 181 // Upload files 182 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 183 assert.NoError(t, err) 184 runRt(t, "u", "--spec="+specFile) 185 186 // Create release bundle 187 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in", "--sign") 188 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 189 190 // Download by bundle name and version with pattern "*", b2 and b3 should not be downloaded, b1 should 191 runRt(t, "dl", "*", "out/download/simple_by_build/data/", "--bundle="+tests.BundleName+"/"+bundleVersion, "--flat") 192 193 // Validate files are downloaded by bundle version 194 paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 195 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 196 assert.NoError(t, err) 197 198 // Download by bundle name and version version without pattern, b2 and b3 should not be downloaded, b1 should 199 tests.CleanFileSystem() 200 specFile, err = tests.CreateSpec(tests.BundleDownloadSpecNoPattern) 201 runRt(t, "dl", "--spec="+specFile, "--flat") 202 203 // Validate files are downloaded by bundle version 204 paths, _ = fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 205 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 206 assert.NoError(t, err) 207 208 // Cleanup 209 cleanDistributionTest(t) 210 } 211 212 func TestBundleExclusions(t *testing.T) { 213 initDistributionTest(t) 214 215 // Upload files 216 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 217 assert.NoError(t, err) 218 runRt(t, "u", "--spec="+specFile) 219 220 // Create release bundle. Include b1.in and b2.in. Exclude b3.in. 221 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b*.in", "--sign", "--exclusions=*b3.in") 222 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 223 224 // Download by bundle version, b2 and b3 should not be downloaded, b1 should 225 runRt(t, "dl", tests.DistRepo1+"/data/*", tests.Out+fileutils.GetFileSeparator()+"download"+fileutils.GetFileSeparator()+"simple_by_build"+fileutils.GetFileSeparator(), "--bundle="+tests.BundleName+"/"+bundleVersion, "--exclusions=*b2.in") 226 227 // Validate files are downloaded by bundle version 228 paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 229 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 230 assert.NoError(t, err) 231 232 // Cleanup 233 cleanDistributionTest(t) 234 } 235 236 func TestBundleCopy(t *testing.T) { 237 initDistributionTest(t) 238 239 // Upload files 240 specFileA, err := tests.CreateSpec(tests.DistributionUploadSpecA) 241 assert.NoError(t, err) 242 specFileB, err := tests.CreateSpec(tests.DistributionUploadSpecB) 243 assert.NoError(t, err) 244 runRt(t, "u", "--spec="+specFileA) 245 runRt(t, "u", "--spec="+specFileB) 246 247 // Create release bundle 248 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/a*", "--sign") 249 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 250 251 // Copy by bundle name and version 252 specFile, err := tests.CreateSpec(tests.CopyByBundleSpec) 253 assert.NoError(t, err) 254 runRt(t, "cp", "--spec="+specFile) 255 256 // Validate files are copied by bundle version 257 spec, err := tests.CreateSpec(tests.CopyByBundleAssertSpec) 258 assert.NoError(t, err) 259 verifyExistInArtifactory(tests.GetBundleCopyExpected(), spec, t) 260 261 // Cleanup 262 cleanDistributionTest(t) 263 } 264 265 func TestBundleSetProperties(t *testing.T) { 266 initDistributionTest(t) 267 268 // Upload a file. 269 runRt(t, "u", "testdata/a/a1.in", tests.DistRepo1+"/a.in") 270 271 // Create release bundle 272 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/a.in", "--sign") 273 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 274 275 // Set the 'prop=red' property to the file. 276 runRt(t, "sp", tests.DistRepo1+"/a.*", "prop=red", "--bundle="+tests.BundleName+"/"+bundleVersion) 277 // Now let's change the property value, by searching for the 'prop=red'. 278 specFile, err := tests.CreateSpec(tests.DistributionSetDeletePropsSpec) 279 assert.NoError(t, err) 280 runRt(t, "sp", "prop=green", "--spec="+specFile, "--bundle="+tests.BundleName+"/"+bundleVersion) 281 282 resultItems := searchItemsInArtifactory(t, tests.SearchDistRepoByInSuffix) 283 assert.NotZero(t, len(resultItems), "No artifacts were found.") 284 for _, item := range resultItems { 285 properties := item.Properties 286 assert.Equal(t, 2, len(properties), "Failed setting properties on item:", item.GetItemRelativePath()) 287 for _, prop := range properties { 288 if prop.Key == "sha256" { 289 continue 290 } 291 assert.Equal(t, "prop", prop.Key, "Wrong property key") 292 assert.Equal(t, "green", prop.Value, "Wrong property value") 293 } 294 } 295 cleanDistributionTest(t) 296 } 297 298 func TestSignReleaseBundle(t *testing.T) { 299 initDistributionTest(t) 300 301 // Upload files 302 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 303 assert.NoError(t, err) 304 runRt(t, "u", "--spec="+specFile) 305 306 // Create a release bundle without --sign and make sure it is not signed 307 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in") 308 distributableResponse := inttestutils.GetLocalBundle(t, tests.BundleName, bundleVersion, distHttpDetails) 309 inttestutils.AssertReleaseBundleOpen(t, distributableResponse) 310 311 // Sign the release bundle and make sure it is signed 312 runRb(t, "rbs", tests.BundleName, bundleVersion) 313 distributableResponse = inttestutils.GetLocalBundle(t, tests.BundleName, bundleVersion, distHttpDetails) 314 inttestutils.AssertReleaseBundleSigned(t, distributableResponse) 315 316 // Cleanup 317 cleanDistributionTest(t) 318 } 319 320 func TestBundleDeleteLocal(t *testing.T) { 321 initDistributionTest(t) 322 323 // Upload files 324 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 325 assert.NoError(t, err) 326 runRt(t, "u", "--spec="+specFile) 327 328 // Create a release bundle 329 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in", "--sign") 330 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 331 332 // Delete release bundle locally 333 runRb(t, "rbdel", tests.BundleName, bundleVersion, "--site=*", "--delete-from-dist", "--quiet") 334 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, false, distHttpDetails) 335 336 // Cleanup 337 cleanDistributionTest(t) 338 } 339 340 func TestUpdateReleaseBundle(t *testing.T) { 341 initDistributionTest(t) 342 343 // Upload files 344 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 345 assert.NoError(t, err) 346 runRt(t, "u", "--spec="+specFile) 347 348 // Create a release bundle with b2.in 349 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b2.in") 350 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 351 352 // Update release bundle to have b1.in 353 runRb(t, "rbu", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in", "--sign") 354 355 // Distribute release bundle 356 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 357 358 // Download by bundle version, b2 and b3 should not be downloaded, b1 should 359 runRt(t, "dl", tests.DistRepo1+"/data/*", tests.Out+fileutils.GetFileSeparator()+"download"+fileutils.GetFileSeparator()+"simple_by_build"+fileutils.GetFileSeparator(), "--bundle="+tests.BundleName+"/"+bundleVersion) 360 361 // Validate files are downloaded by bundle version 362 paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) 363 err = tests.ValidateListsIdentical(tests.GetBuildSimpleDownload(), paths) 364 assert.NoError(t, err) 365 366 // Cleanup 367 cleanDistributionTest(t) 368 } 369 370 func TestCreateBundleText(t *testing.T) { 371 initDistributionTest(t) 372 373 // Upload files 374 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 375 assert.NoError(t, err) 376 runRt(t, "u", "--spec="+specFile) 377 378 // Create a release bundle with release notes and description 379 releaseNotesPath := filepath.Join(tests.GetTestResourcesPath(), "distribution", "releasenotes.md") 380 description := "thisIsADescription" 381 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/*", "--release-notes-path="+releaseNotesPath, "--desc="+description) 382 383 // Validate release notes and description 384 distributableResponse := inttestutils.GetLocalBundle(t, tests.BundleName, bundleVersion, distHttpDetails) 385 if distributableResponse != nil { 386 assert.Equal(t, description, distributableResponse.Description) 387 releaseNotes, err := os.ReadFile(releaseNotesPath) 388 assert.NoError(t, err) 389 assert.Equal(t, string(releaseNotes), distributableResponse.ReleaseNotes.Content) 390 assert.Equal(t, clientDistUtils.Markdown, distributableResponse.ReleaseNotes.Syntax) 391 } 392 393 cleanDistributionTest(t) 394 } 395 396 func TestCreateBundleProps(t *testing.T) { 397 initDistributionTest(t) 398 399 // Upload files 400 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 401 assert.NoError(t, err) 402 runRt(t, "u", "--spec="+specFile) 403 404 // Create and distribute release bundle with added props 405 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/*", "--target-props=key1=val1;key2=val2,val3", "--sign") 406 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 407 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 408 409 // Verify props are added to the distributes artifact 410 verifyExistInArtifactoryByProps(tests.GetBundlePropsExpected(), tests.DistRepo1+"/data/", "key1=val1;key2=val2;key2=val3", t) 411 412 cleanDistributionTest(t) 413 } 414 415 func TestUpdateBundleProps(t *testing.T) { 416 initDistributionTest(t) 417 418 // Upload files 419 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 420 assert.NoError(t, err) 421 runRt(t, "u", "--spec="+specFile) 422 423 // Create, update and distribute release bundle with added props 424 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/*") 425 runRb(t, "rbu", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/*", "--target-props=key1=val1", "--sign") 426 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 427 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 428 429 // Verify props are added to the distributes artifact 430 verifyExistInArtifactoryByProps(tests.GetBundlePropsExpected(), tests.DistRepo1+"/data/", "key1=val1", t) 431 432 cleanDistributionTest(t) 433 } 434 435 func TestBundlePathMapping(t *testing.T) { 436 initDistributionTest(t) 437 438 // Upload files 439 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 440 assert.NoError(t, err) 441 runRt(t, "u", "--spec="+specFile) 442 443 // Create and distribute release bundle with path mapping from <DistRepo1>/data/ to <DistRepo2>/target/ 444 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/(*)", "--sign", "--target="+tests.DistRepo2+"/target/{1}") 445 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 446 447 // Validate files are distributed to the target mapping 448 spec, err := tests.CreateSpec(tests.DistributionMappingDownload) 449 assert.NoError(t, err) 450 verifyExistInArtifactory(tests.GetBundleMappingExpected(), spec, t) 451 452 cleanDistributionTest(t) 453 } 454 455 func TestBundlePathMappingUsingSpec(t *testing.T) { 456 initDistributionTest(t) 457 458 // Upload files 459 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 460 assert.NoError(t, err) 461 runRt(t, "u", "--spec="+specFile) 462 463 // Create and distribute release bundle with path mapping from <DistRepo1>/data/ to <DistRepo2>/target/ 464 spec, err := tests.CreateSpec(tests.DistributionCreateWithMapping) 465 assert.NoError(t, err) 466 runRb(t, "rbc", tests.BundleName, bundleVersion, "--sign", "--spec="+spec) 467 runRb(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") 468 469 // Validate files are distributed to the target mapping 470 spec, err = tests.CreateSpec(tests.DistributionMappingDownload) 471 assert.NoError(t, err) 472 verifyExistInArtifactory(tests.GetBundleMappingExpected(), spec, t) 473 474 cleanDistributionTest(t) 475 } 476 477 func TestReleaseBundleCreateDetailedSummary(t *testing.T) { 478 initDistributionTest(t) 479 480 // Upload files 481 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 482 assert.NoError(t, err) 483 runRt(t, "u", "--spec="+specFile) 484 485 buffer, previousLog := tests.RedirectLogOutputToBuffer() 486 // Restore previous logger when the function returns 487 defer log.SetLogger(previousLog) 488 489 // Create a release bundle with b2.in 490 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b2.in", "--sign", "--detailed-summary") 491 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 492 493 tests.VerifySha256DetailedSummaryFromBuffer(t, buffer, previousLog) 494 495 // Cleanup 496 cleanDistributionTest(t) 497 } 498 499 func TestReleaseBundleUpdateDetailedSummary(t *testing.T) { 500 initDistributionTest(t) 501 502 // Upload files 503 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 504 assert.NoError(t, err) 505 runRt(t, "u", "--spec="+specFile) 506 507 buffer, previousLog := tests.RedirectLogOutputToBuffer() 508 // Restore previous logger when the function returns 509 defer log.SetLogger(previousLog) 510 511 // Create a release bundle with b2.in 512 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b2.in") 513 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 514 515 // Update release bundle to have b1.in 516 runRb(t, "rbu", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b1.in", "--sign", "--detailed-summary") 517 518 tests.VerifySha256DetailedSummaryFromBuffer(t, buffer, previousLog) 519 520 // Cleanup 521 cleanDistributionTest(t) 522 } 523 524 func TestReleaseBundleSignDetailedSummary(t *testing.T) { 525 initDistributionTest(t) 526 527 // Upload files 528 specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) 529 assert.NoError(t, err) 530 runRt(t, "u", "--spec="+specFile) 531 532 buffer, previousLog := tests.RedirectLogOutputToBuffer() 533 // Restore previous logger when the function returns 534 defer log.SetLogger(previousLog) 535 536 // Create a release bundle with b2.in 537 runRb(t, "rbc", tests.BundleName, bundleVersion, tests.DistRepo1+"/data/b2.in") 538 inttestutils.VerifyLocalBundleExistence(t, tests.BundleName, bundleVersion, true, distHttpDetails) 539 540 // Update release bundle to have b1.in 541 runRb(t, "rbs", tests.BundleName, bundleVersion, "--detailed-summary") 542 543 tests.VerifySha256DetailedSummaryFromBuffer(t, buffer, previousLog) 544 545 // Cleanup 546 cleanDistributionTest(t) 547 } 548 549 // Run `jfrog rt rb*` command`. The first arg is the distribution command, such as 'rbc', 'rbu', etc. 550 func runRb(t *testing.T, args ...string) { 551 err := distributionCli.Exec(args...) 552 assert.NoError(t, err) 553 } 554 555 // Run `jfrog rt` command 556 func runRt(t *testing.T, args ...string) { 557 err := artifactoryCli.Exec(args...) 558 assert.NoError(t, err) 559 }