Skip to content

Commit 5addb43

Browse files
committed
xds/cdsbalancer: cleanup security tests
1 parent cc705fe commit 5addb43

File tree

3 files changed

+757
-468
lines changed

3 files changed

+757
-468
lines changed

internal/credentials/xds/handshake_info.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,26 @@ type handshakeAttrKey struct{}
4646
// Equal reports whether the handshake info structs are identical (have the
4747
// same pointer). This is sufficient as all subconns from one CDS balancer use
4848
// the same one.
49-
func (hi *HandshakeInfo) Equal(o any) bool {
50-
oh, ok := o.(*HandshakeInfo)
51-
return ok && oh == hi
49+
func (hi *HandshakeInfo) Equal(other *HandshakeInfo) bool {
50+
if hi == nil && other == nil {
51+
return true
52+
}
53+
if hi == nil || other == nil {
54+
return false
55+
}
56+
if hi.rootProvider != other.rootProvider ||
57+
hi.identityProvider != other.identityProvider ||
58+
hi.requireClientCert != other.requireClientCert ||
59+
len(hi.sanMatchers) != len(other.sanMatchers) {
60+
return false
61+
}
62+
for i := range hi.sanMatchers {
63+
if !hi.sanMatchers[i].Equal(other.sanMatchers[i]) {
64+
return false
65+
}
66+
}
67+
return true
68+
5269
}
5370

5471
// SetHandshakeInfo returns a copy of addr in which the Attributes field is

internal/stubserver/stubserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func parseCfg(r *manual.Resolver, s string) *serviceconfig.ParseResult {
216216
// StartTestService spins up a stub server exposing the TestService on a local
217217
// port. If the passed in server is nil, a stub server that implements only the
218218
// EmptyCall and UnaryCall RPCs is started.
219-
func StartTestService(t *testing.T, server *StubServer) *StubServer {
219+
func StartTestService(t *testing.T, server *StubServer, sopts ...grpc.ServerOption) *StubServer {
220220
if server == nil {
221221
server = &StubServer{
222222
EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { return &testpb.Empty{}, nil },
@@ -225,7 +225,7 @@ func StartTestService(t *testing.T, server *StubServer) *StubServer {
225225
},
226226
}
227227
}
228-
server.StartServer()
228+
server.StartServer(sopts...)
229229

230230
t.Logf("Started test service backend at %q", server.Address)
231231
return server

0 commit comments

Comments
 (0)