Skip to content

Commit

Permalink
reverting stubserver changes
Browse files Browse the repository at this point in the history
  • Loading branch information
janardhankrishna-sai committed Dec 13, 2024
1 parent 1c11e23 commit 6e64672
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions test/creds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/internal/stubserver"
"google.golang.org/grpc/internal/testutils"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/resolver"
Expand Down Expand Up @@ -470,37 +469,22 @@ func (s) TestCredsHandshakeServerNameAuthority(t *testing.T) {
cred := &authorityCheckCreds{}
defer lis.Close()

stub := &stubserver.StubServer{
Listener: lis,
EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) {
return &testpb.Empty{}, nil
},
}
stub.S = grpc.NewServer()
stubserver.StartTestService(t, stub)
s := grpc.NewServer()
go s.Serve(lis)
defer s.Stop()

r := manual.NewBuilderWithScheme("whatever")

r.InitialState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String(), ServerName: testServerName}}})
cc, err := grpc.NewClient(r.Scheme()+":///"+testAuthority, grpc.WithTransportCredentials(cred), grpc.WithResolvers(r))
if err != nil {
t.Fatalf("grpc.NewClient(%q) = %v", lis.Addr().String(), err)
}
cc.Connect()
defer cc.Close()

// Start a goroutine to update the resolver state.
go func() {
<-time.After(100 * time.Millisecond)
r.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String(), ServerName: testServerName}}})
}()

ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()

// Perform an RPC to trigger the connection process and use the resolver.
client := testpb.NewTestServiceClient(cc)
if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err != nil {
t.Fatalf("Test RPC failed: %v", err)
}
testutils.AwaitState(ctx, t, cc, connectivity.Ready)

if cred.got != testServerName {
t.Fatalf("client creds got authority: %q, want: %q", cred.got, testAuthority)
Expand Down

0 comments on commit 6e64672

Please sign in to comment.