Skip to content

Commit

Permalink
Merge pull request #102063 from tdihp/fix/azure-auth-refresh
Browse files Browse the repository at this point in the history
Azure auth forwarding adal refresh error to azureTokenSource
  • Loading branch information
k8s-ci-robot committed Jun 2, 2021
2 parents 807e70c + e105611 commit eee6e54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -354,7 +354,6 @@ func (ts *azureTokenSource) Refresh(token *azureToken) (*azureToken, error) {
}

// refresh outdated token with adal.
// adal.RefreshTokenError will be returned if error occur during refreshing.
func (ts *azureTokenSourceDeviceCode) Refresh(token *azureToken) (*azureToken, error) {
env, err := azure.EnvironmentFromName(token.environment)
if err != nil {
Expand Down Expand Up @@ -388,7 +387,8 @@ func (ts *azureTokenSourceDeviceCode) Refresh(token *azureToken) (*azureToken, e
}

if err := spt.Refresh(); err != nil {
return nil, fmt.Errorf("refreshing token: %v", err)
// Caller expects IsTokenRefreshError(err) to trigger prompt.
return nil, fmt.Errorf("refreshing token: %w", err)
}

return &azureToken{
Expand Down
Expand Up @@ -330,6 +330,16 @@ func TestAzureTokenSourceScenarios(t *testing.T) {
tokenCalls: 1,
persistCalls: 1,
},
{
name: "extend failure with fmt.Errorf nested tokenRefreshError",
configToken: expiredToken,
refreshErr: fmt.Errorf("refreshing token: %w", fakeTokenRefreshError{message: "nested FakeError happened when refreshing"}),
sourceToken: fakeToken,
expectToken: fakeToken,
refreshCalls: 1,
tokenCalls: 1,
persistCalls: 1,
},
{
name: "unexpected error when extend",
configToken: expiredToken,
Expand Down

0 comments on commit eee6e54

Please sign in to comment.