Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrog-ecosystem committed May 9, 2024
2 parents 4ee40cf + dd2d090 commit 603502c
Show file tree
Hide file tree
Showing 40 changed files with 381 additions and 235 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/gradleTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
with:
go-version: 1.20.x
cache: false
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
19 changes: 13 additions & 6 deletions access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ func TestRefreshableAccessTokens(t *testing.T) {
if !assert.NoError(t, err) {
return
}
curAccessToken, curRefreshToken, err := getAccessTokensFromConfig(t, tests.ServerId)
curAccessToken, curRefreshToken, curArtifactoryRefreshToken, err := getTokensFromConfig(t)
if !assert.NoError(t, err) {
return
}
assert.NotEmpty(t, curAccessToken)
assert.NotEmpty(t, curRefreshToken)
assert.Empty(t, curArtifactoryRefreshToken)

// Make the token always refresh.
auth.RefreshPlatformTokenBeforeExpiryMinutes = 365 * 24 * 60
Expand All @@ -137,7 +138,7 @@ func TestRefreshableAccessTokens(t *testing.T) {
if !assert.NoError(t, err) {
return
}
curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken)
curAccessToken, curRefreshToken, err = assertAccessTokensChanged(t, curAccessToken, curRefreshToken)
if !assert.NoError(t, err) {
return
}
Expand All @@ -149,24 +150,30 @@ func TestRefreshableAccessTokens(t *testing.T) {
if !assert.NoError(t, err) {
return
}
newAccessToken, newRefreshToken, err := getArtifactoryTokensFromConfig(t)
newAccessToken, newRefreshToken, newArtifactoryRefreshToken, err := getTokensFromConfig(t)
if !assert.NoError(t, err) {
return
}
assert.Equal(t, curAccessToken, newAccessToken)
assert.Equal(t, curRefreshToken, newRefreshToken)
assert.Empty(t, newArtifactoryRefreshToken)

// Cleanup
cleanArtifactoryTest()
}

func getAccessTokensFromConfig(t *testing.T, serverId string) (accessToken, refreshToken string, err error) {
details, err := config.GetSpecificConfig(serverId, false, false)
// After refreshing an access token, assert that the access token and the refresh token were changed, and the Artifactory refresh token remained empty.
func assertAccessTokensChanged(t *testing.T, curAccessToken, curRefreshToken string) (newAccessToken, newRefreshToken string, err error) {
var newArtifactoryRefreshToken string
newAccessToken, newRefreshToken, newArtifactoryRefreshToken, err = getTokensFromConfig(t)
if err != nil {
assert.NoError(t, err)
return "", "", err
}
return details.AccessToken, details.RefreshToken, nil
assert.NotEqual(t, curAccessToken, newAccessToken)
assert.NotEqual(t, curRefreshToken, newRefreshToken)
assert.Empty(t, newArtifactoryRefreshToken)
return newAccessToken, newRefreshToken, nil
}

const (
Expand Down
11 changes: 5 additions & 6 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ func GetCommands() []cli.Command {
Name: "go",
Hidden: true,
Flags: cliutils.GetCommandFlags(cliutils.Go),
Aliases: []string{"go"},
Usage: gocommand.GetDescription(),
HelpName: corecommon.CreateUsage("rt go", gocommand.GetDescription(), gocommand.Usage),
UsageText: gocommand.GetArguments(),
Expand Down Expand Up @@ -1186,7 +1185,7 @@ func prepareDownloadCommand(c *cli.Context) (*spec.SpecFiles, error) {
var downloadSpec *spec.SpecFiles
var err error
if c.IsSet("spec") {
downloadSpec, err = cliutils.GetSpec(c, true)
downloadSpec, err = cliutils.GetSpec(c, true, true)
} else {
downloadSpec, err = createDefaultDownloadSpec(c)
}
Expand Down Expand Up @@ -1315,7 +1314,7 @@ func prepareCopyMoveCommand(c *cli.Context) (*spec.SpecFiles, error) {
var copyMoveSpec *spec.SpecFiles
var err error
if c.IsSet("spec") {
copyMoveSpec, err = cliutils.GetSpec(c, false)
copyMoveSpec, err = cliutils.GetSpec(c, false, true)
} else {
copyMoveSpec, err = createDefaultCopyMoveSpec(c)
}
Expand Down Expand Up @@ -1403,7 +1402,7 @@ func prepareDeleteCommand(c *cli.Context) (*spec.SpecFiles, error) {
var deleteSpec *spec.SpecFiles
var err error
if c.IsSet("spec") {
deleteSpec, err = cliutils.GetSpec(c, false)
deleteSpec, err = cliutils.GetSpec(c, false, true)
} else {
deleteSpec, err = createDefaultDeleteSpec(c)
}
Expand Down Expand Up @@ -1458,7 +1457,7 @@ func prepareSearchCommand(c *cli.Context) (*spec.SpecFiles, error) {
var searchSpec *spec.SpecFiles
var err error
if c.IsSet("spec") {
searchSpec, err = cliutils.GetSpec(c, false)
searchSpec, err = cliutils.GetSpec(c, false, true)
} else {
searchSpec, err = createDefaultSearchSpec(c)
}
Expand Down Expand Up @@ -1525,7 +1524,7 @@ func preparePropsCmd(c *cli.Context) (*generic.PropsCommand, error) {
var props string
if c.IsSet("spec") {
props = c.Args()[0]
propsSpec, err = cliutils.GetSpec(c, false)
propsSpec, err = cliutils.GetSpec(c, false, true)
} else {
propsSpec, err = createDefaultPropertiesSpec(c)
if c.NArg() == 1 {
Expand Down
12 changes: 7 additions & 5 deletions artifactory/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ var createUploadConfigurationCases = []struct {
expectedSplitCount int
expectedThreads int
expectedDeb string
expectedChunkSize int64
}{
{"empty", []string{}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, commonCliUtils.Threads, ""},
{"min-split", []string{"min-split=101"}, 101, cliutils.UploadSplitCount, commonCliUtils.Threads, ""},
{"split-count", []string{"split-count=6"}, cliutils.UploadMinSplitMb, 6, commonCliUtils.Threads, ""},
{"threads", []string{"threads=6"}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, 6, ""},
{"deb", []string{"deb=jammy/main/i386"}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, commonCliUtils.Threads, "jammy/main/i386"},
{"empty", []string{}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, commonCliUtils.Threads, "", cliutils.UploadChunkSizeMb},
{"min-split", []string{"min-split=101"}, 101, cliutils.UploadSplitCount, commonCliUtils.Threads, "", cliutils.UploadChunkSizeMb},
{"split-count", []string{"split-count=6"}, cliutils.UploadMinSplitMb, 6, commonCliUtils.Threads, "", cliutils.UploadChunkSizeMb},
{"threads", []string{"threads=6"}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, 6, "", cliutils.UploadChunkSizeMb},
{"deb", []string{"deb=jammy/main/i386"}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, commonCliUtils.Threads, "jammy/main/i386", cliutils.UploadChunkSizeMb},
{"chunk-size", []string{"chunk-size=123"}, cliutils.UploadMinSplitMb, cliutils.UploadSplitCount, commonCliUtils.Threads, "", 123},
}

func TestCreateUploadConfiguration(t *testing.T) {
Expand Down
33 changes: 19 additions & 14 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5343,12 +5343,13 @@ func TestRefreshableArtifactoryTokens(t *testing.T) {
if err != nil {
return
}
curAccessToken, curRefreshToken, err := getArtifactoryTokensFromConfig(t)
curAccessToken, curRefreshToken, curArtifactoryRefreshToken, err := getTokensFromConfig(t)
if err != nil {
return
}
assert.NotEmpty(t, curAccessToken)
assert.NotEmpty(t, curRefreshToken)
assert.NotEmpty(t, curArtifactoryRefreshToken)
assert.Empty(t, curRefreshToken)

// Make the token always refresh.
auth.RefreshArtifactoryTokenBeforeExpiryMinutes = 60
Expand All @@ -5359,7 +5360,7 @@ func TestRefreshableArtifactoryTokens(t *testing.T) {
if err != nil {
return
}
curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken)
curAccessToken, curArtifactoryRefreshToken, err = assertArtifactoryTokensChanged(t, curAccessToken, curArtifactoryRefreshToken)
if err != nil {
return
}
Expand All @@ -5374,7 +5375,7 @@ func TestRefreshableArtifactoryTokens(t *testing.T) {
if err != nil {
return
}
curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken)
curAccessToken, curArtifactoryRefreshToken, err = assertArtifactoryTokensChanged(t, curAccessToken, curArtifactoryRefreshToken)
if err != nil {
return
}
Expand All @@ -5389,7 +5390,7 @@ func TestRefreshableArtifactoryTokens(t *testing.T) {
if err != nil {
return
}
curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken)
curAccessToken, curArtifactoryRefreshToken, err = assertArtifactoryTokensChanged(t, curAccessToken, curArtifactoryRefreshToken)
if err != nil {
return
}
Expand All @@ -5401,12 +5402,13 @@ func TestRefreshableArtifactoryTokens(t *testing.T) {
if err != nil {
return
}
newAccessToken, newRefreshToken, err := getArtifactoryTokensFromConfig(t)
newAccessToken, newRefreshToken, newArtifactoryRefreshToken, err := getTokensFromConfig(t)
if err != nil {
return
}
assert.Equal(t, curAccessToken, newAccessToken)
assert.Equal(t, curRefreshToken, newRefreshToken)
assert.Equal(t, curArtifactoryRefreshToken, newArtifactoryRefreshToken)
assert.Empty(t, newRefreshToken)

// Cleanup
cleanArtifactoryTest()
Expand Down Expand Up @@ -5442,24 +5444,27 @@ func setPasswordInConfig(t *testing.T, serverId, password string) error {
return nil
}

func getArtifactoryTokensFromConfig(t *testing.T) (accessToken, refreshToken string, err error) {
func getTokensFromConfig(t *testing.T) (accessToken, refreshToken, artifactoryRefreshToken string, err error) {
details, err := config.GetSpecificConfig(tests.ServerId, false, false)
if err != nil {
assert.NoError(t, err)
return "", "", err
return "", "", "", err
}
return details.AccessToken, details.ArtifactoryRefreshToken, nil
return details.AccessToken, details.RefreshToken, details.ArtifactoryRefreshToken, nil
}

func assertTokensChanged(t *testing.T, curAccessToken, curRefreshToken string) (newAccessToken, newRefreshToken string, err error) {
newAccessToken, newRefreshToken, err = getArtifactoryTokensFromConfig(t)
// After refreshing an Artifactory access token, assert that the access token and the artifactory refresh token were changed, and refresh token remained empty.
func assertArtifactoryTokensChanged(t *testing.T, curAccessToken, curArtifactoryRefreshToken string) (newAccessToken, newArtifactoryRefreshToken string, err error) {
var newRefreshToken string
newAccessToken, newRefreshToken, newArtifactoryRefreshToken, err = getTokensFromConfig(t)
if err != nil {
assert.NoError(t, err)
return "", "", err
}
assert.NotEqual(t, curAccessToken, newAccessToken)
assert.NotEqual(t, curRefreshToken, newRefreshToken)
return newAccessToken, newRefreshToken, nil
assert.NotEqual(t, curArtifactoryRefreshToken, newArtifactoryRefreshToken)
assert.Empty(t, newRefreshToken)
return newAccessToken, newArtifactoryRefreshToken, nil
}

func uploadWithSpecificServerAndVerify(t *testing.T, cli *coretests.JfrogCli, source string, expectedResults int) error {
Expand Down
2 changes: 1 addition & 1 deletion build/npm/v2-jf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/npm/v2-jf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jfrog-cli-v2-jf",
"version": "2.56.0",
"version": "2.56.1",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
2 changes: 1 addition & 1 deletion build/npm/v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/npm/v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jfrog-cli-v2",
"version": "2.56.0",
"version": "2.56.1",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
1 change: 0 additions & 1 deletion buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ func GetCommands() []cli.Command {
{
Name: "go",
Flags: cliutils.GetCommandFlags(cliutils.Go),
Aliases: []string{"go"},
Usage: gocommand.GetDescription(),
HelpName: corecommon.CreateUsage("go", gocommand.GetDescription(), gocommand.Usage),
UsageText: gocommand.GetArguments(),
Expand Down
4 changes: 2 additions & 2 deletions distribution/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func releaseBundleCreateCmd(c *cli.Context) error {
var releaseBundleCreateSpec *spec.SpecFiles
var err error
if c.IsSet("spec") {
releaseBundleCreateSpec, err = cliutils.GetSpec(c, true)
releaseBundleCreateSpec, err = cliutils.GetSpec(c, true, true)
} else {
releaseBundleCreateSpec = createDefaultReleaseBundleSpec(c)
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func releaseBundleUpdateCmd(c *cli.Context) error {
var releaseBundleUpdateSpec *spec.SpecFiles
var err error
if c.IsSet("spec") {
releaseBundleUpdateSpec, err = cliutils.GetSpec(c, true)
releaseBundleUpdateSpec, err = cliutils.GetSpec(c, true, true)
} else {
releaseBundleUpdateSpec = createDefaultReleaseBundleSpec(c)
}
Expand Down
6 changes: 5 additions & 1 deletion docs/artifactory/buildaddgit/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package buildaddgit
var Usage = []string{"rt bag [command options] <build name> <build number> [Path To .git]"}

func GetDescription() string {
return "Collect VCS details from git and add them to a build."
return `Collects the Git revision and URL from the local .git directory and adds it to the build-info.
It can also collect the list of tracked project issues (for example, issues stored in JIRA or other bug tracking systems) and add them to the build-info.
The issues are collected by reading the git commit messages from the local git log.
Each commit message is matched against a pre-configured regular expression, which retrieves the issue ID and issue summary.
The information required for collecting the issues is retrieved from a yaml configuration file provided to the command.`
}

func GetArguments() string {
Expand Down
6 changes: 3 additions & 3 deletions docs/artifactory/copy/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ var Usage = []string{"rt cp [command options] <source pattern> <target pattern>"
const EnvVar string = common.JfrogCliFailNoOp

func GetDescription() string {
return "Copy files."
return "Copy files between Artifactory paths."
}

func GetArguments() string {
return ` source Pattern
return ` source pattern
Specifies the source path in Artifactory, from which the artifacts should be copied,
in the following format: <repository name>/<repository path>. You can use wildcards to specify multiple artifacts.
target Pattern
target pattern
Specifies the target path in Artifactory, to which the artifacts should be copied, in the following format: <repository name>/<repository path>.
If the pattern ends with a slash, the target path is assumed to be a folder. For example, if you specify the target as "repo-name/a/b/",
then "b" is assumed to be a folder in Artifactory into which files should be copied.
Expand Down
2 changes: 1 addition & 1 deletion docs/artifactory/delete/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Usage = []string{"rt del [command options] <delete pattern>",
const EnvVar string = common.JfrogCliFailNoOp

func GetDescription() string {
return "Delete files."
return "Delete files from Artifactory."
}

func GetArguments() string {
Expand Down
11 changes: 6 additions & 5 deletions docs/artifactory/deleteprops/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package deleteprops

import "github.com/jfrog/jfrog-cli/docs/common"

var Usage = []string{"rt delp [command options] <artifacts pattern> <artifact properties>",
"rt delp <artifact properties> --spec=<File Spec path> [command options]"}
var Usage = []string{"rt delp [command options] <files pattern> <properties list>",
"rt delp <properties list> --spec=<File Spec path> [command options]"}

const EnvVar string = common.JfrogCliFailNoOp

Expand All @@ -12,9 +12,10 @@ func GetDescription() string {
}

func GetArguments() string {
return ` artifacts pattern
return ` files pattern
Properties of artifacts that match this pattern will be removed.
in the following format: <repository name>/<repository path>. You can use wildcards to specify multiple artifacts.
artifact properties
The list of properties, in the form of key1,key2,..., to be removed from the matching artifacts.`
properties list
List of comma-separated(,) properties, in the form of key1,key2,..., to be removed from the matching files.`
}
2 changes: 1 addition & 1 deletion docs/artifactory/download/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Usage = []string{"rt dl [command options] <source pattern> [target pattern]"
var EnvVar = []string{common.JfrogCliTransitiveDownloadExperimental, common.JfrogCliFailNoOp}

func GetDescription() string {
return "Download files."
return "Download files from Artifactory to local file system."
}

func GetArguments() string {
Expand Down
2 changes: 1 addition & 1 deletion docs/artifactory/groupaddusers/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ func GetArguments() string {
users list
Specifies the usernames to add to the specified group.
The list should be comma-separated.
The list should be comma-separated(,) in the form of user1,user2,...
`
}
2 changes: 1 addition & 1 deletion docs/artifactory/move/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Usage = []string{"rt mv [command options] <source pattern> <target pattern>"
var EnvVar = common.JfrogCliFailNoOp

func GetDescription() string {
return "Move files."
return "Move files between Artifactory paths."
}

func GetArguments() string {
Expand Down
Loading

0 comments on commit 603502c

Please sign in to comment.