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

Reconcile test cases w/ latest spec changes and fixes from latest connect-go #826

Merged
merged 12 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module connectrpc.com/conformance
go 1.20

require (
connectrpc.com/connect v1.15.0
connectrpc.com/connect v1.16.0
github.com/andybalholm/brotli v1.1.0
github.com/bufbuild/protoyaml-go v0.1.8
github.com/golang/snappy v0.0.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-2023110619213
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20231106192134-1baebb0a1518.2/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
connectrpc.com/connect v1.15.0 h1:lFdeCbZrVVDydAqwr4xGV2y+ULn+0Z73s5JBj2LikWo=
connectrpc.com/connect v1.15.0/go.mod h1:bQmjpDY8xItMnttnurVgOkHUBMRT9cpsNi2O4AjKhmA=
connectrpc.com/connect v1.16.0 h1:rdtfQjZ0OyFkWPTegBNcH7cwquGAN1WzyJy80oFNibg=
connectrpc.com/connect v1.16.0/go.mod h1:XpZAduBQUySsb4/KO5JffORVkDI4B6/EYPi7N8xpNZw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
name: HTTP to Connect Code Mapping
name: HTTP to RPC Code Mapping
# If a server returns a non-200 HTTP code for unary requests without an
# explicit Connect error code, the client must synthesize an RPC code
# explicit RPC error code, the client must synthesize an RPC code
# from the HTTP code. These tests cases verify that mapping by forcing
# the server to return a specified HTTP code and then test whether the
# client correctly returns the required RPC code.
#
# TODO: Remove relevant protocols once the Connect code mapping table
# is updated to align with gRPC.
## https://github.com/connectrpc/connectrpc.com/pull/130
mode: TEST_MODE_CLIENT
relevantProtocols:
- PROTOCOL_CONNECT
testCases:
- request:
testName: bad-request
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
responseData: "dGVzdCByZXNwb25zZQ=="
rawResponse:
statusCode: 400
expectedResponse:
error:
code: CODE_INVALID_ARGUMENT
code: CODE_INTERNAL
- request:
testName: unauthorized
streamType: STREAM_TYPE_UNARY
Expand Down Expand Up @@ -57,17 +50,6 @@ testCases:
expectedResponse:
error:
code: CODE_UNIMPLEMENTED
- request:
testName: request-timeout
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 408
expectedResponse:
error:
code: CODE_DEADLINE_EXCEEDED
- request:
testName: conflict
streamType: STREAM_TYPE_UNARY
Expand All @@ -78,7 +60,7 @@ testCases:
statusCode: 409
expectedResponse:
error:
code: CODE_ABORTED
code: CODE_UNKNOWN
- request:
testName: precondition-failed
streamType: STREAM_TYPE_UNARY
Expand All @@ -89,7 +71,7 @@ testCases:
statusCode: 412
expectedResponse:
error:
code: CODE_FAILED_PRECONDITION
code: CODE_UNKNOWN
- request:
testName: payload-too-large
streamType: STREAM_TYPE_UNARY
Expand All @@ -100,20 +82,18 @@ testCases:
statusCode: 413
expectedResponse:
error:
code: CODE_RESOURCE_EXHAUSTED
# TODO - uncomment when conformance is updated to the latest release of connect-go
# that includes this fix
# - request:
# testName: unsupported media type
# streamType: STREAM_TYPE_UNARY
# requestMessages:
# - "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
# responseDefinition:
# rawResponse:
# statusCode: 415
# expectedResponse:
# error:
# code: CODE_INTERNAL
code: CODE_UNKNOWN
- request:
testName: unsupported media type
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 415
expectedResponse:
error:
code: CODE_UNKNOWN
- request:
testName: too-many-requests
streamType: STREAM_TYPE_UNARY
Expand All @@ -135,7 +115,7 @@ testCases:
statusCode: 431
expectedResponse:
error:
code: CODE_RESOURCE_EXHAUSTED
code: CODE_UNKNOWN
- request:
testName: bad-gateway
streamType: STREAM_TYPE_UNARY
Expand Down Expand Up @@ -169,4 +149,14 @@ testCases:
expectedResponse:
error:
code: CODE_UNAVAILABLE

- request:
testName: http-version-not-supported
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 505
expectedResponse:
error:
code: CODE_UNKNOWN
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testCases:
error:
code: CODE_CANCELED
expectedResponse:
httpStatusCode: 408
httpStatusCode: 499
error:
code: CODE_CANCELED
details:
Expand Down Expand Up @@ -71,7 +71,7 @@ testCases:
error:
code: CODE_DEADLINE_EXCEEDED
expectedResponse:
httpStatusCode: 408
httpStatusCode: 504
error:
code: CODE_DEADLINE_EXCEEDED
details:
Expand Down Expand Up @@ -166,7 +166,7 @@ testCases:
error:
code: CODE_FAILED_PRECONDITION
expectedResponse:
httpStatusCode: 412
httpStatusCode: 400
error:
code: CODE_FAILED_PRECONDITION
details:
Expand Down Expand Up @@ -223,7 +223,7 @@ testCases:
error:
code: CODE_UNIMPLEMENTED
expectedResponse:
httpStatusCode: 404
httpStatusCode: 501
error:
code: CODE_UNIMPLEMENTED
details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ testCases:
text: "null"
expectedResponse:
error:
code: CODE_UNKNOWN
code: CODE_UNAUTHENTICATED
- request:
testName: error/null-code
service: connectrpc.conformance.v1.ConformanceService
Expand All @@ -41,7 +41,7 @@ testCases:
{ "code": null, "message": "oops" }
expectedResponse:
error:
code: CODE_UNKNOWN
code: CODE_UNAUTHENTICATED
message: oops
- request:
testName: error/missing-code
Expand All @@ -61,31 +61,28 @@ testCases:
{ "message": "oops" }
expectedResponse:
error:
code: CODE_UNKNOWN
code: CODE_UNAUTHENTICATED
message: oops
- request:
testName: error/unrecognized-code
service: connectrpc.conformance.v1.ConformanceService
method: Unary
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 429
headers:
- name: content-type
value: [ "application/json" ]
unary:
text: |
{ "code": "foobar", "message": "oops" }
expectedResponse:
error:
code: CODE_UNAVAILABLE
message: oops

# # TODO: uncomment this once connect-go can de-serialize the
# # rest of the JSON in the face of an invalid code
# - request:
# testName: error/unrecognized-code
# service: connectrpc.conformance.v1.ConformanceService
# method: Unary
# streamType: STREAM_TYPE_UNARY
# requestMessages:
# - "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
# responseDefinition:
# rawResponse:
# statusCode: 422
# headers:
# - name: content-type
# value: [ "application/json" ]
# unary:
# text: |
# { "code": "foobar", "message": "oops" }
# expectedResponse:
# error:
# code: CODE_UNKNOWN
# message: oops
- request:
testName: error/allow-unrecognized-fields
service: connectrpc.conformance.v1.ConformanceService
Expand Down Expand Up @@ -251,33 +248,31 @@ testCases:
error:
code: CODE_UNKNOWN
message: oops
# # TODO: uncomment this once connect-go can de-serialize the
# # rest of the JSON in the face of an invalid code
# - request:
# testName: end-stream/unrecognized-code
# service: connectrpc.conformance.v1.ConformanceService
# method: ServerStream
# streamType: STREAM_TYPE_SERVER_STREAM
# requestMessages:
# - "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
# responseDefinition:
# rawResponse:
# statusCode: 200
# headers:
# - name: content-type
# value: [ "application/connect+proto" ]
# stream:
# items:
# - flags: 2
# payload:
# text: |
# {
# "error": { "code": "foobar", "message": "oops" }
# }
# expectedResponse:
# error:
# code: CODE_UNKNOWN
# message: oops
- request:
testName: end-stream/unrecognized-code
service: connectrpc.conformance.v1.ConformanceService
method: ServerStream
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
statusCode: 200
headers:
- name: content-type
value: [ "application/connect+proto" ]
stream:
items:
- flags: 2
payload:
text: |
{
"error": { "code": "foobar", "message": "oops" }
}
expectedResponse:
error:
code: CODE_UNKNOWN
message: oops
- request:
testName: end-stream/allow-unrecognized-fields
service: connectrpc.conformance.v1.ConformanceService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ testCases:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 412
statusCode: 403
headers:
- name: content-type
value: [ "application/proto" ]
unary:
binary_message: { "@type": "type.googleapis.com/connectrpc.conformance.v1.UnaryResponse"}
expectedResponse:
error:
# mapped from 412 status code (invalid body ignored)
code: CODE_FAILED_PRECONDITION
# mapped from 403 status code (invalid body ignored)
code: CODE_PERMISSION_DENIED

- request:
testName: client-stream/ok-but-no-response
Expand All @@ -43,7 +43,7 @@ testCases:
text: |
{
"code": "out_of_range",
"message": "oops",
"message": "oops"
}
expectedResponse:
error:
Expand Down Expand Up @@ -74,7 +74,7 @@ testCases:
text: |
{
"code": "out_of_range",
"message": "oops",
"message": "oops"
}
expectedResponse:
error:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ relevantCompressions:
relevantCodecs:
- CODEC_PROTO
testCases:
- request:
testName: unexpected-content-type
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
rawRequest:
verb: POST
uri: /connectrpc.conformance.v1.ConformanceService/Unary
headers:
- name: content-type
value: [ "image/jpeg" ]
unary:
binary: "12345678"
expectedResponse:
httpStatusCode: 415
error:
code: CODE_UNKNOWN

- request:
testName: server-stream/no-request
streamType: STREAM_TYPE_SERVER_STREAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,9 @@ testCases:
headers:
- name: Content-Type
value: [ "image/jpeg" ]
otherAllowedErrorCodes:
# Not actually specified what error code to use, but only
# internal and unknown really make any sense. There may be
# an argument for unimplemented, too.
- CODE_INTERNAL
- CODE_UNIMPLEMENTED
expectedResponse:
error:
# derived from 200 response code
code: CODE_UNKNOWN
- request:
testName: unexpected-codec
Expand Down
Loading
Loading