Replies: 1 comment 3 replies
-
Nothing comes to my mind. At first glance, I'd assume that your code worked as expected. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello - new to rust and the lambda-rust-runtime, hoping to get some advice. I am trying to write some tests to verify the configuration of my routes and handlers in a rust lambda that backs an api gateway api. My code works when deployed, but I wanted to just write a basic test to validate that an incoming request gets routed, parsed, and passed through the handlers correctly.
I took the json of a request out of my logs and am trying to use it to run the handler through the router. The problem I'm having is that I'm using an axum extractor to get auth information from the request, but when it gets to the extractor in test, the Parts being passed in do not have the requestcontext_ref. I can verify before I execute the router on the LambdaEvent that the Parts do have the requestcontext info, but it seems to be getting lost in test, on the way to my extractor.
Here are some snippets: first, my test setup. As comments show, after I create the request I can verify that breaking it into parts includes the authorizer in the requestcontext_ref:
my router setup looks like this. The tracing layer shows that authorizer info is at least on the request extensions in here, although I can't check parts:
here is my authorization extractor. Although this works when deployed, in my test at this point the request_context_ref is None, so I can't get to the authorizer information:
FWIW, here is my handler declaration, where I'm pulling out the auth data using the extractor:
I'm guessing there is some step in setting up the request that I'm missing, or something that lambda_http::run does to add/preserve the parts that I've skipped?
Beta Was this translation helpful? Give feedback.
All reactions