Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alts: Extract AuthInfo after handshake in ALTS e2e test. #6931

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
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
18 changes: 17 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,20 @@ func establishAltsConnection(t *testing.T, handshakerAddress, serverAddress stri
if !success {
t.Fatalf("c.UnaryCall() timed out after %v", defaultTestShortTimeout)
}

// Check that peer.AuthInfo was populated with an ALTS AuthInfo
// instance. As a sanity check, also verify that the AuthType() and
// ApplicationProtocol() have the expected values.
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
Loading