Skip to content

Commit

Permalink
UsesXDS
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonsinth committed Jan 24, 2024
1 parent 3fc2238 commit 3ca27b7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions grpcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,8 @@ func (c *errSignalingCreds) ClientHandshake(ctx context.Context, addr string, ra
}
return conn, auth, err
}

func (c *errSignalingCreds) UsesXDS() bool {
xc, ok := c.TransportCredentials.(interface{ UsesXDS() bool })
return ok && xc.UsesXDS()
}
25 changes: 25 additions & 0 deletions xds_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package grpcurl

import (
"testing"

"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/credentials/xds"
)

func TestXdsWrapping(t *testing.T) {
x, _ := xds.NewClientCredentials(xds.ClientOptions{FallbackCreds: insecure.NewCredentials()})
e := &errSignalingCreds{
TransportCredentials: x,
writeResult: nil,
}
ec := credentials.TransportCredentials(e)
xc, ok := ec.(interface{ UsesXDS() bool })
if !ok {
t.Errorf("expected to implement UsesXDS")
}
if !xc.UsesXDS() {
t.Errorf("expected to UsesXDS")
}
}

0 comments on commit 3ca27b7

Please sign in to comment.