|
22 | 22 |
|
23 | 23 | TEST_INVOKE_TEMPLATE = """Execution log for request {request_id}
|
24 | 24 | {formatted_date} : Starting execution for request: {request_id}
|
25 |
| -{formatted_date} : HTTP Method: GET, Resource Path: {resource_path} |
| 25 | +{formatted_date} : HTTP Method: {request_method}, Resource Path: {resource_path} |
26 | 26 | {formatted_date} : Method request path: {method_request_path_parameters}
|
27 | 27 | {formatted_date} : Method request query string: {method_request_query_string}
|
28 | 28 | {formatted_date} : Method request headers: {method_request_headers}
|
@@ -68,7 +68,8 @@ def log_template(invocation_context: RestApiInvocationContext, response_headers:
|
68 | 68 | return TEST_INVOKE_TEMPLATE.format(
|
69 | 69 | formatted_date=formatted_date,
|
70 | 70 | request_id=context_var["requestId"],
|
71 |
| - resource_path=context_var["resourcePath"], |
| 71 | + resource_path=request["path"], |
| 72 | + request_method=request["http_method"], |
72 | 73 | method_request_path_parameters=dict_to_string(request["path_parameters"]),
|
73 | 74 | method_request_query_string=dict_to_string(request["query_string_parameters"]),
|
74 | 75 | method_request_headers=_dump_headers(request.get("headers")),
|
@@ -176,11 +177,18 @@ def run_test_invocation(
|
176 | 177 | invocation_context = create_test_invocation_context(test_request, deployment)
|
177 | 178 |
|
178 | 179 | test_chain = create_test_chain()
|
179 |
| - # we manually add the trace-id, as it is normally added by handlers.response_enricher which adds to much data for |
180 |
| - # the TestInvoke |
181 |
| - test_response = Response( |
182 |
| - headers={"X-Amzn-Trace-Id": invocation_context.trace_id, "Content-Type": APPLICATION_JSON} |
183 |
| - ) |
| 180 | + # header order is important |
| 181 | + if invocation_context.integration["type"] == "MOCK": |
| 182 | + base_headers = {"Content-Type": APPLICATION_JSON} |
| 183 | + else: |
| 184 | + # we manually add the trace-id, as it is normally added by handlers.response_enricher which adds to much data |
| 185 | + # for the TestInvoke. It needs to be first |
| 186 | + base_headers = { |
| 187 | + "X-Amzn-Trace-Id": invocation_context.trace_id, |
| 188 | + "Content-Type": APPLICATION_JSON, |
| 189 | + } |
| 190 | + |
| 191 | + test_response = Response(headers=base_headers) |
184 | 192 | start_time = datetime.datetime.now()
|
185 | 193 | test_chain.handle(context=invocation_context, response=test_response)
|
186 | 194 | end_time = datetime.datetime.now()
|
|
0 commit comments