Run server httpRequestTest
s and httpMalformedRequestTests
against actual Service
s
#1212
Labels
httpRequestTest
s and httpMalformedRequestTests
against actual Service
s
#1212
Currently, we're deserializing requests manually in server
httpRequestTest
protocol tests. That is, we build the HTTP request and then callfrom_request()
on the operation input wrapper struct corresponding to the operation associated with the test that was passed intoServerProtocolTestGenerator
. We then assert that what we've deserialized is what we expected inparams
.Instead, we should be running the actual service defined in the Smithy model of the protocol test. Maybe not run a Hyper server over localhost, but at the very least invoking the
tower::Service
that we get from theOperationRegistry
. This is a "higher-level" test that has some advantages over how we're currently doing things:OperationRegistry
, conversion into theRouter
Service
,Router
(we could have protocol tests specifically exercising possibly ambiguous routing decisions),FromRequest
/IntoResponse
traits, to which the service implementer does not have access in their code,method
field from the test cases; as of now we're ignoring it and sending onlyGET
requests, and none of the tests have failed because there's no exercised code path that looks at the HTTP method (if ourRouter
had been in the code path, it would have caught a possible failure),Overall we get more assurances.
Note though that the actual assertions against
params
s would be made inside the operation handlers that we'd code-generate (perhaps as closures). It's unclear what we should return from the operation handlers though, unless the output operation struct isDefault
.For
httpMalformedRequestTest
s, the assertions are against HTTP responses, so they'd continue to go in the test functions.Note that this approach is also how
awslabs/smithy-typescript
operates.The text was updated successfully, but these errors were encountered: