Skip to content

Commit 4793ad0

Browse files
authored
credentials/alts: preserve boundAccessToken in altsTC.Clone (#9345)
`altsTC.Clone` does not copy `boundAccessToken`, so a cloned ALTS credential silently loses the token and performs its handshake without it. RELEASE NOTES: none
1 parent 3284af7 commit 4793ad0

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

credentials/alts/alts.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,11 @@ func (g *altsTC) Clone() credentials.TransportCredentials {
266266
copy(accounts, g.accounts)
267267
}
268268
return &altsTC{
269-
info: &info,
270-
side: g.side,
271-
hsAddress: g.hsAddress,
272-
accounts: accounts,
269+
info: &info,
270+
side: g.side,
271+
hsAddress: g.hsAddress,
272+
accounts: accounts,
273+
boundAccessToken: g.boundAccessToken,
273274
}
274275
}
275276

credentials/alts/alts_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (s) TestCloneClient(t *testing.T) {
9191
opt := DefaultClientOptions()
9292
opt.TargetServiceAccounts = []string{"not", "empty"}
9393
c := NewClientCreds(opt)
94+
c.(*altsTC).boundAccessToken = "bound-access-token"
9495
c.OverrideServerName(wantServerName)
9596
cc := c.Clone()
9697
if got, want := cc.Info().ServerName, wantServerName; got != want {
@@ -116,6 +117,9 @@ func (s) TestCloneClient(t *testing.T) {
116117
if !reflect.DeepEqual(ct.accounts, cct.accounts) {
117118
t.Errorf("cc.accounts = %q, want %q", cct.accounts, ct.accounts)
118119
}
120+
if ct.boundAccessToken != cct.boundAccessToken {
121+
t.Errorf("cc.boundAccessToken = %q, want %q", cct.boundAccessToken, ct.boundAccessToken)
122+
}
119123
}
120124

121125
func (s) TestCloneServer(t *testing.T) {

0 commit comments

Comments
 (0)