Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
"encoding/json"
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/general/token"
"net/http"
"os"
"regexp"
"testing"

"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
Expand Down Expand Up @@ -274,30 +274,18 @@ func TestAccessTokenCreate(t *testing.T) {
func TestOidcExchangeToken(t *testing.T) {
// If token ID was not provided by the CI, skip this test
if os.Getenv(coreutils.OidcExchangeTokenId) == "" {
t.Skip("No token ID available in environment,skipping test")
t.Skip("No token ID available in environment, skipping test")
return
}
accessCli = coreTests.NewJfrogCli(execMain, "jfrog", "")
var testCases = []struct {
name string
args []string
expectedOutput string
}{
{
name: "Successful exchange",
args: []string{"eot", "setup-jfrog-cli-test", "--url=https://ecosysjfrog.jfrog.io"},
expectedOutput: `\{ AccessToken: [^\s]+ Username: [^\s]+ \}`,
},
}

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
output := accessCli.RunCliCmdWithOutput(t, testCase.args...)
matched, err := regexp.MatchString(testCase.expectedOutput, output)
assert.NoError(t, err)
assert.True(t, matched, "Output did not match expected pattern")
})
}
output := accessCli.RunCliCmdWithOutput(t, "eot", "setup-jfrog-cli-test", "--url=https://ecosysjfrog.jfrog.io")
var result token.ExchangeCommandOutputStruct
err := json.Unmarshal([]byte(output), &result)
assert.NoError(t, err, "Output should be valid JSON")
assert.NotEmpty(t, result.AccessToken, "AccessToken should not be empty")
assert.NotEmpty(t, result.Username, "Username should not be empty")

}

func assertNotEmptyIfExpected(t *testing.T, expected bool, output string) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250410085750-f34f5feea93e
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250505105213-0ba559a374cb

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250406105605-ee90d11546f9

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,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-artifactory v0.2.4 h1:n/BlqkH20jW8T1JPr/QHw+D+wsPZsDU0Qq/+eSGzgAg=
github.com/jfrog/jfrog-cli-artifactory v0.2.4/go.mod h1:tXlrvTtG4l0dPdKFG7nlteuSv7vggF/OVwsq44sgVgA=
github.com/jfrog/jfrog-cli-core/v2 v2.58.4 h1:ywpq2UMOPtp9WcELR54HSJJS0PSgin9plM4If9sDks0=
github.com/jfrog/jfrog-cli-core/v2 v2.58.4/go.mod h1:JbLdMCWL0xVZZ0FY7jd+iTi/gKYqRmRpeLBhAFtldfQ=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250505105213-0ba559a374cb h1:rFO38OtQqjO2mO8cOQibQ0n+i/mMkh/QLq6Ss8fsJjg=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250505105213-0ba559a374cb/go.mod h1:JbLdMCWL0xVZZ0FY7jd+iTi/gKYqRmRpeLBhAFtldfQ=
github.com/jfrog/jfrog-cli-platform-services v1.9.0 h1:r/ETgJuMUOUu12w20ydsF6paqEaj0khH6bxMRsdNz1Y=
github.com/jfrog/jfrog-cli-platform-services v1.9.0/go.mod h1:pMZMSwhj7yA4VKyj0Skr2lObIyGpZUxNJ40DSLKXU38=
github.com/jfrog/jfrog-cli-security v1.17.1 h1:4gXZ9Q59DOBkntMBDjlcVdZ1jaJUn1bFy4Rhr+SAeqA=
Expand Down
Loading