diff --git a/access_test.go b/access_test.go index 5bf961d74..029c254fd 100644 --- a/access_test.go +++ b/access_test.go @@ -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" @@ -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) { diff --git a/go.mod b/go.mod index a753b5716..ed29656ef 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 73082262a..0f8eb9079 100644 --- a/go.sum +++ b/go.sum @@ -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=