Skip to content

Commit

Permalink
Merge branch 'dev' into fix-script
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 authored Jan 21, 2024
2 parents 661864b + 56b291b commit ff4f745
Show file tree
Hide file tree
Showing 58 changed files with 379 additions and 3,293 deletions.
71 changes: 0 additions & 71 deletions .github/workflows/xrayTests.yml

This file was deleted.

4 changes: 0 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ node("docker") {

masterBranch = 'v2'
devBranch = 'dev'
if (BRANCH?.trim() == 'v1') {
masterBranch = 'v1'
devBranch = 'dev-v1'
}

releaseVersion = ''

Expand Down
8 changes: 4 additions & 4 deletions access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

var (
accessDetails *config.ServerDetails
accessCli *tests.JfrogCli
accessCli *coreTests.JfrogCli
accessHttpDetails httputils.HttpClientDetails
)

Expand All @@ -37,7 +37,7 @@ func initAccessCli() {
if accessCli != nil {
return
}
accessCli = tests.NewJfrogCli(execMain, "jfrog", authenticateAccess())
accessCli = coreTests.NewJfrogCli(execMain, "jfrog", authenticateAccess())
}

func InitAccessTests() {
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestRefreshableAccessTokens(t *testing.T) {
defer deleteServerConfig(t)

// Upload a file and assert the refreshable tokens were generated.
artifactoryCommandExecutor := tests.NewJfrogCli(execMain, "jfrog rt", "")
artifactoryCommandExecutor := coreTests.NewJfrogCli(execMain, "jfrog rt", "")
uploadedFiles := 1
err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a1.in", uploadedFiles)
if !assert.NoError(t, err) {
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestAccessTokenCreate(t *testing.T) {
assertNotEmptyIfExpected(t, test.expectedReference, token.ReferenceToken)

// Try pinging Artifactory with the new token.
assert.NoError(t, tests.NewJfrogCli(execMain, "jfrog rt",
assert.NoError(t, coreTests.NewJfrogCli(execMain, "jfrog rt",
"--url="+*tests.JfrogUrl+tests.ArtifactoryEndpoint+" --access-token="+token.AccessToken).Exec("ping"))
})
}
Expand Down
18 changes: 3 additions & 15 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
"github.com/jfrog/jfrog-cli-core/v2/common/build"
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/common/progressbar"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
"github.com/jfrog/jfrog-cli/buildtools"
"github.com/jfrog/jfrog-cli/docs/artifactory/accesstokencreate"
"github.com/jfrog/jfrog-cli/docs/artifactory/buildadddependencies"
Expand Down Expand Up @@ -110,7 +111,6 @@ import (
"github.com/jfrog/jfrog-cli/docs/artifactory/yarnconfig"
"github.com/jfrog/jfrog-cli/docs/common"
"github.com/jfrog/jfrog-cli/utils/cliutils"
"github.com/jfrog/jfrog-cli/utils/progressbar"
buildinfocmd "github.com/jfrog/jfrog-client-go/artifactory/buildinfo"
"github.com/jfrog/jfrog-client-go/artifactory/services"
clientutils "github.com/jfrog/jfrog-client-go/utils"
Expand Down Expand Up @@ -2682,23 +2682,11 @@ func createDefaultBuildAddDependenciesSpec(c *cli.Context) *spec.SpecFiles {
func fixWinPathsForDownloadCmd(uploadSpec *spec.SpecFiles, c *cli.Context) {
if coreutils.IsWindows() {
for i, file := range uploadSpec.Files {
uploadSpec.Files[i].Target = fixWinPathBySource(file.Target, c.IsSet("spec"))
uploadSpec.Files[i].Target = commonCliUtils.FixWinPathBySource(file.Target, c.IsSet("spec"))
}
}
}

func fixWinPathBySource(path string, fromSpec bool) string {
if strings.Count(path, "/") > 0 {
// Assuming forward slashes - not doubling backslash to allow regexp escaping
return ioutils.UnixToWinPathSeparator(path)
}
if fromSpec {
// Doubling backslash only for paths from spec files (that aren't forward slashed)
return ioutils.DoubleWinPathSeparator(path)
}
return path
}

func createUploadConfiguration(c *cli.Context) (uploadConfiguration *utils.UploadConfiguration, err error) {
uploadConfiguration = new(utils.UploadConfiguration)
uploadConfiguration.Threads, err = cliutils.GetThreadsCount(c)
Expand Down
40 changes: 21 additions & 19 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ import (
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
commontests "github.com/jfrog/jfrog-cli-core/v2/common/tests"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/dependencies"
Expand Down Expand Up @@ -68,13 +70,13 @@ import (
const terraformMinArtifactoryVersion = "7.38.4"

// JFrog CLI for Artifactory sub-commands (jfrog rt ...)
var artifactoryCli *tests.JfrogCli
var artifactoryCli *coretests.JfrogCli

// JFrog CLI for Platform commands (jfrog ...)
var platformCli *tests.JfrogCli
var platformCli *coretests.JfrogCli

// JFrog CLI for config command only (doesn't pass the --ssh-passphrase flag)
var configCli *tests.JfrogCli
var configCli *coretests.JfrogCli

var serverDetails *config.ServerDetails
var artAuth auth.ServiceDetails
Expand Down Expand Up @@ -126,11 +128,11 @@ func authenticate(configCli bool) string {

// A Jfrog CLI to be used to execute a config task.
// Removed the ssh-passphrase flag that cannot be passed to with a config command
func createConfigJfrogCLI(cred string) *tests.JfrogCli {
func createConfigJfrogCLI(cred string) *coretests.JfrogCli {
if strings.Contains(cred, " --ssh-passphrase=") {
cred = strings.ReplaceAll(cred, " --ssh-passphrase="+*tests.JfrogSshPassphrase, "")
}
return tests.NewJfrogCli(execMain, "jfrog config", cred)
return coretests.NewJfrogCli(execMain, "jfrog config", cred)
}

func getArtifactoryTestCredentials() string {
Expand Down Expand Up @@ -212,7 +214,7 @@ func TestArtifactorySimpleUploadSpecUsingConfig(t *testing.T) {
passphrase, err := createServerConfigAndReturnPassphrase(t)
defer deleteServerConfig(t)
assert.NoError(t, err)
artifactoryCommandExecutor := tests.NewJfrogCli(execMain, "jfrog rt", "")
artifactoryCommandExecutor := coretests.NewJfrogCli(execMain, "jfrog rt", "")
specFile, err := tests.CreateSpec(tests.UploadFlatRecursive)
assert.NoError(t, err)
assert.NoError(t, artifactoryCommandExecutor.Exec("upload", "--spec="+specFile, "--server-id="+tests.ServerId, passphrase))
Expand Down Expand Up @@ -349,7 +351,7 @@ func TestArtifactoryDownloadFromVirtual(t *testing.T) {
func TestArtifactoryDownloadAndUploadWithProgressBar(t *testing.T) {
initArtifactoryTest(t, "")

callback := tests.MockProgressInitialization()
callback := commontests.MockProgressInitialization()
defer callback()

runRt(t, "upload", "testdata/a/*", tests.RtRepo1, "--flat=false")
Expand Down Expand Up @@ -793,7 +795,7 @@ func verifyUsersExistInArtifactory(csvFilePath string, t *testing.T) {
break
}
user, password := record[0], record[1]
err = tests.NewJfrogCli(execMain, "jfrog rt", "--url="+serverDetails.ArtifactoryUrl+" --user="+user+" --password="+password).Exec("ping")
err = coretests.NewJfrogCli(execMain, "jfrog rt", "--url="+serverDetails.ArtifactoryUrl+" --user="+user+" --password="+password).Exec("ping")
assert.NoError(t, err)
}

Expand Down Expand Up @@ -1805,7 +1807,7 @@ func TestXrayScanBuild(t *testing.T) {
initArtifactoryTest(t, "")
xrayServerPort := xray.StartXrayMockServer()
serverUrl := "--url=http://localhost:" + strconv.Itoa(xrayServerPort)
artifactoryCommandExecutor := tests.NewJfrogCli(execMain, "jfrog rt", serverUrl+getArtifactoryTestCredentials())
artifactoryCommandExecutor := coretests.NewJfrogCli(execMain, "jfrog rt", serverUrl+getArtifactoryTestCredentials())
assert.NoError(t, artifactoryCommandExecutor.Exec("build-scan", xray.CleanScanBuildName, "3"))

cleanArtifactoryTest()
Expand Down Expand Up @@ -3090,7 +3092,7 @@ func prepareDownloadByBuildWithDependenciesTests(t *testing.T) {
runRt(t, "upload", "--spec="+specFileB)

// Add build dependencies.
artifactoryCliNoCreds := tests.NewJfrogCli(execMain, "jfrog rt", "")
artifactoryCliNoCreds := coretests.NewJfrogCli(execMain, "jfrog rt", "")
assert.NoError(t, artifactoryCliNoCreds.Exec("bad", "--spec="+specFileB, tests.RtBuildName1, buildNumber))

// Publish build.
Expand Down Expand Up @@ -4222,7 +4224,7 @@ func TestUploadDetailedSummary(t *testing.T) {

func createUploadConfiguration() *utils.UploadConfiguration {
uploadConfiguration := new(utils.UploadConfiguration)
uploadConfiguration.Threads = cliutils.Threads
uploadConfiguration.Threads = commonCliUtils.Threads
return uploadConfiguration
}

Expand Down Expand Up @@ -5098,9 +5100,9 @@ func TestConfigEncryption(t *testing.T) {
assert.NoError(t, configCli.Exec("add", "server-2"))

// Expect no error after reading it
assert.NoError(t, tests.NewJfrogCli(execMain, "jfrog config", "").Exec("show"))
assert.NoError(t, tests.NewJfrogCli(execMain, "jfrog rt", "--server-id=server-1").Exec("ping"))
assert.NoError(t, tests.NewJfrogCli(execMain, "jfrog rt", "--server-id=server-2").Exec("ping"))
assert.NoError(t, coretests.NewJfrogCli(execMain, "jfrog config", "").Exec("show"))
assert.NoError(t, coretests.NewJfrogCli(execMain, "jfrog rt", "--server-id=server-1").Exec("ping"))
assert.NoError(t, coretests.NewJfrogCli(execMain, "jfrog rt", "--server-id=server-2").Exec("ping"))
}

func TestConfigEncryptionMissingKey(t *testing.T) {
Expand Down Expand Up @@ -5194,7 +5196,7 @@ func pipeStdinSecret(t *testing.T, secret string) func() {
func TestArtifactoryReplicationCreate(t *testing.T) {
initArtifactoryTest(t, "")
// Configure server with dummy credentials
err := tests.NewJfrogCli(execMain, "jfrog config", "").Exec("add", tests.ServerId, "--artifactory-url="+*tests.JfrogUrl+tests.ArtifactoryEndpoint, "--user=admin", "--password=password", "--enc-password=false")
err := coretests.NewJfrogCli(execMain, "jfrog config", "").Exec("add", tests.ServerId, "--artifactory-url="+*tests.JfrogUrl+tests.ArtifactoryEndpoint, "--user=admin", "--password=password", "--enc-password=false")
defer deleteServerConfig(t)
assert.NoError(t, err)

Expand Down Expand Up @@ -5244,7 +5246,7 @@ func TestArtifactoryAccessTokenCreate(t *testing.T) {
*tests.JfrogAccessToken = origAccessToken
}()
*tests.JfrogAccessToken = ""
err := tests.NewJfrogCli(execMain, "jfrog rt", authenticate(false)).Exec("atc")
err := coretests.NewJfrogCli(execMain, "jfrog rt", authenticate(false)).Exec("atc")
assert.NoError(t, err)
} else {
runRt(t, "atc")
Expand Down Expand Up @@ -5273,7 +5275,7 @@ func checkAccessToken(t *testing.T, buffer *bytes.Buffer) {
assert.NoError(t, err)

// Try ping with the new token
err = tests.NewJfrogCli(execMain, "jfrog rt", "--url="+*tests.JfrogUrl+tests.ArtifactoryEndpoint+" --access-token="+token).Exec("ping")
err = coretests.NewJfrogCli(execMain, "jfrog rt", "--url="+*tests.JfrogUrl+tests.ArtifactoryEndpoint+" --access-token="+token).Exec("ping")
assert.NoError(t, err)
}

Expand All @@ -5290,7 +5292,7 @@ func TestRefreshableArtifactoryTokens(t *testing.T) {
assert.NoError(t, err)

// Upload a file and assert the refreshable tokens were generated.
artifactoryCommandExecutor := tests.NewJfrogCli(execMain, "jfrog rt", "")
artifactoryCommandExecutor := coretests.NewJfrogCli(execMain, "jfrog rt", "")
uploadedFiles := 1
err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a1.in", uploadedFiles)
if err != nil {
Expand Down Expand Up @@ -5415,7 +5417,7 @@ func assertTokensChanged(t *testing.T, curAccessToken, curRefreshToken string) (
return newAccessToken, newRefreshToken, nil
}

func uploadWithSpecificServerAndVerify(t *testing.T, cli *tests.JfrogCli, source string, expectedResults int) error {
func uploadWithSpecificServerAndVerify(t *testing.T, cli *coretests.JfrogCli, source string, expectedResults int) error {
err := cli.Exec("upload", source, tests.RtRepo1, "--server-id="+tests.ServerId)
if err != nil {
assert.NoError(t, err)
Expand Down
18 changes: 11 additions & 7 deletions build/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# Function to get fromVersion from a file
populateFromVersion() {
build/build.sh
fromVersion=$(./jf -v | tr -d 'jfrog version' | tr -d '\n')
local versionString
versionString=$(./jf -v)
fromVersion=${versionString//[^0-9.+]/}
}

# Function to validate arguments
Expand Down Expand Up @@ -32,17 +34,18 @@ validateVersions() {
exit 1
fi

echo Bumping version from $fromVersion to $toVersion
echo "Bumping version from $fromVersion to $toVersion"
}

createBranch() {
branchName=bump-ver-from-$fromVersion-to-$toVersion
branchName="bump-ver-from-$fromVersion-to-$toVersion"
git remote rm upstream
git remote add upstream https://github.com/jfrog/jfrog-cli.git
git checkout dev
git fetch upstream dev
git pull upstream dev
git reset --hard upstream/dev
git push
git checkout -b $branchName
git checkout -b "$branchName"
}

# Function to replace version in file
Expand Down Expand Up @@ -83,7 +86,7 @@ replaceVersion() {
}

## Validate the argument was received.
validateArg
validateArg "$@"

## Read the script argument into the toVersion variable
toVersion=$1
Expand All @@ -108,4 +111,5 @@ replaceVersion "build/npm/v2-jf/package.json" "\"version\": \"$fromVersion\"," "
echo "Version bumped successfully."

## Push the new branch, with the version bump
git push --set-upstream origin $branchName
git commit -m "Bump version from $fromVersion to $toVersion"
git push --set-upstream origin "$branchName"
6 changes: 3 additions & 3 deletions buildinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestBuildAddDependenciesDryRun(t *testing.T) {
chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, "testdata")
defer chdirCallback()

noCredsCli := tests.NewJfrogCli(execMain, "jfrog rt", "")
noCredsCli := coretests.NewJfrogCli(execMain, "jfrog rt", "")
// Execute the bad command on the local file system
assert.NoError(t, noCredsCli.Exec("bad", tests.RtBuildName1, "1", "a/*", "--dry-run=true"))
buildDir, err := build.GetBuildDir(tests.RtBuildName1, "1", "")
Expand Down Expand Up @@ -660,7 +660,7 @@ func TestBuildAddGitEnvBuildNameAndNumber(t *testing.T) {

func testBuildAddGit(t *testing.T, useEnvBuildNameAndNumber bool) {
initArtifactoryTest(t, "")
gitCollectCliRunner := tests.NewJfrogCli(execMain, "jfrog rt", "")
gitCollectCliRunner := coretests.NewJfrogCli(execMain, "jfrog rt", "")
buildNumber := "13"

// Populate cli config with 'default' server
Expand Down Expand Up @@ -843,7 +843,7 @@ func TestModuleName(t *testing.T) {
}

func collectDepsAndPublishBuild(badTest buildAddDepsBuildInfoTestParams, useEnvBuildNameAndNumber bool, t *testing.T) {
noCredsCli := tests.NewJfrogCli(execMain, "jfrog rt", "")
noCredsCli := coretests.NewJfrogCli(execMain, "jfrog rt", "")
// Remove old tests data from fs if exists
err := build.RemoveBuildDir(badTest.buildName, badTest.buildNumber, "")
assert.NoError(t, err)
Expand Down
Loading

0 comments on commit ff4f745

Please sign in to comment.