@@ -3,9 +3,9 @@ package main
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
+ "github.com/jfrog/jfrog-cli-core/v2/general/token"
6
7
"net/http"
7
8
"os"
8
- "regexp"
9
9
"testing"
10
10
11
11
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
@@ -274,30 +274,18 @@ func TestAccessTokenCreate(t *testing.T) {
274
274
func TestOidcExchangeToken (t * testing.T ) {
275
275
// If token ID was not provided by the CI, skip this test
276
276
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" )
278
278
return
279
279
}
280
280
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
- }
292
281
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
+
301
289
}
302
290
303
291
func assertNotEmptyIfExpected (t * testing.T , expected bool , output string ) {
0 commit comments