Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "grpc-httpjson-transcoding",
project_desc = "Library that supports transcoding so that HTTP/JSON can be converted to gRPC",
project_url = "https://github.com/grpc-ecosystem/grpc-httpjson-transcoding",
version = "4d095f048889d4fc3b8d4579aa80ca4290319802",
sha256 = "7af66e0674340932683ab4f04ea6f03e2550849a54741738d94310b84d396a2c",
version = "22160afc7e67b9becce3198f8a6a321f01a3cef8",
sha256 = "d761b6442f600b628f5e420b601824757dfdbea6c12ac86cd59dbaa53d20d343",
strip_prefix = "grpc-httpjson-transcoding-{version}",
urls = ["https://github.com/grpc-ecosystem/grpc-httpjson-transcoding/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,42 @@ TEST_F(GrpcJsonTranscoderFilterTest, TranscodingUnaryWithHttpBodyAsOutput) {
EXPECT_EQ(Http::FilterTrailersStatus::Continue, filter_.decodeTrailers(request_trailers));
}


TEST_F(GrpcJsonTranscoderFilterTest, TranscodingUnaryOnRootPath) {
Http::TestRequestHeaderMapImpl request_headers{{":method", "GET"}, {":path", "/"}};

EXPECT_CALL(decoder_callbacks_, clearRouteCache());

EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_.decodeHeaders(request_headers, false));
EXPECT_EQ("application/grpc", request_headers.get_("content-type"));
EXPECT_EQ("/", request_headers.get_("x-envoy-original-path"));
EXPECT_EQ("GET", request_headers.get_("x-envoy-original-method"));
EXPECT_EQ("/bookstore.Bookstore/GetRoot", request_headers.get_(":path"));
EXPECT_EQ("trailers", request_headers.get_("te"));

Http::TestResponseHeaderMapImpl response_headers{{"content-type", "application/grpc"},
{":status", "200"}};

EXPECT_EQ(Http::FilterHeadersStatus::StopIteration,
filter_.encodeHeaders(response_headers, false));
EXPECT_EQ("application/json", response_headers.get_("content-type"));

google::api::HttpBody response;
response.set_content_type("text/html");
response.set_data("<h1>Hello, world!</h1>");

auto response_data = Grpc::Common::serializeToGrpcFrame(response);

EXPECT_EQ(Http::FilterDataStatus::StopIterationAndBuffer,
filter_.encodeData(*response_data, false));

EXPECT_EQ(response.content_type(), response_headers.get_("content-type"));
EXPECT_EQ(response.data(), response_data->toString());

Http::TestRequestTrailerMapImpl request_trailers;
EXPECT_EQ(Http::FilterTrailersStatus::Continue, filter_.decodeTrailers(request_trailers));
}

TEST_F(GrpcJsonTranscoderFilterTest, TranscodingUnaryWithInvalidHttpBodyAsOutput) {
Http::TestRequestHeaderMapImpl request_headers{{":method", "GET"},
{":path", "/echoResponseBodyPath"}};
Expand Down
5 changes: 5 additions & 0 deletions test/proto/bookstore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ service Bookstore {
get: "/indexStream"
};
}
rpc GetRoot(google.protobuf.Empty) returns (google.api.HttpBody) {
option (google.api.http) = {
get: "/"
};
}
rpc PostBody(EchoBodyRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/postBody"
Expand Down