diff --git a/desc_source_test.go b/desc_source_test.go index cd58357..a9c9a8c 100644 --- a/desc_source_test.go +++ b/desc_source_test.go @@ -10,11 +10,11 @@ import ( ) func TestWriteProtoset(t *testing.T) { - exampleProtoset, err := loadProtoset("./testing/example.protoset") + exampleProtoset, err := loadProtoset("./internal/testing/example.protoset") if err != nil { t.Fatalf("failed to load example.protoset: %v", err) } - testProtoset, err := loadProtoset("./testing/test.protoset") + testProtoset, err := loadProtoset("./internal/testing/test.protoset") if err != nil { t.Fatalf("failed to load test.protoset: %v", err) } @@ -29,8 +29,8 @@ func TestWriteProtoset(t *testing.T) { } checkWriteProtoset(t, descSrc, exampleProtoset, "TestService") - checkWriteProtoset(t, descSrc, testProtoset, "grpc.testing.TestService") - checkWriteProtoset(t, descSrc, mergedProtoset, "TestService", "grpc.testing.TestService") + checkWriteProtoset(t, descSrc, testProtoset, "testing.TestService") + checkWriteProtoset(t, descSrc, mergedProtoset, "TestService", "testing.TestService") } func loadProtoset(path string) (*descriptor.FileDescriptorSet, error) { diff --git a/format_test.go b/format_test.go index 1a36059..d7c509d 100644 --- a/format_test.go +++ b/format_test.go @@ -15,7 +15,7 @@ import ( ) func TestRequestParser(t *testing.T) { - source, err := DescriptorSourceFromProtoSets("testing/example.protoset") + source, err := DescriptorSourceFromProtoSets("internal/testing/example.protoset") if err != nil { t.Fatalf("failed to create descriptor source: %v", err) } @@ -97,7 +97,7 @@ func TestRequestParser(t *testing.T) { // Handler prints response data (and headers/trailers in verbose mode). // This verifies that we get the right output in both JSON and proto text modes. func TestHandler(t *testing.T) { - source, err := DescriptorSourceFromProtoSets("testing/example.protoset") + source, err := DescriptorSourceFromProtoSets("internal/testing/example.protoset") if err != nil { t.Fatalf("failed to create descriptor source: %v", err) } diff --git a/grpcurl_test.go b/grpcurl_test.go index ff2f46e..dabde2d 100644 --- a/grpcurl_test.go +++ b/grpcurl_test.go @@ -18,15 +18,14 @@ import ( "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" - "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/reflection" reflectpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" "google.golang.org/grpc/status" . "github.com/fullstorydev/grpcurl" - grpcurl_testing "github.com/fullstorydev/grpcurl/testing" - jsonpbtest "github.com/fullstorydev/grpcurl/testing/jsonpb_test_proto" + grpcurl_testing "github.com/fullstorydev/grpcurl/internal/testing" + jsonpbtest "github.com/fullstorydev/grpcurl/internal/testing/jsonpb_test_proto" ) var ( @@ -52,18 +51,18 @@ type descSourceCase struct { func TestMain(m *testing.M) { var err error - sourceProtoset, err = DescriptorSourceFromProtoSets("testing/test.protoset") + sourceProtoset, err = DescriptorSourceFromProtoSets("internal/testing/test.protoset") if err != nil { panic(err) } - sourceProtoFiles, err = DescriptorSourceFromProtoFiles(nil, "testing/test.proto") + sourceProtoFiles, err = DescriptorSourceFromProtoFiles([]string{"internal/testing"}, "test.proto") if err != nil { panic(err) } // Create a server that includes the reflection service svrReflect := grpc.NewServer() - grpc_testing.RegisterTestServiceServer(svrReflect, grpcurl_testing.TestServer{}) + grpcurl_testing.RegisterTestServiceServer(svrReflect, grpcurl_testing.TestServer{}) reflection.Register(svrReflect) var portReflect int if l, err := net.Listen("tcp", "127.0.0.1:0"); err != nil { @@ -89,7 +88,7 @@ func TestMain(m *testing.M) { // Also create a server that does *not* include the reflection service svrProtoset := grpc.NewServer() - grpc_testing.RegisterTestServiceServer(svrProtoset, grpcurl_testing.TestServer{}) + grpcurl_testing.RegisterTestServiceServer(svrProtoset, grpcurl_testing.TestServer{}) var portProtoset int if l, err := net.Listen("tcp", "127.0.0.1:0"); err != nil { panic(err) @@ -141,7 +140,7 @@ func TestServerDoesNotSupportReflection(t *testing.T) { } func TestProtosetWithImports(t *testing.T) { - sourceProtoset, err := DescriptorSourceFromProtoSets("testing/example.protoset") + sourceProtoset, err := DescriptorSourceFromProtoSets("internal/testing/example.protoset") if err != nil { t.Fatalf("failed to load protoset: %v", err) } @@ -178,11 +177,11 @@ func doTestListServices(t *testing.T, source DescriptorSource, includeReflection var expected []string if includeReflection { // when using server reflection, we see the TestService as well as the ServerReflection service - expected = []string{"grpc.reflection.v1alpha.ServerReflection", "grpc.testing.TestService"} + expected = []string{"grpc.reflection.v1alpha.ServerReflection", "testing.TestService"} } else { // without reflection, we see all services defined in the same test.proto file, which is the // TestService as well as UnimplementedService - expected = []string{"grpc.testing.TestService", "grpc.testing.UnimplementedService"} + expected = []string{"testing.TestService", "testing.UnimplementedService"} } if !reflect.DeepEqual(expected, names) { t.Errorf("ListServices returned wrong results: wanted %v, got %v", expected, names) @@ -198,17 +197,17 @@ func TestListMethods(t *testing.T) { } func doTestListMethods(t *testing.T, source DescriptorSource, includeReflection bool) { - names, err := ListMethods(source, "grpc.testing.TestService") + names, err := ListMethods(source, "testing.TestService") if err != nil { t.Fatalf("failed to list methods for TestService: %v", err) } expected := []string{ - "grpc.testing.TestService.EmptyCall", - "grpc.testing.TestService.FullDuplexCall", - "grpc.testing.TestService.HalfDuplexCall", - "grpc.testing.TestService.StreamingInputCall", - "grpc.testing.TestService.StreamingOutputCall", - "grpc.testing.TestService.UnaryCall", + "testing.TestService.EmptyCall", + "testing.TestService.FullDuplexCall", + "testing.TestService.HalfDuplexCall", + "testing.TestService.StreamingInputCall", + "testing.TestService.StreamingOutputCall", + "testing.TestService.UnaryCall", } if !reflect.DeepEqual(expected, names) { t.Errorf("ListMethods returned wrong results: wanted %v, got %v", expected, names) @@ -224,11 +223,11 @@ func doTestListMethods(t *testing.T, source DescriptorSource, includeReflection } else { // without reflection, we see all services defined in the same test.proto file, which is the // TestService as well as UnimplementedService - names, err = ListMethods(source, "grpc.testing.UnimplementedService") + names, err = ListMethods(source, "testing.UnimplementedService") if err != nil { t.Fatalf("failed to list methods for ServerReflection: %v", err) } - expected = []string{"grpc.testing.UnimplementedService.UnimplementedCall"} + expected = []string{"testing.UnimplementedService.UnimplementedCall"} } if !reflect.DeepEqual(expected, names) { t.Errorf("ListMethods returned wrong results: wanted %v, got %v", expected, names) @@ -242,13 +241,13 @@ func doTestListMethods(t *testing.T, source DescriptorSource, includeReflection } func TestGetAllFiles(t *testing.T) { - expectedFiles := []string{"testing/test.proto"} + expectedFiles := []string{"test.proto"} // server reflection picks up filename from linked in Go package, // which indicates "grpc_testing/test.proto", not our local copy. expectedFilesWithReflection := [][]string{ - {"grpc_reflection_v1alpha/reflection.proto", "grpc_testing/test.proto"}, + {"grpc_reflection_v1alpha/reflection.proto", "test.proto"}, // depending on the version of grpc, the filenames could be prefixed with "interop/" and "reflection/" - {"interop/grpc_testing/test.proto", "reflection/grpc_reflection_v1alpha/reflection.proto"}, + {"reflection/grpc_reflection_v1alpha/reflection.proto", "test.proto"}, } for _, ds := range descSources { @@ -279,11 +278,11 @@ func TestGetAllFiles(t *testing.T) { } // try cases with more complicated set of files - otherSourceProtoset, err := DescriptorSourceFromProtoSets("testing/test.protoset", "testing/example.protoset") + otherSourceProtoset, err := DescriptorSourceFromProtoSets("internal/testing/test.protoset", "internal/testing/example.protoset") if err != nil { t.Fatal(err.Error()) } - otherSourceProtoFiles, err := DescriptorSourceFromProtoFiles(nil, "testing/test.proto", "testing/example.proto") + otherSourceProtoFiles, err := DescriptorSourceFromProtoFiles([]string{"internal/testing"}, "test.proto", "example.proto") if err != nil { t.Fatal(err.Error()) } @@ -292,13 +291,13 @@ func TestGetAllFiles(t *testing.T) { {"proto[b]", otherSourceProtoFiles, false}, } expectedFiles = []string{ + "example.proto", + "example2.proto", "google/protobuf/any.proto", "google/protobuf/descriptor.proto", "google/protobuf/empty.proto", "google/protobuf/timestamp.proto", - "testing/example.proto", - "testing/example2.proto", - "testing/test.proto", + "test.proto", } for _, ds := range otherDescSources { t.Run(ds.name, func(t *testing.T) { @@ -403,7 +402,7 @@ func TestDescribe(t *testing.T) { } func doTestDescribe(t *testing.T, source DescriptorSource) { - sym := "grpc.testing.TestService.EmptyCall" + sym := "testing.TestService.EmptyCall" dsc, err := source.FindSymbol(sym) if err != nil { t.Fatalf("failed to get descriptor for %q: %v", sym, err) @@ -414,14 +413,14 @@ func doTestDescribe(t *testing.T, source DescriptorSource) { txt := proto.MarshalTextString(dsc.AsProto()) expected := `name: "EmptyCall" -input_type: ".grpc.testing.Empty" -output_type: ".grpc.testing.Empty" +input_type: ".testing.Empty" +output_type: ".testing.Empty" ` if expected != txt { t.Errorf("descriptor mismatch: expected %s, got %s", expected, txt) } - sym = "grpc.testing.StreamingOutputCallResponse" + sym = "testing.StreamingOutputCallResponse" dsc, err = source.FindSymbol(sym) if err != nil { t.Fatalf("failed to get descriptor for %q: %v", sym, err) @@ -437,7 +436,7 @@ field: < number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE - type_name: ".grpc.testing.Payload" + type_name: ".testing.Payload" json_name: "payload" > ` @@ -493,12 +492,12 @@ func TestUnary(t *testing.T) { func doTestUnary(t *testing.T, cc *grpc.ClientConn, source DescriptorSource) { // Success h := &handler{reqMessages: []string{payload1}} - err := InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/UnaryCall", makeHeaders(codes.OK), h, h.getRequestData) + err := InvokeRpc(context.Background(), source, cc, "testing.TestService/UnaryCall", makeHeaders(codes.OK), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - if h.check(t, "grpc.testing.TestService.UnaryCall", codes.OK, 1, 1) { + if h.check(t, "testing.TestService.UnaryCall", codes.OK, 1, 1) { if h.respMessages[0] != payload1 { t.Errorf("unexpected response from RPC: expecting %s; got %s", payload1, h.respMessages[0]) } @@ -506,12 +505,12 @@ func doTestUnary(t *testing.T, cc *grpc.ClientConn, source DescriptorSource) { // Failure h = &handler{reqMessages: []string{payload1}} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/UnaryCall", makeHeaders(codes.NotFound), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/UnaryCall", makeHeaders(codes.NotFound), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.UnaryCall", codes.NotFound, 1, 0) + h.check(t, "testing.TestService.UnaryCall", codes.NotFound, 1, 0) } func TestClientStream(t *testing.T) { @@ -525,12 +524,12 @@ func TestClientStream(t *testing.T) { func doTestClientStream(t *testing.T, cc *grpc.ClientConn, source DescriptorSource) { // Success h := &handler{reqMessages: []string{payload1, payload2, payload3}} - err := InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/StreamingInputCall", makeHeaders(codes.OK), h, h.getRequestData) + err := InvokeRpc(context.Background(), source, cc, "testing.TestService/StreamingInputCall", makeHeaders(codes.OK), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - if h.check(t, "grpc.testing.TestService.StreamingInputCall", codes.OK, 3, 1) { + if h.check(t, "testing.TestService.StreamingInputCall", codes.OK, 3, 1) { expected := `{ "aggregatedPayloadSize": 61 @@ -542,21 +541,21 @@ func doTestClientStream(t *testing.T, cc *grpc.ClientConn, source DescriptorSour // Fail fast (server rejects as soon as possible) h = &handler{reqMessages: []string{payload1, payload2, payload3}} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/StreamingInputCall", makeHeaders(codes.InvalidArgument), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/StreamingInputCall", makeHeaders(codes.InvalidArgument), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.StreamingInputCall", codes.InvalidArgument, -3, 0) + h.check(t, "testing.TestService.StreamingInputCall", codes.InvalidArgument, -3, 0) // Fail late (server waits until stream is complete to reject) h = &handler{reqMessages: []string{payload1, payload2, payload3}} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/StreamingInputCall", makeHeaders(codes.Internal, true), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/StreamingInputCall", makeHeaders(codes.Internal, true), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.StreamingInputCall", codes.Internal, 3, 0) + h.check(t, "testing.TestService.StreamingInputCall", codes.Internal, 3, 0) } func TestServerStream(t *testing.T) { @@ -568,9 +567,9 @@ func TestServerStream(t *testing.T) { } func doTestServerStream(t *testing.T, cc *grpc.ClientConn, source DescriptorSource) { - req := &grpc_testing.StreamingOutputCallRequest{ - ResponseType: grpc_testing.PayloadType_COMPRESSABLE, - ResponseParameters: []*grpc_testing.ResponseParameters{ + req := &grpcurl_testing.StreamingOutputCallRequest{ + ResponseType: grpcurl_testing.PayloadType_COMPRESSABLE, + ResponseParameters: []*grpcurl_testing.ResponseParameters{ {Size: 10}, {Size: 20}, {Size: 30}, {Size: 40}, {Size: 50}, }, } @@ -581,19 +580,19 @@ func doTestServerStream(t *testing.T, cc *grpc.ClientConn, source DescriptorSour // Success h := &handler{reqMessages: []string{payload}} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/StreamingOutputCall", makeHeaders(codes.OK), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/StreamingOutputCall", makeHeaders(codes.OK), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - if h.check(t, "grpc.testing.TestService.StreamingOutputCall", codes.OK, 1, 5) { - resp := &grpc_testing.StreamingOutputCallResponse{} + if h.check(t, "testing.TestService.StreamingOutputCall", codes.OK, 1, 5) { + resp := &grpcurl_testing.StreamingOutputCallResponse{} for i, msg := range h.respMessages { if err := jsonpb.UnmarshalString(msg, resp); err != nil { t.Errorf("failed to parse response %d: %v", i+1, err) } - if resp.Payload.GetType() != grpc_testing.PayloadType_COMPRESSABLE { - t.Errorf("response %d has wrong payload type; expecting %v, got %v", i, grpc_testing.PayloadType_COMPRESSABLE, resp.Payload.Type) + if resp.Payload.GetType() != grpcurl_testing.PayloadType_COMPRESSABLE { + t.Errorf("response %d has wrong payload type; expecting %v, got %v", i, grpcurl_testing.PayloadType_COMPRESSABLE, resp.Payload.Type) } if len(resp.Payload.Body) != (i+1)*10 { t.Errorf("response %d has wrong payload size; expecting %d, got %d", i, (i+1)*10, len(resp.Payload.Body)) @@ -604,21 +603,21 @@ func doTestServerStream(t *testing.T, cc *grpc.ClientConn, source DescriptorSour // Fail fast (server rejects as soon as possible) h = &handler{reqMessages: []string{payload}} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/StreamingOutputCall", makeHeaders(codes.Aborted), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/StreamingOutputCall", makeHeaders(codes.Aborted), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.StreamingOutputCall", codes.Aborted, 1, 0) + h.check(t, "testing.TestService.StreamingOutputCall", codes.Aborted, 1, 0) // Fail late (server waits until stream is complete to reject) h = &handler{reqMessages: []string{payload}} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/StreamingOutputCall", makeHeaders(codes.AlreadyExists, true), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/StreamingOutputCall", makeHeaders(codes.AlreadyExists, true), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.StreamingOutputCall", codes.AlreadyExists, 1, 5) + h.check(t, "testing.TestService.StreamingOutputCall", codes.AlreadyExists, 1, 5) } func TestHalfDuplexStream(t *testing.T) { @@ -634,12 +633,12 @@ func doTestHalfDuplexStream(t *testing.T, cc *grpc.ClientConn, source Descriptor // Success h := &handler{reqMessages: reqs} - err := InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/HalfDuplexCall", makeHeaders(codes.OK), h, h.getRequestData) + err := InvokeRpc(context.Background(), source, cc, "testing.TestService/HalfDuplexCall", makeHeaders(codes.OK), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - if h.check(t, "grpc.testing.TestService.HalfDuplexCall", codes.OK, 3, 3) { + if h.check(t, "testing.TestService.HalfDuplexCall", codes.OK, 3, 3) { for i, resp := range h.respMessages { if resp != reqs[i] { t.Errorf("unexpected response %d from RPC:\nexpecting %q\ngot %q", i, reqs[i], resp) @@ -649,21 +648,21 @@ func doTestHalfDuplexStream(t *testing.T, cc *grpc.ClientConn, source Descriptor // Fail fast (server rejects as soon as possible) h = &handler{reqMessages: reqs} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/HalfDuplexCall", makeHeaders(codes.Canceled), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/HalfDuplexCall", makeHeaders(codes.Canceled), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.HalfDuplexCall", codes.Canceled, -3, 0) + h.check(t, "testing.TestService.HalfDuplexCall", codes.Canceled, -3, 0) // Fail late (server waits until stream is complete to reject) h = &handler{reqMessages: reqs} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/HalfDuplexCall", makeHeaders(codes.DataLoss, true), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/HalfDuplexCall", makeHeaders(codes.DataLoss, true), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.HalfDuplexCall", codes.DataLoss, 3, 3) + h.check(t, "testing.TestService.HalfDuplexCall", codes.DataLoss, 3, 3) } func TestFullDuplexStream(t *testing.T) { @@ -676,11 +675,11 @@ func TestFullDuplexStream(t *testing.T) { func doTestFullDuplexStream(t *testing.T, cc *grpc.ClientConn, source DescriptorSource) { reqs := make([]string, 3) - req := &grpc_testing.StreamingOutputCallRequest{ - ResponseType: grpc_testing.PayloadType_RANDOM, + req := &grpcurl_testing.StreamingOutputCallRequest{ + ResponseType: grpcurl_testing.PayloadType_RANDOM, } for i := range reqs { - req.ResponseParameters = append(req.ResponseParameters, &grpc_testing.ResponseParameters{Size: int32((i + 1) * 10)}) + req.ResponseParameters = append(req.ResponseParameters, &grpcurl_testing.ResponseParameters{Size: int32((i + 1) * 10)}) payload, err := (&jsonpb.Marshaler{}).MarshalToString(req) if err != nil { t.Fatalf("failed to construct request %d: %v", i, err) @@ -690,13 +689,13 @@ func doTestFullDuplexStream(t *testing.T, cc *grpc.ClientConn, source Descriptor // Success h := &handler{reqMessages: reqs} - err := InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/FullDuplexCall", makeHeaders(codes.OK), h, h.getRequestData) + err := InvokeRpc(context.Background(), source, cc, "testing.TestService/FullDuplexCall", makeHeaders(codes.OK), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - if h.check(t, "grpc.testing.TestService.FullDuplexCall", codes.OK, 3, 6) { - resp := &grpc_testing.StreamingOutputCallResponse{} + if h.check(t, "testing.TestService.FullDuplexCall", codes.OK, 3, 6) { + resp := &grpcurl_testing.StreamingOutputCallResponse{} i := 0 for j := 1; j < 3; j++ { // three requests @@ -706,8 +705,8 @@ func doTestFullDuplexStream(t *testing.T, cc *grpc.ClientConn, source Descriptor if err := jsonpb.UnmarshalString(msg, resp); err != nil { t.Errorf("failed to parse response %d: %v", i+1, err) } - if resp.Payload.GetType() != grpc_testing.PayloadType_RANDOM { - t.Errorf("response %d has wrong payload type; expecting %v, got %v", i, grpc_testing.PayloadType_RANDOM, resp.Payload.Type) + if resp.Payload.GetType() != grpcurl_testing.PayloadType_RANDOM { + t.Errorf("response %d has wrong payload type; expecting %v, got %v", i, grpcurl_testing.PayloadType_RANDOM, resp.Payload.Type) } if len(resp.Payload.Body) != (k+1)*10 { t.Errorf("response %d has wrong payload size; expecting %d, got %d", i, (k+1)*10, len(resp.Payload.Body)) @@ -721,21 +720,21 @@ func doTestFullDuplexStream(t *testing.T, cc *grpc.ClientConn, source Descriptor // Fail fast (server rejects as soon as possible) h = &handler{reqMessages: reqs} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/FullDuplexCall", makeHeaders(codes.PermissionDenied), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/FullDuplexCall", makeHeaders(codes.PermissionDenied), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.FullDuplexCall", codes.PermissionDenied, -3, 0) + h.check(t, "testing.TestService.FullDuplexCall", codes.PermissionDenied, -3, 0) // Fail late (server waits until stream is complete to reject) h = &handler{reqMessages: reqs} - err = InvokeRpc(context.Background(), source, cc, "grpc.testing.TestService/FullDuplexCall", makeHeaders(codes.ResourceExhausted, true), h, h.getRequestData) + err = InvokeRpc(context.Background(), source, cc, "testing.TestService/FullDuplexCall", makeHeaders(codes.ResourceExhausted, true), h, h.getRequestData) if err != nil { t.Fatalf("unexpected error during RPC: %v", err) } - h.check(t, "grpc.testing.TestService.FullDuplexCall", codes.ResourceExhausted, 3, 6) + h.check(t, "testing.TestService.FullDuplexCall", codes.ResourceExhausted, 3, 6) } type handler struct { diff --git a/testing/cmd/bankdemo/README.md b/internal/testing/cmd/bankdemo/README.md similarity index 100% rename from testing/cmd/bankdemo/README.md rename to internal/testing/cmd/bankdemo/README.md diff --git a/testing/cmd/bankdemo/auth.go b/internal/testing/cmd/bankdemo/auth.go similarity index 100% rename from testing/cmd/bankdemo/auth.go rename to internal/testing/cmd/bankdemo/auth.go diff --git a/testing/cmd/bankdemo/bank.go b/internal/testing/cmd/bankdemo/bank.go similarity index 100% rename from testing/cmd/bankdemo/bank.go rename to internal/testing/cmd/bankdemo/bank.go diff --git a/testing/cmd/bankdemo/bank.pb.go b/internal/testing/cmd/bankdemo/bank.pb.go similarity index 100% rename from testing/cmd/bankdemo/bank.pb.go rename to internal/testing/cmd/bankdemo/bank.pb.go diff --git a/testing/cmd/bankdemo/bank.proto b/internal/testing/cmd/bankdemo/bank.proto similarity index 100% rename from testing/cmd/bankdemo/bank.proto rename to internal/testing/cmd/bankdemo/bank.proto diff --git a/testing/cmd/bankdemo/chat.go b/internal/testing/cmd/bankdemo/chat.go similarity index 100% rename from testing/cmd/bankdemo/chat.go rename to internal/testing/cmd/bankdemo/chat.go diff --git a/testing/cmd/bankdemo/db.go b/internal/testing/cmd/bankdemo/db.go similarity index 100% rename from testing/cmd/bankdemo/db.go rename to internal/testing/cmd/bankdemo/db.go diff --git a/testing/cmd/bankdemo/main.go b/internal/testing/cmd/bankdemo/main.go similarity index 100% rename from testing/cmd/bankdemo/main.go rename to internal/testing/cmd/bankdemo/main.go diff --git a/testing/cmd/bankdemo/support.pb.go b/internal/testing/cmd/bankdemo/support.pb.go similarity index 100% rename from testing/cmd/bankdemo/support.pb.go rename to internal/testing/cmd/bankdemo/support.pb.go diff --git a/testing/cmd/bankdemo/support.proto b/internal/testing/cmd/bankdemo/support.proto similarity index 100% rename from testing/cmd/bankdemo/support.proto rename to internal/testing/cmd/bankdemo/support.proto diff --git a/testing/cmd/testserver/README.md b/internal/testing/cmd/testserver/README.md similarity index 100% rename from testing/cmd/testserver/README.md rename to internal/testing/cmd/testserver/README.md diff --git a/testing/cmd/testserver/testserver.go b/internal/testing/cmd/testserver/testserver.go similarity index 96% rename from testing/cmd/testserver/testserver.go rename to internal/testing/cmd/testserver/testserver.go index ea4b66a..e42821f 100644 --- a/testing/cmd/testserver/testserver.go +++ b/internal/testing/cmd/testserver/testserver.go @@ -13,13 +13,12 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/reflection" "google.golang.org/grpc/status" "github.com/fullstorydev/grpcurl" - grpcurl_testing "github.com/fullstorydev/grpcurl/testing" + grpcurl_testing "github.com/fullstorydev/grpcurl/internal/testing" ) var ( @@ -96,7 +95,7 @@ func main() { svr := grpc.NewServer(opts...) - grpc_testing.RegisterTestServiceServer(svr, grpcurl_testing.TestServer{}) + grpcurl_testing.RegisterTestServiceServer(svr, grpcurl_testing.TestServer{}) if !*noreflect { reflection.Register(svr) } diff --git a/testing/cmd/testserver/unix.go b/internal/testing/cmd/testserver/unix.go similarity index 100% rename from testing/cmd/testserver/unix.go rename to internal/testing/cmd/testserver/unix.go diff --git a/testing/example.proto b/internal/testing/example.proto similarity index 93% rename from testing/example.proto rename to internal/testing/example.proto index bfb3f3f..e054bda 100644 --- a/testing/example.proto +++ b/internal/testing/example.proto @@ -3,7 +3,7 @@ syntax = "proto3"; import "google/protobuf/descriptor.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; -import "testing/example2.proto"; +import "example2.proto"; message TestRequest { repeated string file_names = 1; diff --git a/testing/example.protoset b/internal/testing/example.protoset similarity index 95% rename from testing/example.protoset rename to internal/testing/example.protoset index cad3361..a6b1329 100644 Binary files a/testing/example.protoset and b/internal/testing/example.protoset differ diff --git a/testing/example2.proto b/internal/testing/example2.proto similarity index 100% rename from testing/example2.proto rename to internal/testing/example2.proto diff --git a/testing/jsonpb_test_proto/test_objects.pb.go b/internal/testing/jsonpb_test_proto/test_objects.pb.go similarity index 100% rename from testing/jsonpb_test_proto/test_objects.pb.go rename to internal/testing/jsonpb_test_proto/test_objects.pb.go diff --git a/testing/jsonpb_test_proto/test_objects.proto b/internal/testing/jsonpb_test_proto/test_objects.proto similarity index 100% rename from testing/jsonpb_test_proto/test_objects.proto rename to internal/testing/jsonpb_test_proto/test_objects.proto diff --git a/internal/testing/test.pb.go b/internal/testing/test.pb.go new file mode 100644 index 0000000..3c70e08 --- /dev/null +++ b/internal/testing/test.pb.go @@ -0,0 +1,1132 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: test.proto + +package testing + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// The type of payload that should be returned. +type PayloadType int32 + +const ( + // Compressable text format. + PayloadType_COMPRESSABLE PayloadType = 0 + // Uncompressable binary format. + PayloadType_UNCOMPRESSABLE PayloadType = 1 + // Randomly chosen from all other formats defined in this enum. + PayloadType_RANDOM PayloadType = 2 +) + +var PayloadType_name = map[int32]string{ + 0: "COMPRESSABLE", + 1: "UNCOMPRESSABLE", + 2: "RANDOM", +} + +var PayloadType_value = map[string]int32{ + "COMPRESSABLE": 0, + "UNCOMPRESSABLE": 1, + "RANDOM": 2, +} + +func (x PayloadType) String() string { + return proto.EnumName(PayloadType_name, int32(x)) +} + +func (PayloadType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{0} +} + +type Empty struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Empty) Reset() { *m = Empty{} } +func (m *Empty) String() string { return proto.CompactTextString(m) } +func (*Empty) ProtoMessage() {} +func (*Empty) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{0} +} + +func (m *Empty) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Empty.Unmarshal(m, b) +} +func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Empty.Marshal(b, m, deterministic) +} +func (m *Empty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Empty.Merge(m, src) +} +func (m *Empty) XXX_Size() int { + return xxx_messageInfo_Empty.Size(m) +} +func (m *Empty) XXX_DiscardUnknown() { + xxx_messageInfo_Empty.DiscardUnknown(m) +} + +var xxx_messageInfo_Empty proto.InternalMessageInfo + +// A block of data, to simply increase gRPC message size. +type Payload struct { + // The type of data in body. + Type PayloadType `protobuf:"varint,1,opt,name=type,proto3,enum=testing.PayloadType" json:"type,omitempty"` + // Primary contents of payload. + Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Payload) Reset() { *m = Payload{} } +func (m *Payload) String() string { return proto.CompactTextString(m) } +func (*Payload) ProtoMessage() {} +func (*Payload) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{1} +} + +func (m *Payload) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Payload.Unmarshal(m, b) +} +func (m *Payload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Payload.Marshal(b, m, deterministic) +} +func (m *Payload) XXX_Merge(src proto.Message) { + xxx_messageInfo_Payload.Merge(m, src) +} +func (m *Payload) XXX_Size() int { + return xxx_messageInfo_Payload.Size(m) +} +func (m *Payload) XXX_DiscardUnknown() { + xxx_messageInfo_Payload.DiscardUnknown(m) +} + +var xxx_messageInfo_Payload proto.InternalMessageInfo + +func (m *Payload) GetType() PayloadType { + if m != nil { + return m.Type + } + return PayloadType_COMPRESSABLE +} + +func (m *Payload) GetBody() []byte { + if m != nil { + return m.Body + } + return nil +} + +// A protobuf representation for grpc status. This is used by test +// clients to specify a status that the server should attempt to return. +type EchoStatus struct { + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EchoStatus) Reset() { *m = EchoStatus{} } +func (m *EchoStatus) String() string { return proto.CompactTextString(m) } +func (*EchoStatus) ProtoMessage() {} +func (*EchoStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{2} +} + +func (m *EchoStatus) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EchoStatus.Unmarshal(m, b) +} +func (m *EchoStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EchoStatus.Marshal(b, m, deterministic) +} +func (m *EchoStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_EchoStatus.Merge(m, src) +} +func (m *EchoStatus) XXX_Size() int { + return xxx_messageInfo_EchoStatus.Size(m) +} +func (m *EchoStatus) XXX_DiscardUnknown() { + xxx_messageInfo_EchoStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_EchoStatus proto.InternalMessageInfo + +func (m *EchoStatus) GetCode() int32 { + if m != nil { + return m.Code + } + return 0 +} + +func (m *EchoStatus) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +// Unary request. +type SimpleRequest struct { + // Desired payload type in the response from the server. + // If response_type is RANDOM, server randomly chooses one from other formats. + ResponseType PayloadType `protobuf:"varint,1,opt,name=response_type,json=responseType,proto3,enum=testing.PayloadType" json:"response_type,omitempty"` + // Desired payload size in the response from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + ResponseSize int32 `protobuf:"varint,2,opt,name=response_size,json=responseSize,proto3" json:"response_size,omitempty"` + // Optional input payload sent along with the request. + Payload *Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` + // Whether SimpleResponse should include username. + FillUsername bool `protobuf:"varint,4,opt,name=fill_username,json=fillUsername,proto3" json:"fill_username,omitempty"` + // Whether SimpleResponse should include OAuth scope. + FillOauthScope bool `protobuf:"varint,5,opt,name=fill_oauth_scope,json=fillOauthScope,proto3" json:"fill_oauth_scope,omitempty"` + // Whether server should return a given status + ResponseStatus *EchoStatus `protobuf:"bytes,7,opt,name=response_status,json=responseStatus,proto3" json:"response_status,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SimpleRequest) Reset() { *m = SimpleRequest{} } +func (m *SimpleRequest) String() string { return proto.CompactTextString(m) } +func (*SimpleRequest) ProtoMessage() {} +func (*SimpleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{3} +} + +func (m *SimpleRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SimpleRequest.Unmarshal(m, b) +} +func (m *SimpleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SimpleRequest.Marshal(b, m, deterministic) +} +func (m *SimpleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SimpleRequest.Merge(m, src) +} +func (m *SimpleRequest) XXX_Size() int { + return xxx_messageInfo_SimpleRequest.Size(m) +} +func (m *SimpleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SimpleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SimpleRequest proto.InternalMessageInfo + +func (m *SimpleRequest) GetResponseType() PayloadType { + if m != nil { + return m.ResponseType + } + return PayloadType_COMPRESSABLE +} + +func (m *SimpleRequest) GetResponseSize() int32 { + if m != nil { + return m.ResponseSize + } + return 0 +} + +func (m *SimpleRequest) GetPayload() *Payload { + if m != nil { + return m.Payload + } + return nil +} + +func (m *SimpleRequest) GetFillUsername() bool { + if m != nil { + return m.FillUsername + } + return false +} + +func (m *SimpleRequest) GetFillOauthScope() bool { + if m != nil { + return m.FillOauthScope + } + return false +} + +func (m *SimpleRequest) GetResponseStatus() *EchoStatus { + if m != nil { + return m.ResponseStatus + } + return nil +} + +// Unary response, as configured by the request. +type SimpleResponse struct { + // Payload to increase message size. + Payload *Payload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + // The user the request came from, for verifying authentication was + // successful when the client expected it. + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + // OAuth scope. + OauthScope string `protobuf:"bytes,3,opt,name=oauth_scope,json=oauthScope,proto3" json:"oauth_scope,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SimpleResponse) Reset() { *m = SimpleResponse{} } +func (m *SimpleResponse) String() string { return proto.CompactTextString(m) } +func (*SimpleResponse) ProtoMessage() {} +func (*SimpleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{4} +} + +func (m *SimpleResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SimpleResponse.Unmarshal(m, b) +} +func (m *SimpleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SimpleResponse.Marshal(b, m, deterministic) +} +func (m *SimpleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SimpleResponse.Merge(m, src) +} +func (m *SimpleResponse) XXX_Size() int { + return xxx_messageInfo_SimpleResponse.Size(m) +} +func (m *SimpleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SimpleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SimpleResponse proto.InternalMessageInfo + +func (m *SimpleResponse) GetPayload() *Payload { + if m != nil { + return m.Payload + } + return nil +} + +func (m *SimpleResponse) GetUsername() string { + if m != nil { + return m.Username + } + return "" +} + +func (m *SimpleResponse) GetOauthScope() string { + if m != nil { + return m.OauthScope + } + return "" +} + +// Client-streaming request. +type StreamingInputCallRequest struct { + // Optional input payload sent along with the request. + Payload *Payload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StreamingInputCallRequest) Reset() { *m = StreamingInputCallRequest{} } +func (m *StreamingInputCallRequest) String() string { return proto.CompactTextString(m) } +func (*StreamingInputCallRequest) ProtoMessage() {} +func (*StreamingInputCallRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{5} +} + +func (m *StreamingInputCallRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StreamingInputCallRequest.Unmarshal(m, b) +} +func (m *StreamingInputCallRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StreamingInputCallRequest.Marshal(b, m, deterministic) +} +func (m *StreamingInputCallRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StreamingInputCallRequest.Merge(m, src) +} +func (m *StreamingInputCallRequest) XXX_Size() int { + return xxx_messageInfo_StreamingInputCallRequest.Size(m) +} +func (m *StreamingInputCallRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StreamingInputCallRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StreamingInputCallRequest proto.InternalMessageInfo + +func (m *StreamingInputCallRequest) GetPayload() *Payload { + if m != nil { + return m.Payload + } + return nil +} + +// Client-streaming response. +type StreamingInputCallResponse struct { + // Aggregated size of payloads received from the client. + AggregatedPayloadSize int32 `protobuf:"varint,1,opt,name=aggregated_payload_size,json=aggregatedPayloadSize,proto3" json:"aggregated_payload_size,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StreamingInputCallResponse) Reset() { *m = StreamingInputCallResponse{} } +func (m *StreamingInputCallResponse) String() string { return proto.CompactTextString(m) } +func (*StreamingInputCallResponse) ProtoMessage() {} +func (*StreamingInputCallResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{6} +} + +func (m *StreamingInputCallResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StreamingInputCallResponse.Unmarshal(m, b) +} +func (m *StreamingInputCallResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StreamingInputCallResponse.Marshal(b, m, deterministic) +} +func (m *StreamingInputCallResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StreamingInputCallResponse.Merge(m, src) +} +func (m *StreamingInputCallResponse) XXX_Size() int { + return xxx_messageInfo_StreamingInputCallResponse.Size(m) +} +func (m *StreamingInputCallResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StreamingInputCallResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StreamingInputCallResponse proto.InternalMessageInfo + +func (m *StreamingInputCallResponse) GetAggregatedPayloadSize() int32 { + if m != nil { + return m.AggregatedPayloadSize + } + return 0 +} + +// Configuration for a particular response. +type ResponseParameters struct { + // Desired payload sizes in responses from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + Size int32 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` + // Desired interval between consecutive responses in the response stream in + // microseconds. + IntervalUs int32 `protobuf:"varint,2,opt,name=interval_us,json=intervalUs,proto3" json:"interval_us,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ResponseParameters) Reset() { *m = ResponseParameters{} } +func (m *ResponseParameters) String() string { return proto.CompactTextString(m) } +func (*ResponseParameters) ProtoMessage() {} +func (*ResponseParameters) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{7} +} + +func (m *ResponseParameters) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ResponseParameters.Unmarshal(m, b) +} +func (m *ResponseParameters) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ResponseParameters.Marshal(b, m, deterministic) +} +func (m *ResponseParameters) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResponseParameters.Merge(m, src) +} +func (m *ResponseParameters) XXX_Size() int { + return xxx_messageInfo_ResponseParameters.Size(m) +} +func (m *ResponseParameters) XXX_DiscardUnknown() { + xxx_messageInfo_ResponseParameters.DiscardUnknown(m) +} + +var xxx_messageInfo_ResponseParameters proto.InternalMessageInfo + +func (m *ResponseParameters) GetSize() int32 { + if m != nil { + return m.Size + } + return 0 +} + +func (m *ResponseParameters) GetIntervalUs() int32 { + if m != nil { + return m.IntervalUs + } + return 0 +} + +// Server-streaming request. +type StreamingOutputCallRequest struct { + // Desired payload type in the response from the server. + // If response_type is RANDOM, the payload from each response in the stream + // might be of different types. This is to simulate a mixed type of payload + // stream. + ResponseType PayloadType `protobuf:"varint,1,opt,name=response_type,json=responseType,proto3,enum=testing.PayloadType" json:"response_type,omitempty"` + // Configuration for each expected response message. + ResponseParameters []*ResponseParameters `protobuf:"bytes,2,rep,name=response_parameters,json=responseParameters,proto3" json:"response_parameters,omitempty"` + // Optional input payload sent along with the request. + Payload *Payload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` + // Whether server should return a given status + ResponseStatus *EchoStatus `protobuf:"bytes,7,opt,name=response_status,json=responseStatus,proto3" json:"response_status,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StreamingOutputCallRequest) Reset() { *m = StreamingOutputCallRequest{} } +func (m *StreamingOutputCallRequest) String() string { return proto.CompactTextString(m) } +func (*StreamingOutputCallRequest) ProtoMessage() {} +func (*StreamingOutputCallRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{8} +} + +func (m *StreamingOutputCallRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StreamingOutputCallRequest.Unmarshal(m, b) +} +func (m *StreamingOutputCallRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StreamingOutputCallRequest.Marshal(b, m, deterministic) +} +func (m *StreamingOutputCallRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StreamingOutputCallRequest.Merge(m, src) +} +func (m *StreamingOutputCallRequest) XXX_Size() int { + return xxx_messageInfo_StreamingOutputCallRequest.Size(m) +} +func (m *StreamingOutputCallRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StreamingOutputCallRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StreamingOutputCallRequest proto.InternalMessageInfo + +func (m *StreamingOutputCallRequest) GetResponseType() PayloadType { + if m != nil { + return m.ResponseType + } + return PayloadType_COMPRESSABLE +} + +func (m *StreamingOutputCallRequest) GetResponseParameters() []*ResponseParameters { + if m != nil { + return m.ResponseParameters + } + return nil +} + +func (m *StreamingOutputCallRequest) GetPayload() *Payload { + if m != nil { + return m.Payload + } + return nil +} + +func (m *StreamingOutputCallRequest) GetResponseStatus() *EchoStatus { + if m != nil { + return m.ResponseStatus + } + return nil +} + +// Server-streaming response, as configured by the request and parameters. +type StreamingOutputCallResponse struct { + // Payload to increase response size. + Payload *Payload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StreamingOutputCallResponse) Reset() { *m = StreamingOutputCallResponse{} } +func (m *StreamingOutputCallResponse) String() string { return proto.CompactTextString(m) } +func (*StreamingOutputCallResponse) ProtoMessage() {} +func (*StreamingOutputCallResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{9} +} + +func (m *StreamingOutputCallResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StreamingOutputCallResponse.Unmarshal(m, b) +} +func (m *StreamingOutputCallResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StreamingOutputCallResponse.Marshal(b, m, deterministic) +} +func (m *StreamingOutputCallResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StreamingOutputCallResponse.Merge(m, src) +} +func (m *StreamingOutputCallResponse) XXX_Size() int { + return xxx_messageInfo_StreamingOutputCallResponse.Size(m) +} +func (m *StreamingOutputCallResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StreamingOutputCallResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StreamingOutputCallResponse proto.InternalMessageInfo + +func (m *StreamingOutputCallResponse) GetPayload() *Payload { + if m != nil { + return m.Payload + } + return nil +} + +func init() { + proto.RegisterEnum("testing.PayloadType", PayloadType_name, PayloadType_value) + proto.RegisterType((*Empty)(nil), "testing.Empty") + proto.RegisterType((*Payload)(nil), "testing.Payload") + proto.RegisterType((*EchoStatus)(nil), "testing.EchoStatus") + proto.RegisterType((*SimpleRequest)(nil), "testing.SimpleRequest") + proto.RegisterType((*SimpleResponse)(nil), "testing.SimpleResponse") + proto.RegisterType((*StreamingInputCallRequest)(nil), "testing.StreamingInputCallRequest") + proto.RegisterType((*StreamingInputCallResponse)(nil), "testing.StreamingInputCallResponse") + proto.RegisterType((*ResponseParameters)(nil), "testing.ResponseParameters") + proto.RegisterType((*StreamingOutputCallRequest)(nil), "testing.StreamingOutputCallRequest") + proto.RegisterType((*StreamingOutputCallResponse)(nil), "testing.StreamingOutputCallResponse") +} + +func init() { + proto.RegisterFile("test.proto", fileDescriptor_c161fcfdc0c3ff1e) +} + +var fileDescriptor_c161fcfdc0c3ff1e = []byte{ + // 646 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x5d, 0x4f, 0x13, 0x51, + 0x10, 0x75, 0x5b, 0x4a, 0x61, 0x5a, 0xd6, 0x3a, 0xa0, 0xac, 0xe5, 0xc1, 0x66, 0xf1, 0x61, 0x83, + 0x09, 0x31, 0x25, 0x31, 0xd1, 0x90, 0x18, 0x84, 0x8a, 0x44, 0xa0, 0x64, 0x97, 0x3e, 0x37, 0x97, + 0x76, 0x28, 0x9b, 0xec, 0x97, 0xbb, 0x77, 0x89, 0xe5, 0x4f, 0xf8, 0x37, 0xfc, 0x97, 0x9a, 0x7b, + 0xf7, 0xa3, 0x4b, 0x8b, 0x60, 0x83, 0xbe, 0xdd, 0x7b, 0xee, 0x99, 0x99, 0x73, 0x66, 0xa6, 0x5b, + 0x00, 0x4e, 0x11, 0xdf, 0x0e, 0x42, 0x9f, 0xfb, 0x58, 0x15, 0x67, 0xdb, 0x1b, 0xe9, 0x55, 0xa8, + 0x74, 0xdc, 0x80, 0x8f, 0xf5, 0x43, 0xa8, 0x9e, 0xb1, 0xb1, 0xe3, 0xb3, 0x21, 0x1a, 0xb0, 0xc0, + 0xc7, 0x01, 0x69, 0x4a, 0x4b, 0x31, 0xd4, 0xf6, 0xda, 0x76, 0xca, 0xdd, 0x4e, 0xdf, 0xcf, 0xc7, + 0x01, 0x99, 0x92, 0x81, 0x08, 0x0b, 0x17, 0xfe, 0x70, 0xac, 0x95, 0x5a, 0x8a, 0x51, 0x37, 0xe5, + 0x59, 0xff, 0x00, 0xd0, 0x19, 0x5c, 0xf9, 0x16, 0x67, 0x3c, 0x8e, 0x04, 0x63, 0xe0, 0x0f, 0x93, + 0x5c, 0x15, 0x53, 0x9e, 0x51, 0x83, 0xaa, 0x4b, 0x51, 0xc4, 0x46, 0x24, 0x03, 0x97, 0xcd, 0xec, + 0xaa, 0xff, 0x2c, 0xc1, 0x8a, 0x65, 0xbb, 0x81, 0x43, 0x26, 0x7d, 0x8b, 0x29, 0xe2, 0xf8, 0x1e, + 0x56, 0x42, 0x8a, 0x02, 0xdf, 0x8b, 0xa8, 0xff, 0xa0, 0xa8, 0x7a, 0x46, 0x15, 0x37, 0xdc, 0x2c, + 0x84, 0x46, 0xf6, 0x4d, 0x52, 0xac, 0x32, 0x21, 0x59, 0xf6, 0x0d, 0xe1, 0x16, 0x54, 0x83, 0x24, + 0x83, 0x56, 0x6e, 0x29, 0x46, 0xad, 0xdd, 0x98, 0xce, 0x6c, 0x66, 0x04, 0x91, 0xf0, 0xd2, 0x76, + 0x9c, 0x7e, 0x1c, 0x51, 0xe8, 0x31, 0x97, 0xb4, 0x85, 0x96, 0x62, 0x2c, 0x99, 0x75, 0x01, 0xf6, + 0x52, 0x0c, 0x0d, 0x68, 0x48, 0x92, 0xcf, 0x62, 0x7e, 0xd5, 0x8f, 0x06, 0x7e, 0x40, 0x5a, 0x45, + 0xf2, 0x54, 0x81, 0x77, 0x05, 0x6c, 0x09, 0x14, 0x77, 0xe1, 0xe9, 0x44, 0x9f, 0xec, 0x96, 0x56, + 0x95, 0x12, 0x56, 0x73, 0x09, 0x93, 0x46, 0x9a, 0x6a, 0x2e, 0x5b, 0xde, 0xf5, 0x31, 0xa8, 0x59, + 0xa7, 0x12, 0xbc, 0x68, 0x45, 0x79, 0xc8, 0x4a, 0x13, 0x96, 0x72, 0x17, 0xc9, 0x0c, 0xf2, 0x3b, + 0xbe, 0x82, 0x5a, 0x51, 0x7c, 0x59, 0x3e, 0x83, 0x9f, 0x0b, 0xd7, 0x0f, 0xe1, 0xa5, 0xc5, 0x43, + 0x62, 0xae, 0xed, 0x8d, 0x8e, 0xbc, 0x20, 0xe6, 0xfb, 0xcc, 0x71, 0xb2, 0x81, 0xcd, 0xa1, 0x42, + 0x3f, 0x87, 0xe6, 0x5d, 0x89, 0x52, 0x3f, 0xef, 0x60, 0x9d, 0x8d, 0x46, 0x21, 0x8d, 0x18, 0xa7, + 0x61, 0x3f, 0x8d, 0x49, 0x26, 0x99, 0x6c, 0xd3, 0xf3, 0xc9, 0x73, 0x9a, 0x5a, 0x8c, 0x54, 0x3f, + 0x02, 0xcc, 0x72, 0x9c, 0xb1, 0x90, 0xb9, 0xc4, 0x29, 0x94, 0x8b, 0x58, 0x08, 0x95, 0x67, 0xe1, + 0xd4, 0xf6, 0x38, 0x85, 0xd7, 0x4c, 0x0c, 0x35, 0xdd, 0x0f, 0xc8, 0xa0, 0x5e, 0xa4, 0xff, 0x28, + 0x15, 0x14, 0x76, 0x63, 0x3e, 0xe5, 0xf5, 0x11, 0xcb, 0x79, 0x0c, 0xab, 0x79, 0x68, 0x90, 0xab, + 0xd4, 0x4a, 0xad, 0xb2, 0x51, 0x6b, 0x6f, 0xe4, 0x09, 0x66, 0x8d, 0x98, 0x18, 0xce, 0x9a, 0x9b, + 0x67, 0x8b, 0x1f, 0xb7, 0x76, 0x47, 0xb0, 0x71, 0x67, 0x43, 0xe6, 0xdf, 0xc1, 0xad, 0x8f, 0x50, + 0x2b, 0xf4, 0x07, 0x1b, 0x50, 0xdf, 0xef, 0x9e, 0x9c, 0x99, 0x1d, 0xcb, 0xda, 0xfb, 0x74, 0xdc, + 0x69, 0x3c, 0x41, 0x04, 0xb5, 0x77, 0x7a, 0x0b, 0x53, 0x10, 0x60, 0xd1, 0xdc, 0x3b, 0x3d, 0xe8, + 0x9e, 0x34, 0x4a, 0xed, 0x5f, 0x65, 0xa8, 0x9d, 0x53, 0xc4, 0x2d, 0x0a, 0xaf, 0xed, 0x01, 0xe1, + 0x1b, 0x58, 0x96, 0xdf, 0x32, 0xa1, 0x08, 0xd5, 0x89, 0x1b, 0x81, 0x35, 0xa7, 0xee, 0xb8, 0x0b, + 0xcb, 0x3d, 0x8f, 0x85, 0x09, 0xf9, 0x45, 0xfe, 0x78, 0xeb, 0xeb, 0xd3, 0x5c, 0x9f, 0xc1, 0x53, + 0x9f, 0x17, 0xb0, 0x7a, 0x47, 0x1b, 0x70, 0x73, 0xc2, 0xff, 0xe3, 0xd6, 0x34, 0x5f, 0xdf, 0x4f, + 0x4a, 0x2a, 0xbc, 0x55, 0xb0, 0x0f, 0x38, 0xfb, 0xeb, 0x40, 0x7d, 0x36, 0x7a, 0xfa, 0x37, 0xd8, + 0xdc, 0xbc, 0x97, 0x93, 0x14, 0x30, 0x44, 0x01, 0xf5, 0x73, 0xec, 0x38, 0x07, 0x71, 0xe0, 0xd0, + 0xf7, 0x7f, 0xac, 0xdf, 0x50, 0xa4, 0x03, 0xf5, 0x0b, 0x73, 0x2e, 0xff, 0x5b, 0x81, 0xf6, 0x57, + 0x58, 0xeb, 0x79, 0x72, 0x32, 0x2e, 0x79, 0x9c, 0x86, 0xd9, 0x26, 0xec, 0xc0, 0xb3, 0x5b, 0xf8, + 0xdf, 0x6c, 0xc4, 0xc5, 0xa2, 0xfc, 0x6b, 0xdc, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xca, 0x17, + 0x8b, 0xfe, 0x28, 0x07, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// TestServiceClient is the client API for TestService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type TestServiceClient interface { + // One empty request followed by one empty response. + EmptyCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) + // One request followed by one response. + // The server returns the client payload as-is. + UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error) + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + StreamingOutputCall(ctx context.Context, in *StreamingOutputCallRequest, opts ...grpc.CallOption) (TestService_StreamingOutputCallClient, error) + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + StreamingInputCall(ctx context.Context, opts ...grpc.CallOption) (TestService_StreamingInputCallClient, error) + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + FullDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_FullDuplexCallClient, error) + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + HalfDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_HalfDuplexCallClient, error) +} + +type testServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient { + return &testServiceClient{cc} +} + +func (c *testServiceClient) EmptyCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { + out := new(Empty) + err := c.cc.Invoke(ctx, "/testing.TestService/EmptyCall", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testServiceClient) UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error) { + out := new(SimpleResponse) + err := c.cc.Invoke(ctx, "/testing.TestService/UnaryCall", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testServiceClient) StreamingOutputCall(ctx context.Context, in *StreamingOutputCallRequest, opts ...grpc.CallOption) (TestService_StreamingOutputCallClient, error) { + stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[0], "/testing.TestService/StreamingOutputCall", opts...) + if err != nil { + return nil, err + } + x := &testServiceStreamingOutputCallClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type TestService_StreamingOutputCallClient interface { + Recv() (*StreamingOutputCallResponse, error) + grpc.ClientStream +} + +type testServiceStreamingOutputCallClient struct { + grpc.ClientStream +} + +func (x *testServiceStreamingOutputCallClient) Recv() (*StreamingOutputCallResponse, error) { + m := new(StreamingOutputCallResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *testServiceClient) StreamingInputCall(ctx context.Context, opts ...grpc.CallOption) (TestService_StreamingInputCallClient, error) { + stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[1], "/testing.TestService/StreamingInputCall", opts...) + if err != nil { + return nil, err + } + x := &testServiceStreamingInputCallClient{stream} + return x, nil +} + +type TestService_StreamingInputCallClient interface { + Send(*StreamingInputCallRequest) error + CloseAndRecv() (*StreamingInputCallResponse, error) + grpc.ClientStream +} + +type testServiceStreamingInputCallClient struct { + grpc.ClientStream +} + +func (x *testServiceStreamingInputCallClient) Send(m *StreamingInputCallRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testServiceStreamingInputCallClient) CloseAndRecv() (*StreamingInputCallResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(StreamingInputCallResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *testServiceClient) FullDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_FullDuplexCallClient, error) { + stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[2], "/testing.TestService/FullDuplexCall", opts...) + if err != nil { + return nil, err + } + x := &testServiceFullDuplexCallClient{stream} + return x, nil +} + +type TestService_FullDuplexCallClient interface { + Send(*StreamingOutputCallRequest) error + Recv() (*StreamingOutputCallResponse, error) + grpc.ClientStream +} + +type testServiceFullDuplexCallClient struct { + grpc.ClientStream +} + +func (x *testServiceFullDuplexCallClient) Send(m *StreamingOutputCallRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testServiceFullDuplexCallClient) Recv() (*StreamingOutputCallResponse, error) { + m := new(StreamingOutputCallResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *testServiceClient) HalfDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_HalfDuplexCallClient, error) { + stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[3], "/testing.TestService/HalfDuplexCall", opts...) + if err != nil { + return nil, err + } + x := &testServiceHalfDuplexCallClient{stream} + return x, nil +} + +type TestService_HalfDuplexCallClient interface { + Send(*StreamingOutputCallRequest) error + Recv() (*StreamingOutputCallResponse, error) + grpc.ClientStream +} + +type testServiceHalfDuplexCallClient struct { + grpc.ClientStream +} + +func (x *testServiceHalfDuplexCallClient) Send(m *StreamingOutputCallRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testServiceHalfDuplexCallClient) Recv() (*StreamingOutputCallResponse, error) { + m := new(StreamingOutputCallResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TestServiceServer is the server API for TestService service. +type TestServiceServer interface { + // One empty request followed by one empty response. + EmptyCall(context.Context, *Empty) (*Empty, error) + // One request followed by one response. + // The server returns the client payload as-is. + UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error) + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + StreamingOutputCall(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + StreamingInputCall(TestService_StreamingInputCallServer) error + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + FullDuplexCall(TestService_FullDuplexCallServer) error + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + HalfDuplexCall(TestService_HalfDuplexCallServer) error +} + +// UnimplementedTestServiceServer can be embedded to have forward compatible implementations. +type UnimplementedTestServiceServer struct { +} + +func (*UnimplementedTestServiceServer) EmptyCall(ctx context.Context, req *Empty) (*Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method EmptyCall not implemented") +} +func (*UnimplementedTestServiceServer) UnaryCall(ctx context.Context, req *SimpleRequest) (*SimpleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented") +} +func (*UnimplementedTestServiceServer) StreamingOutputCall(req *StreamingOutputCallRequest, srv TestService_StreamingOutputCallServer) error { + return status.Errorf(codes.Unimplemented, "method StreamingOutputCall not implemented") +} +func (*UnimplementedTestServiceServer) StreamingInputCall(srv TestService_StreamingInputCallServer) error { + return status.Errorf(codes.Unimplemented, "method StreamingInputCall not implemented") +} +func (*UnimplementedTestServiceServer) FullDuplexCall(srv TestService_FullDuplexCallServer) error { + return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented") +} +func (*UnimplementedTestServiceServer) HalfDuplexCall(srv TestService_HalfDuplexCallServer) error { + return status.Errorf(codes.Unimplemented, "method HalfDuplexCall not implemented") +} + +func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) { + s.RegisterService(&_TestService_serviceDesc, srv) +} + +func _TestService_EmptyCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServiceServer).EmptyCall(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testing.TestService/EmptyCall", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServiceServer).EmptyCall(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _TestService_UnaryCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SimpleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServiceServer).UnaryCall(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testing.TestService/UnaryCall", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServiceServer).UnaryCall(ctx, req.(*SimpleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TestService_StreamingOutputCall_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(StreamingOutputCallRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TestServiceServer).StreamingOutputCall(m, &testServiceStreamingOutputCallServer{stream}) +} + +type TestService_StreamingOutputCallServer interface { + Send(*StreamingOutputCallResponse) error + grpc.ServerStream +} + +type testServiceStreamingOutputCallServer struct { + grpc.ServerStream +} + +func (x *testServiceStreamingOutputCallServer) Send(m *StreamingOutputCallResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _TestService_StreamingInputCall_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TestServiceServer).StreamingInputCall(&testServiceStreamingInputCallServer{stream}) +} + +type TestService_StreamingInputCallServer interface { + SendAndClose(*StreamingInputCallResponse) error + Recv() (*StreamingInputCallRequest, error) + grpc.ServerStream +} + +type testServiceStreamingInputCallServer struct { + grpc.ServerStream +} + +func (x *testServiceStreamingInputCallServer) SendAndClose(m *StreamingInputCallResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testServiceStreamingInputCallServer) Recv() (*StreamingInputCallRequest, error) { + m := new(StreamingInputCallRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _TestService_FullDuplexCall_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TestServiceServer).FullDuplexCall(&testServiceFullDuplexCallServer{stream}) +} + +type TestService_FullDuplexCallServer interface { + Send(*StreamingOutputCallResponse) error + Recv() (*StreamingOutputCallRequest, error) + grpc.ServerStream +} + +type testServiceFullDuplexCallServer struct { + grpc.ServerStream +} + +func (x *testServiceFullDuplexCallServer) Send(m *StreamingOutputCallResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testServiceFullDuplexCallServer) Recv() (*StreamingOutputCallRequest, error) { + m := new(StreamingOutputCallRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _TestService_HalfDuplexCall_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TestServiceServer).HalfDuplexCall(&testServiceHalfDuplexCallServer{stream}) +} + +type TestService_HalfDuplexCallServer interface { + Send(*StreamingOutputCallResponse) error + Recv() (*StreamingOutputCallRequest, error) + grpc.ServerStream +} + +type testServiceHalfDuplexCallServer struct { + grpc.ServerStream +} + +func (x *testServiceHalfDuplexCallServer) Send(m *StreamingOutputCallResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testServiceHalfDuplexCallServer) Recv() (*StreamingOutputCallRequest, error) { + m := new(StreamingOutputCallRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _TestService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "testing.TestService", + HandlerType: (*TestServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "EmptyCall", + Handler: _TestService_EmptyCall_Handler, + }, + { + MethodName: "UnaryCall", + Handler: _TestService_UnaryCall_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamingOutputCall", + Handler: _TestService_StreamingOutputCall_Handler, + ServerStreams: true, + }, + { + StreamName: "StreamingInputCall", + Handler: _TestService_StreamingInputCall_Handler, + ClientStreams: true, + }, + { + StreamName: "FullDuplexCall", + Handler: _TestService_FullDuplexCall_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "HalfDuplexCall", + Handler: _TestService_HalfDuplexCall_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "test.proto", +} + +// UnimplementedServiceClient is the client API for UnimplementedService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type UnimplementedServiceClient interface { + // A call that no server should implement + UnimplementedCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) +} + +type unimplementedServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUnimplementedServiceClient(cc grpc.ClientConnInterface) UnimplementedServiceClient { + return &unimplementedServiceClient{cc} +} + +func (c *unimplementedServiceClient) UnimplementedCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { + out := new(Empty) + err := c.cc.Invoke(ctx, "/testing.UnimplementedService/UnimplementedCall", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UnimplementedServiceServer is the server API for UnimplementedService service. +type UnimplementedServiceServer interface { + // A call that no server should implement + UnimplementedCall(context.Context, *Empty) (*Empty, error) +} + +// UnimplementedUnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedUnimplementedServiceServer struct { +} + +func (*UnimplementedUnimplementedServiceServer) UnimplementedCall(ctx context.Context, req *Empty) (*Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnimplementedCall not implemented") +} + +func RegisterUnimplementedServiceServer(s *grpc.Server, srv UnimplementedServiceServer) { + s.RegisterService(&_UnimplementedService_serviceDesc, srv) +} + +func _UnimplementedService_UnimplementedCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UnimplementedServiceServer).UnimplementedCall(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testing.UnimplementedService/UnimplementedCall", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UnimplementedServiceServer).UnimplementedCall(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +var _UnimplementedService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "testing.UnimplementedService", + HandlerType: (*UnimplementedServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UnimplementedCall", + Handler: _UnimplementedService_UnimplementedCall_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "test.proto", +} diff --git a/testing/test.proto b/internal/testing/test.proto similarity index 98% rename from testing/test.proto rename to internal/testing/test.proto index 6765e36..3ab9bb1 100644 --- a/testing/test.proto +++ b/internal/testing/test.proto @@ -18,7 +18,7 @@ // of unary/streaming requests/responses. syntax = "proto3"; -package grpc.testing; +package testing; message Empty {} @@ -172,5 +172,5 @@ service TestService { // that case. service UnimplementedService { // A call that no server should implement - rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty); + rpc UnimplementedCall(Empty) returns (Empty); } diff --git a/internal/testing/test.protoset b/internal/testing/test.protoset new file mode 100644 index 0000000..fe75566 Binary files /dev/null and b/internal/testing/test.protoset differ diff --git a/testing/test_server.go b/internal/testing/test_server.go similarity index 84% rename from testing/test_server.go rename to internal/testing/test_server.go index 9c04c13..413f2c5 100644 --- a/testing/test_server.go +++ b/internal/testing/test_server.go @@ -1,5 +1,9 @@ package testing +//go:generate protoc --go_out=plugins=grpc:./ test.proto +//go:generate protoc --descriptor_set_out=./test.protoset test.proto +//go:generate protoc --descriptor_set_out=./example.protoset --include_imports example.proto + import ( "io" "strconv" @@ -8,7 +12,6 @@ import ( "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" - "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" @@ -19,7 +22,7 @@ import ( type TestServer struct{} // EmptyCall accepts one empty request and issues one empty response. -func (TestServer) EmptyCall(ctx context.Context, req *grpc_testing.Empty) (*grpc_testing.Empty, error) { +func (TestServer) EmptyCall(ctx context.Context, req *Empty) (*Empty, error) { headers, trailers, failEarly, failLate := processMetadata(ctx) grpc.SetHeader(ctx, headers) grpc.SetTrailer(ctx, trailers) @@ -35,7 +38,7 @@ func (TestServer) EmptyCall(ctx context.Context, req *grpc_testing.Empty) (*grpc // UnaryCall accepts one request and issues one response. The response includes // the client's payload as-is. -func (TestServer) UnaryCall(ctx context.Context, req *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) { +func (TestServer) UnaryCall(ctx context.Context, req *SimpleRequest) (*SimpleResponse, error) { headers, trailers, failEarly, failLate := processMetadata(ctx) grpc.SetHeader(ctx, headers) grpc.SetTrailer(ctx, trailers) @@ -46,7 +49,7 @@ func (TestServer) UnaryCall(ctx context.Context, req *grpc_testing.SimpleRequest return nil, status.Error(failLate, "fail") } - return &grpc_testing.SimpleResponse{ + return &SimpleResponse{ Payload: req.Payload, }, nil } @@ -54,7 +57,7 @@ func (TestServer) UnaryCall(ctx context.Context, req *grpc_testing.SimpleRequest // StreamingOutputCall accepts one request and issues a sequence of responses // (streamed download). The server returns the payload with client desired type // and sizes as specified in the request's ResponseParameters. -func (TestServer) StreamingOutputCall(req *grpc_testing.StreamingOutputCallRequest, str grpc_testing.TestService_StreamingOutputCallServer) error { +func (TestServer) StreamingOutputCall(req *StreamingOutputCallRequest, str TestService_StreamingOutputCallServer) error { headers, trailers, failEarly, failLate := processMetadata(str.Context()) str.SetHeader(headers) str.SetTrailer(trailers) @@ -62,7 +65,7 @@ func (TestServer) StreamingOutputCall(req *grpc_testing.StreamingOutputCallReque return status.Error(failEarly, "fail") } - rsp := &grpc_testing.StreamingOutputCallResponse{Payload: &grpc_testing.Payload{}} + rsp := &StreamingOutputCallResponse{Payload: &Payload{}} for _, param := range req.ResponseParameters { if str.Context().Err() != nil { return str.Context().Err() @@ -92,7 +95,7 @@ func (TestServer) StreamingOutputCall(req *grpc_testing.StreamingOutputCallReque // StreamingInputCall accepts a sequence of requests and issues one response // (streamed upload). The server returns the aggregated size of client payloads // as the result. -func (TestServer) StreamingInputCall(str grpc_testing.TestService_StreamingInputCallServer) error { +func (TestServer) StreamingInputCall(str TestService_StreamingInputCallServer) error { headers, trailers, failEarly, failLate := processMetadata(str.Context()) str.SetHeader(headers) str.SetTrailer(trailers) @@ -114,7 +117,7 @@ func (TestServer) StreamingInputCall(str grpc_testing.TestService_StreamingInput sz += len(req.Payload.Body) } } - if err := str.SendAndClose(&grpc_testing.StreamingInputCallResponse{AggregatedPayloadSize: int32(sz)}); err != nil { + if err := str.SendAndClose(&StreamingInputCallResponse{AggregatedPayloadSize: int32(sz)}); err != nil { return err } @@ -127,7 +130,7 @@ func (TestServer) StreamingInputCall(str grpc_testing.TestService_StreamingInput // FullDuplexCall accepts a sequence of requests with each request served by the // server immediately. As one request could lead to multiple responses, this // interface demonstrates the idea of full duplexing. -func (TestServer) FullDuplexCall(str grpc_testing.TestService_FullDuplexCallServer) error { +func (TestServer) FullDuplexCall(str TestService_FullDuplexCallServer) error { headers, trailers, failEarly, failLate := processMetadata(str.Context()) str.SetHeader(headers) str.SetTrailer(trailers) @@ -135,7 +138,7 @@ func (TestServer) FullDuplexCall(str grpc_testing.TestService_FullDuplexCallServ return status.Error(failEarly, "fail") } - rsp := &grpc_testing.StreamingOutputCallResponse{Payload: &grpc_testing.Payload{}} + rsp := &StreamingOutputCallResponse{Payload: &Payload{}} for { if str.Context().Err() != nil { return str.Context().Err() @@ -170,7 +173,7 @@ func (TestServer) FullDuplexCall(str grpc_testing.TestService_FullDuplexCallServ // responses. The server buffers all the client requests and then serves them // in order. A stream of responses is returned to the client once the client // half-closes the stream. -func (TestServer) HalfDuplexCall(str grpc_testing.TestService_HalfDuplexCallServer) error { +func (TestServer) HalfDuplexCall(str TestService_HalfDuplexCallServer) error { headers, trailers, failEarly, failLate := processMetadata(str.Context()) str.SetHeader(headers) str.SetTrailer(trailers) @@ -178,7 +181,7 @@ func (TestServer) HalfDuplexCall(str grpc_testing.TestService_HalfDuplexCallServ return status.Error(failEarly, "fail") } - var reqs []*grpc_testing.StreamingOutputCallRequest + var reqs []*StreamingOutputCallRequest for { if str.Context().Err() != nil { return str.Context().Err() @@ -192,7 +195,7 @@ func (TestServer) HalfDuplexCall(str grpc_testing.TestService_HalfDuplexCallServ reqs = append(reqs, req) } } - rsp := &grpc_testing.StreamingOutputCallResponse{} + rsp := &StreamingOutputCallResponse{} for _, req := range reqs { rsp.Payload = req.Payload if err := str.Send(rsp); err != nil { @@ -251,4 +254,4 @@ func toCode(vals []string) codes.Code { return codes.Code(i) } -var _ grpc_testing.TestServiceServer = TestServer{} +var _ TestServiceServer = TestServer{} diff --git a/testing/tls/ca.crl b/internal/testing/tls/ca.crl similarity index 100% rename from testing/tls/ca.crl rename to internal/testing/tls/ca.crl diff --git a/testing/tls/ca.crt b/internal/testing/tls/ca.crt similarity index 100% rename from testing/tls/ca.crt rename to internal/testing/tls/ca.crt diff --git a/testing/tls/ca.key b/internal/testing/tls/ca.key similarity index 100% rename from testing/tls/ca.key rename to internal/testing/tls/ca.key diff --git a/testing/tls/client.crt b/internal/testing/tls/client.crt similarity index 100% rename from testing/tls/client.crt rename to internal/testing/tls/client.crt diff --git a/testing/tls/client.csr b/internal/testing/tls/client.csr similarity index 100% rename from testing/tls/client.csr rename to internal/testing/tls/client.csr diff --git a/testing/tls/client.key b/internal/testing/tls/client.key similarity index 100% rename from testing/tls/client.key rename to internal/testing/tls/client.key diff --git a/testing/tls/expired.crt b/internal/testing/tls/expired.crt similarity index 100% rename from testing/tls/expired.crt rename to internal/testing/tls/expired.crt diff --git a/testing/tls/expired.csr b/internal/testing/tls/expired.csr similarity index 100% rename from testing/tls/expired.csr rename to internal/testing/tls/expired.csr diff --git a/testing/tls/expired.key b/internal/testing/tls/expired.key similarity index 100% rename from testing/tls/expired.key rename to internal/testing/tls/expired.key diff --git a/testing/tls/other.crt b/internal/testing/tls/other.crt similarity index 100% rename from testing/tls/other.crt rename to internal/testing/tls/other.crt diff --git a/testing/tls/other.csr b/internal/testing/tls/other.csr similarity index 100% rename from testing/tls/other.csr rename to internal/testing/tls/other.csr diff --git a/testing/tls/other.key b/internal/testing/tls/other.key similarity index 100% rename from testing/tls/other.key rename to internal/testing/tls/other.key diff --git a/testing/tls/server.crt b/internal/testing/tls/server.crt similarity index 100% rename from testing/tls/server.crt rename to internal/testing/tls/server.crt diff --git a/testing/tls/server.csr b/internal/testing/tls/server.csr similarity index 100% rename from testing/tls/server.csr rename to internal/testing/tls/server.csr diff --git a/testing/tls/server.key b/internal/testing/tls/server.key similarity index 100% rename from testing/tls/server.key rename to internal/testing/tls/server.key diff --git a/testing/tls/wrong-ca.crl b/internal/testing/tls/wrong-ca.crl similarity index 100% rename from testing/tls/wrong-ca.crl rename to internal/testing/tls/wrong-ca.crl diff --git a/testing/tls/wrong-ca.crt b/internal/testing/tls/wrong-ca.crt similarity index 100% rename from testing/tls/wrong-ca.crt rename to internal/testing/tls/wrong-ca.crt diff --git a/testing/tls/wrong-ca.key b/internal/testing/tls/wrong-ca.key similarity index 100% rename from testing/tls/wrong-ca.key rename to internal/testing/tls/wrong-ca.key diff --git a/testing/tls/wrong-client.crt b/internal/testing/tls/wrong-client.crt similarity index 100% rename from testing/tls/wrong-client.crt rename to internal/testing/tls/wrong-client.crt diff --git a/testing/tls/wrong-client.csr b/internal/testing/tls/wrong-client.csr similarity index 100% rename from testing/tls/wrong-client.csr rename to internal/testing/tls/wrong-client.csr diff --git a/testing/tls/wrong-client.key b/internal/testing/tls/wrong-client.key similarity index 100% rename from testing/tls/wrong-client.key rename to internal/testing/tls/wrong-client.key diff --git a/testing/test.protoset b/testing/test.protoset deleted file mode 100644 index 6915f3d..0000000 Binary files a/testing/test.protoset and /dev/null differ diff --git a/tls_settings_test.go b/tls_settings_test.go index 82ecd76..b6d77ad 100644 --- a/tls_settings_test.go +++ b/tls_settings_test.go @@ -10,10 +10,9 @@ import ( "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "google.golang.org/grpc/interop/grpc_testing" . "github.com/fullstorydev/grpcurl" - grpcurl_testing "github.com/fullstorydev/grpcurl/testing" + grpcurl_testing "github.com/fullstorydev/grpcurl/internal/testing" ) func TestPlainText(t *testing.T) { @@ -27,11 +26,11 @@ func TestPlainText(t *testing.T) { } func TestBasicTLS(t *testing.T) { - serverCreds, err := ServerTransportCredentials("", "testing/tls/server.crt", "testing/tls/server.key", false) + serverCreds, err := ServerTransportCredentials("", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "", "") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "", "") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -46,7 +45,7 @@ func TestBasicTLS(t *testing.T) { } func TestInsecureClientTLS(t *testing.T) { - serverCreds, err := ServerTransportCredentials("", "testing/tls/server.crt", "testing/tls/server.key", false) + serverCreds, err := ServerTransportCredentials("", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -65,11 +64,11 @@ func TestInsecureClientTLS(t *testing.T) { } func TestClientCertTLS(t *testing.T) { - serverCreds, err := ServerTransportCredentials("testing/tls/ca.crt", "testing/tls/server.crt", "testing/tls/server.key", false) + serverCreds, err := ServerTransportCredentials("internal/testing/tls/ca.crt", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "testing/tls/client.crt", "testing/tls/client.key") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "internal/testing/tls/client.crt", "internal/testing/tls/client.key") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -84,11 +83,11 @@ func TestClientCertTLS(t *testing.T) { } func TestRequireClientCertTLS(t *testing.T) { - serverCreds, err := ServerTransportCredentials("testing/tls/ca.crt", "testing/tls/server.crt", "testing/tls/server.key", true) + serverCreds, err := ServerTransportCredentials("internal/testing/tls/ca.crt", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", true) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "testing/tls/client.crt", "testing/tls/client.key") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "internal/testing/tls/client.crt", "internal/testing/tls/client.key") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -103,7 +102,7 @@ func TestRequireClientCertTLS(t *testing.T) { } func TestBrokenTLS_ClientPlainText(t *testing.T) { - serverCreds, err := ServerTransportCredentials("", "testing/tls/server.crt", "testing/tls/server.key", false) + serverCreds, err := ServerTransportCredentials("", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -148,8 +147,8 @@ func TestBrokenTLS_ClientPlainText(t *testing.T) { // but request fails because server closes connection upon seeing request // bytes that are not a TLS handshake - cl := grpc_testing.NewTestServiceClient(e.cc) - _, err = cl.UnaryCall(context.Background(), &grpc_testing.SimpleRequest{}) + cl := grpcurl_testing.NewTestServiceClient(e.cc) + _, err = cl.UnaryCall(context.Background(), &grpcurl_testing.SimpleRequest{}) if err == nil { t.Fatal("expecting failure") } @@ -164,7 +163,7 @@ func TestBrokenTLS_ClientPlainText(t *testing.T) { } func TestBrokenTLS_ServerPlainText(t *testing.T) { - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "", "") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "", "") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -180,11 +179,11 @@ func TestBrokenTLS_ServerPlainText(t *testing.T) { } func TestBrokenTLS_ServerUsesWrongCert(t *testing.T) { - serverCreds, err := ServerTransportCredentials("", "testing/tls/other.crt", "testing/tls/other.key", false) + serverCreds, err := ServerTransportCredentials("", "internal/testing/tls/other.crt", "internal/testing/tls/other.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "", "") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "", "") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -200,11 +199,11 @@ func TestBrokenTLS_ServerUsesWrongCert(t *testing.T) { } func TestBrokenTLS_ClientHasExpiredCert(t *testing.T) { - serverCreds, err := ServerTransportCredentials("testing/tls/ca.crt", "testing/tls/server.crt", "testing/tls/server.key", false) + serverCreds, err := ServerTransportCredentials("internal/testing/tls/ca.crt", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "testing/tls/expired.crt", "testing/tls/expired.key") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "internal/testing/tls/expired.crt", "internal/testing/tls/expired.key") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -220,11 +219,11 @@ func TestBrokenTLS_ClientHasExpiredCert(t *testing.T) { } func TestBrokenTLS_ServerHasExpiredCert(t *testing.T) { - serverCreds, err := ServerTransportCredentials("", "testing/tls/expired.crt", "testing/tls/expired.key", false) + serverCreds, err := ServerTransportCredentials("", "internal/testing/tls/expired.crt", "internal/testing/tls/expired.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "", "") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "", "") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -240,11 +239,11 @@ func TestBrokenTLS_ServerHasExpiredCert(t *testing.T) { } func TestBrokenTLS_ClientNotTrusted(t *testing.T) { - serverCreds, err := ServerTransportCredentials("testing/tls/ca.crt", "testing/tls/server.crt", "testing/tls/server.key", true) + serverCreds, err := ServerTransportCredentials("internal/testing/tls/ca.crt", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", true) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "testing/tls/wrong-client.crt", "testing/tls/wrong-client.key") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "internal/testing/tls/wrong-client.crt", "internal/testing/tls/wrong-client.key") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -260,11 +259,11 @@ func TestBrokenTLS_ClientNotTrusted(t *testing.T) { } func TestBrokenTLS_ServerNotTrusted(t *testing.T) { - serverCreds, err := ServerTransportCredentials("", "testing/tls/server.crt", "testing/tls/server.key", false) + serverCreds, err := ServerTransportCredentials("", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", false) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "", "testing/tls/client.crt", "testing/tls/client.key") + clientCreds, err := ClientTransportCredentials(false, "", "internal/testing/tls/client.crt", "internal/testing/tls/client.key") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -280,11 +279,11 @@ func TestBrokenTLS_ServerNotTrusted(t *testing.T) { } func TestBrokenTLS_RequireClientCertButNonePresented(t *testing.T) { - serverCreds, err := ServerTransportCredentials("testing/tls/ca.crt", "testing/tls/server.crt", "testing/tls/server.key", true) + serverCreds, err := ServerTransportCredentials("internal/testing/tls/ca.crt", "internal/testing/tls/server.crt", "internal/testing/tls/server.key", true) if err != nil { t.Fatalf("failed to create server creds: %v", err) } - clientCreds, err := ClientTransportCredentials(false, "testing/tls/ca.crt", "", "") + clientCreds, err := ClientTransportCredentials(false, "internal/testing/tls/ca.crt", "", "") if err != nil { t.Fatalf("failed to create server creds: %v", err) } @@ -300,10 +299,10 @@ func TestBrokenTLS_RequireClientCertButNonePresented(t *testing.T) { } func simpleTest(t *testing.T, cc *grpc.ClientConn) { - cl := grpc_testing.NewTestServiceClient(cc) + cl := grpcurl_testing.NewTestServiceClient(cc) ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() - _, err := cl.UnaryCall(ctx, &grpc_testing.SimpleRequest{}, grpc.WaitForReady(true)) + _, err := cl.UnaryCall(ctx, &grpcurl_testing.SimpleRequest{}, grpc.WaitForReady(true)) if err != nil { t.Errorf("simple RPC failed: %v", err) } @@ -323,7 +322,7 @@ func createTestServerAndClient(serverCreds, clientCreds credentials.TransportCre svrOpts = []grpc.ServerOption{grpc.Creds(serverCreds)} } svr := grpc.NewServer(svrOpts...) - grpc_testing.RegisterTestServiceServer(svr, grpcurl_testing.TestServer{}) + grpcurl_testing.RegisterTestServiceServer(svr, grpcurl_testing.TestServer{}) l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { return e, err