Skip to content

Commit

Permalink
alts: Extract AuthInfo after handshake in ALTS e2e test.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewstevenson88 committed Jan 19, 2024
1 parent 987df13 commit 37a0d44
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion credentials/alts/alts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"google.golang.org/grpc/internal/testutils"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"
)

Expand Down Expand Up @@ -392,9 +393,10 @@ func establishAltsConnection(t *testing.T, handshakerAddress, serverAddress stri
ctx, cancel := context.WithTimeout(context.Background(), defaultTestLongTimeout)
defer cancel()
c := testgrpc.NewTestServiceClient(conn)
var peer peer.Peer
success := false
for ; ctx.Err() == nil; <-time.After(defaultTestShortTimeout) {
_, err = c.UnaryCall(ctx, &testpb.SimpleRequest{})
_, err = c.UnaryCall(ctx, &testpb.SimpleRequest{}, grpc.Peer(&peer))
if err == nil {
success = true
break
Expand All @@ -409,6 +411,16 @@ func establishAltsConnection(t *testing.T, handshakerAddress, serverAddress stri
if !success {
t.Fatalf("c.UnaryCall() timed out after %v", defaultTestShortTimeout)
}
if got, want := peer.AuthInfo.AuthType(), "alts"; got != want {
t.Errorf("authInfo.AuthType() = %s, want = %s", got, want)
}
authInfo, err := AuthInfoFromPeer(&peer)
if err != nil {
t.Errorf("AuthInfoFromPeer failed: %v", err)
}
if got, want := authInfo.ApplicationProtocol(), "grpc"; got != want {
t.Errorf("authInfo.ApplicationProtocol() = %s, want = %s", got, want)
}
}

func startFakeHandshakerService(t *testing.T, wait *sync.WaitGroup) (stop func(), address string) {
Expand Down

0 comments on commit 37a0d44

Please sign in to comment.