Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand test cases for gRPC-Web Trailers to servers-streaming RPCs #935

Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ relevantCodecs:
- CODEC_PROTO
# These tests verify that a gRPC-Web client can handle trailers in the body with
# no response, trailers-only responses (trailers in headers), and trailers with
# different cases (in addition to the "standard" all lower-case).
# different cases (in addition to the "standard" all lower-case). The tests
# cover unary and servers-streaming RPCs - the two types that are supported in
# web browsers.
testCases:
# Trailers and status are in body (no other response messages)
# Unary: Trailers and status are in body (no other response messages)
- request:
testName: trailers-in-body/expected
testName: unary/trailers-in-body/expected
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
Expand Down Expand Up @@ -38,7 +40,7 @@ testCases:
- name: x-custom-trailer
value: [ "bing" ]
- request:
testName: trailers-in-body/mixed-case
testName: unary/trailers-in-body/mixed-case
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
Expand Down Expand Up @@ -66,7 +68,7 @@ testCases:
- name: x-custom-trailer
value: [ "bing" ]
- request:
testName: trailers-in-body/duplicate-metadata
testName: unary/trailers-in-body/duplicate-metadata
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
Expand Down Expand Up @@ -94,9 +96,9 @@ testCases:
- name: x-custom-trailer
value: [ "bing", "quuz" ]

# Trailers-only responses, where status and trailers are in HTTP headers
# Unary: Trailers-only responses, where status and trailers are in HTTP headers
- request:
testName: trailers-only/expected
testName: unary/trailers-only/expected
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
Expand All @@ -120,7 +122,7 @@ testCases:
- name: x-custom-trailer
value: [ "bing" ]
- request:
testName: trailers-only/duplicate-metadata
testName: unary/trailers-only/duplicate-metadata
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
Expand All @@ -143,3 +145,139 @@ testCases:
responseTrailers:
- name: x-custom-trailer
value: [ "bing", "quuz" ]

# Server-streaming: Trailers and status are in body (no other response messages)
- request:
testName: server-stream/trailers-in-body/expected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For increased clarity of test case names (and more consistency/uniformity), could you rename the existing ones to have a "unary/" prefix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we okay with potentially breaking known-failing lists?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Done in 911c055.

streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
status_code: 200
headers:
- name: content-type
value: [ "application/grpc-web" ]
- name: x-custom-header
value: [ "foo" ]
stream:
items:
- flags: 128
payload:
text: "grpc-status: 9\r\ngrpc-message: error\r\nx-custom-trailer: bing\r\n"
expectedResponse:
responseHeaders:
- name: x-custom-header
value: [ "foo" ]
error:
code: 9
message: error
responseTrailers:
- name: x-custom-trailer
value: [ "bing" ]
- request:
testName: server-stream/trailers-in-body/mixed-case
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
status_code: 200
headers:
- name: content-type
value: [ "application/grpc-web" ]
- name: x-custom-header
value: [ "foo" ]
stream:
items:
- flags: 128
payload:
text: "Grpc-Status: 9\r\ngRPC-Message: error\r\nx-Custom-Trailer: bing\r\n"
expectedResponse:
responseHeaders:
- name: x-custom-header
value: [ "foo" ]
error:
code: 9
message: error
responseTrailers:
- name: x-custom-trailer
value: [ "bing" ]
- request:
testName: server-stream/trailers-in-body/duplicate-metadata
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
status_code: 200
headers:
- name: content-type
value: [ "application/grpc-web" ]
- name: x-custom-header
value: [ "foo", "bar", "baz" ]
stream:
items:
- flags: 128
payload:
text: "grpc-status: 9\r\ngrpc-message: error\r\nx-custom-trailer: bing\r\nx-custom-trailer: quuz\r\n"
expectedResponse:
responseHeaders:
- name: x-custom-header
value: [ "foo", "bar", "baz" ]
error:
code: 9
message: error
responseTrailers:
- name: x-custom-trailer
value: [ "bing", "quuz" ]

# Server-streaming: Trailers-only responses, where status and trailers are in HTTP headers
- request:
testName: server-stream/trailers-only/expected
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
status_code: 200
headers:
- name: content-type
value: [ "application/grpc-web" ]
- name: x-custom-trailer
value: [ "bing" ]
- name: grpc-status
value: [ "9" ]
- name: grpc-message
value: [ "error" ]
expectedResponse:
error:
code: 9
message: error
responseTrailers:
- name: x-custom-trailer
value: [ "bing" ]
- request:
testName: server-stream/trailers-only/duplicate-metadata
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
status_code: 200
headers:
- name: content-type
value: [ "application/grpc-web" ]
- name: x-custom-trailer
value: [ "bing", "quuz" ]
- name: grpc-status
value: [ "9" ]
- name: grpc-message
value: [ "error" ]
expectedResponse:
error:
code: 9
message: error
responseTrailers:
- name: x-custom-trailer
value: [ "bing", "quuz" ]
Loading