Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3f4faf4
chnages added for the bug
cx-harshjeet-patil Jan 1, 2026
1c3f1d9
some new chnages for bug
cx-harshjeet-patil Jan 1, 2026
fc453ad
chnages restored
cx-harshjeet-patil Jan 1, 2026
f7d0138
comment removed
cx-harshjeet-patil Jan 1, 2026
111d604
code matched to main
cx-harshjeet-patil Jan 1, 2026
cd90cd3
new changes for the bug
cx-harshjeet-patil Jan 2, 2026
f5daffa
final code changes
cx-harshjeet-patil Jan 2, 2026
bd30069
new changes
cx-harshjeet-patil Jan 5, 2026
cd45691
removed unused dependency
cx-harshjeet-patil Jan 5, 2026
a2ec18f
file restored
cx-harshjeet-patil Jan 5, 2026
d8811b1
commit
cx-harshjeet-patil Jan 5, 2026
eeb6765
file restored
cx-harshjeet-patil Jan 5, 2026
07db916
Merge branch 'main' into bug/AST-127635
cx-anurag-dalke Jan 8, 2026
0dcef78
Test case correction
cx-harshjeet-patil Jan 12, 2026
e01449f
testing
cx-harshjeet-patil Jan 12, 2026
a41f969
new changes
cx-harshjeet-patil Jan 12, 2026
31c20b4
new commit
cx-harshjeet-patil Jan 12, 2026
1bbd257
unit test case fixed
cx-harshjeet-patil Jan 13, 2026
5bd2d9b
root_test restored
cx-harshjeet-patil Jan 13, 2026
0d36ff0
test case restored
cx-harshjeet-patil Jan 13, 2026
9d4ffcf
added viper reset for integration
cx-harshjeet-patil Jan 14, 2026
cdb0f9f
comment removed
cx-harshjeet-patil Jan 14, 2026
78154bb
removed buffer
cx-harshjeet-patil Jan 14, 2026
307fddc
util command restored
cx-harshjeet-patil Jan 15, 2026
a4f8c8b
new changes
cx-harshjeet-patil Jan 15, 2026
2ec9978
Merge branch 'main' into bug/AST-127635
cx-anjali-deore Jan 16, 2026
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
1 change: 1 addition & 0 deletions internal/commands/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func TestCreateCommand_WithInvalidFlag_ShouldReturnExitCode1(t *testing.T) {

func executeTestCommand(cmd *cobra.Command, args ...string) error {
fmt.Println("Executing command with args ", args)
defer viper.Reset()
cmd.SetArgs(args)
cmd.SilenceUsage = true
return cmd.Execute()
Expand Down
49 changes: 34 additions & 15 deletions internal/wrappers/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,31 +599,50 @@ func configureClientCredentialsAndGetNewToken() (string, error) {
accessKeyID := viper.GetString(commonParams.AccessKeyIDConfigKey)
accessKeySecret := viper.GetString(commonParams.AccessKeySecretConfigKey)
astAPIKey := viper.GetString(commonParams.AstAPIKey)

var accessToken string

if accessKeyID == "" && astAPIKey == "" {
return "", errors.Errorf(FailedToAuth, "access key ID")
} else if accessKeySecret == "" && astAPIKey == "" {
return "", errors.Errorf(FailedToAuth, "access key secret")
if accessKeyID == "" && accessKeySecret == "" && astAPIKey == "" {
return "", errors.Errorf(FailedToAuth, "provide credentials")
}

authURI, err := GetAuthURI()
if err != nil {
return "", err
}
// Prefer client credentials over API key
if accessKeyID != "" && accessKeySecret != "" {
if accessKeyID == "" {
return "", errors.Errorf(FailedToAuth, "access key ID")
}
if accessKeySecret == "" {
return "", errors.Errorf(FailedToAuth, "access key secret")
}

authURI, err := GetAuthURI()
if err != nil {
return "", err
}

if astAPIKey != "" {
accessToken, err = getNewToken(getAPIKeyPayload(astAPIKey), authURI)
} else {
accessToken, err = getNewToken(getCredentialsPayload(accessKeyID, accessKeySecret), authURI)
}
if err != nil {
return "", errors.Errorf("%s", err)
}
} else if astAPIKey != "" {
authURI, err := GetAuthURI()
if err != nil {
return "", err
}

if err != nil {
return "", errors.Errorf("%s", err)
accessToken, err = getNewToken(getAPIKeyPayload(astAPIKey), authURI)
if err != nil {
return "", errors.Errorf("%s", err)
}
} else if accessKeyID != "" || accessKeySecret != "" {
// One is provided but not both
if accessKeyID == "" {
return "", errors.Errorf(FailedToAuth, "access key ID")
}
return "", errors.Errorf(FailedToAuth, "access key secret")
}

writeCredentialsToCache(accessToken)

return accessToken, nil
}

Expand Down
Loading