@@ -34,7 +34,11 @@ import (
3434 "google.golang.org/grpc/internal/channelz"
3535 "google.golang.org/grpc/internal/grpctest"
3636 "google.golang.org/protobuf/encoding/prototext"
37+ "google.golang.org/protobuf/reflect/protodesc"
38+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
3739 "google.golang.org/protobuf/testing/protocmp"
40+ "google.golang.org/protobuf/types/descriptorpb"
41+ "google.golang.org/protobuf/types/dynamicpb"
3842 "google.golang.org/protobuf/types/known/anypb"
3943 "google.golang.org/protobuf/types/known/timestamppb"
4044
@@ -546,6 +550,47 @@ func newSocket(cs czSocket) *channelz.Socket {
546550 return s
547551}
548552
553+ type OtherChannelzSecurityValue struct {
554+ LocalCertificate []byte `protobuf:"bytes,1,opt,name=local_certificate,json=localCertificate,proto3" json:"local_certificate,omitempty"`
555+ RemoteCertificate []byte `protobuf:"bytes,2,opt,name=remote_certificate,json=remoteCertificate,proto3" json:"remote_certificate,omitempty"`
556+ }
557+
558+ func (x * OtherChannelzSecurityValue ) Reset () {
559+ * x = OtherChannelzSecurityValue {}
560+ }
561+
562+ func (x * OtherChannelzSecurityValue ) String () string {
563+ return prototext .Format (x )
564+ }
565+
566+ func (* OtherChannelzSecurityValue ) ProtoMessage () {}
567+
568+ func (x OtherChannelzSecurityValue ) ProtoReflect () protoreflect.Message {
569+ const s = `
570+ name: "service_test.proto"
571+ syntax: "proto3"
572+ package: "grpc.credentials",
573+ message_type: [{
574+ name: "OtherChannelzSecurityValue"
575+ field: [
576+ {name:"local_certificate" number:1 type:TYPE_BYTES},
577+ {name:"remote_certificate" number:2 type:TYPE_BYTES}
578+ ]
579+ }]
580+ `
581+ pb := new (descriptorpb.FileDescriptorProto )
582+ if err := prototext .Unmarshal ([]byte (s ), pb ); err != nil {
583+ panic (err )
584+ }
585+ fd , err := protodesc .NewFile (pb , nil )
586+ if err != nil {
587+ panic (err )
588+ }
589+ md := fd .Messages ().Get (0 )
590+ mt := dynamicpb .NewMessageType (md )
591+ return mt .New ()
592+ }
593+
549594func (s ) TestGetSocket (t * testing.T ) {
550595 ss := []* channelz.Socket {newSocket (czSocket {
551596 streamsStarted : 10 ,
@@ -609,7 +654,7 @@ func (s) TestGetSocket(t *testing.T) {
609654 }), newSocket (czSocket {
610655 security : & credentials.OtherChannelzSecurityValue {
611656 Name : "YYYY" ,
612- Value : & OtherChannelzSecurityValue {
657+ Value : OtherChannelzSecurityValue {
613658 LocalCertificate : []byte {1 , 2 , 3 },
614659 RemoteCertificate : []byte {4 , 5 , 6 },
615660 },
0 commit comments