test(acceptance): reuse fixed customers and align native fulfillment flows
This commit is contained in:
@@ -157,10 +157,14 @@ def data_handler(state, upstream, timeout):
|
||||
wallet_endpoint = "/internal/finance/v1/wallet-command-events"
|
||||
wallet_passthrough = (state.fee_source_id is not None
|
||||
and endpoint == "/internal/finance/v1/business-fee-source-events")
|
||||
# Firstleg 的同步只读客户端与装柜事件共用 LASTLEG_SERVICE_URL。
|
||||
loading_reads = state.event_type == "FirstLegLoadingPlanCompleted" and endpoint == "/internal/lastleg/events"
|
||||
workflow_endpoint = "/internal/lastleg/v1/order-workflow-facts"
|
||||
|
||||
class DataHandler(QuietHandler):
|
||||
def do_POST(self):
|
||||
passthrough = wallet_passthrough and self.path == wallet_endpoint
|
||||
passthrough = (wallet_passthrough and self.path == wallet_endpoint
|
||||
or loading_reads and self.path == workflow_endpoint)
|
||||
if self.path != endpoint and not passthrough:
|
||||
self.safe_error(404, "UNEXPECTED_EVENT_ENDPOINT")
|
||||
return
|
||||
@@ -172,12 +176,22 @@ def data_handler(state, upstream, timeout):
|
||||
state.record(identity, matched, attempt, None, error_code)
|
||||
self.safe_error(409, error_code)
|
||||
return
|
||||
destination = urllib.parse.urlunsplit((parts.scheme, parts.netloc, self.path, "", "")) if passthrough else upstream
|
||||
self.forward(body, identity, matched, attempt, mode, destination, "POST")
|
||||
|
||||
def do_GET(self):
|
||||
if not loading_reads or not re.fullmatch(r"/internal/lastleg/appointment-work/containers/[1-9][0-9]*/route", self.path):
|
||||
self.safe_error(404, "UNEXPECTED_EVENT_ENDPOINT")
|
||||
return
|
||||
destination = urllib.parse.urlunsplit((parts.scheme, parts.netloc, self.path, "", ""))
|
||||
self.forward(None, None, False, 0, "PASS", destination, "GET")
|
||||
|
||||
def forward(self, body, identity, matched, attempt, mode, destination, method):
|
||||
# Forward the exact body and end-to-end headers. Never persist auth headers.
|
||||
connection_headers = set(self.headers.get("Connection", "").lower().replace(" ", "").split(","))
|
||||
headers = {name: value for name, value in self.headers.items()
|
||||
if name.lower() not in HOP_HEADERS | connection_headers}
|
||||
destination = urllib.parse.urlunsplit((parts.scheme, parts.netloc, wallet_endpoint, "", "")) if passthrough else upstream
|
||||
request = urllib.request.Request(destination, data=body, headers=headers, method="POST")
|
||||
request = urllib.request.Request(destination, data=body, headers=headers, method=method)
|
||||
try:
|
||||
# Redirects are forbidden: a redirect could expose a service identity token.
|
||||
class NoRedirect(urllib.request.HTTPRedirectHandler):
|
||||
|
||||
Reference in New Issue
Block a user