@@ -40,6 +40,7 @@ import (
40
40
"google.golang.org/grpc/internal/testutils"
41
41
testgrpc "google.golang.org/grpc/interop/grpc_testing"
42
42
testpb "google.golang.org/grpc/interop/grpc_testing"
43
+ "google.golang.org/grpc/peer"
43
44
"google.golang.org/grpc/status"
44
45
)
45
46
@@ -392,9 +393,10 @@ func establishAltsConnection(t *testing.T, handshakerAddress, serverAddress stri
392
393
ctx , cancel := context .WithTimeout (context .Background (), defaultTestLongTimeout )
393
394
defer cancel ()
394
395
c := testgrpc .NewTestServiceClient (conn )
396
+ var peer peer.Peer
395
397
success := false
396
398
for ; ctx .Err () == nil ; <- time .After (defaultTestShortTimeout ) {
397
- _ , err = c .UnaryCall (ctx , & testpb.SimpleRequest {})
399
+ _ , err = c .UnaryCall (ctx , & testpb.SimpleRequest {}, grpc . Peer ( & peer ) )
398
400
if err == nil {
399
401
success = true
400
402
break
@@ -409,6 +411,20 @@ func establishAltsConnection(t *testing.T, handshakerAddress, serverAddress stri
409
411
if ! success {
410
412
t .Fatalf ("c.UnaryCall() timed out after %v" , defaultTestShortTimeout )
411
413
}
414
+
415
+ // Check that peer.AuthInfo was populated with an ALTS AuthInfo
416
+ // instance. As a sanity check, also verify that the AuthType() and
417
+ // ApplicationProtocol() have the expected values.
418
+ if got , want := peer .AuthInfo .AuthType (), "alts" ; got != want {
419
+ t .Errorf ("authInfo.AuthType() = %s, want = %s" , got , want )
420
+ }
421
+ authInfo , err := AuthInfoFromPeer (& peer )
422
+ if err != nil {
423
+ t .Errorf ("AuthInfoFromPeer failed: %v" , err )
424
+ }
425
+ if got , want := authInfo .ApplicationProtocol (), "grpc" ; got != want {
426
+ t .Errorf ("authInfo.ApplicationProtocol() = %s, want = %s" , got , want )
427
+ }
412
428
}
413
429
414
430
func startFakeHandshakerService (t * testing.T , wait * sync.WaitGroup ) (stop func (), address string ) {
0 commit comments