@@ -3,9 +3,9 @@ package main
33import (
44 "encoding/json"
55 "fmt"
6+ "github.com/jfrog/jfrog-cli-core/v2/general/token"
67 "net/http"
78 "os"
8- "regexp"
99 "testing"
1010
1111 "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
@@ -274,30 +274,18 @@ func TestAccessTokenCreate(t *testing.T) {
274274func TestOidcExchangeToken (t * testing.T ) {
275275 // If token ID was not provided by the CI, skip this test
276276 if os .Getenv (coreutils .OidcExchangeTokenId ) == "" {
277- t .Skip ("No token ID available in environment,skipping test" )
277+ t .Skip ("No token ID available in environment, skipping test" )
278278 return
279279 }
280280 accessCli = coreTests .NewJfrogCli (execMain , "jfrog" , "" )
281- var testCases = []struct {
282- name string
283- args []string
284- expectedOutput string
285- }{
286- {
287- name : "Successful exchange" ,
288- args : []string {"eot" , "setup-jfrog-cli-test" , "--url=https://ecosysjfrog.jfrog.io" },
289- expectedOutput : `\{ AccessToken: [^\s]+ Username: [^\s]+ \}` ,
290- },
291- }
292281
293- for _ , testCase := range testCases {
294- t .Run (testCase .name , func (t * testing.T ) {
295- output := accessCli .RunCliCmdWithOutput (t , testCase .args ... )
296- matched , err := regexp .MatchString (testCase .expectedOutput , output )
297- assert .NoError (t , err )
298- assert .True (t , matched , "Output did not match expected pattern" )
299- })
300- }
282+ output := accessCli .RunCliCmdWithOutput (t , "eot" , "setup-jfrog-cli-test" , "--url=https://ecosysjfrog.jfrog.io" )
283+ var result token.ExchangeCommandOutputStruct
284+ err := json .Unmarshal ([]byte (output ), & result )
285+ assert .NoError (t , err , "Output should be valid JSON" )
286+ assert .NotEmpty (t , result .AccessToken , "AccessToken should not be empty" )
287+ assert .NotEmpty (t , result .Username , "Username should not be empty" )
288+
301289}
302290
303291func assertNotEmptyIfExpected (t * testing.T , expected bool , output string ) {
0 commit comments