Skip to content

Modular logistics and supply chain operating system (LSOS)

ci(contract): socket auth via api/.env; the activity cycle asserts the 400 (#718)

Ron591bcad52cbf
diff --git a/.github/workflows/api-contract.yml b/.github/workflows/api-contract.yml
index 4a18ed20..1040b5c1 100644
--- a/.github/workflows/api-contract.yml
+++ b/.github/workflows/api-contract.yml
@@ -233,12 +233,23 @@ jobs:
# Socket auth on, so the socket-token endpoints are exercised rather than
# answering their "not configured" 404 (Storefront's Create Customer Socket
- # Token). The installer reads SOCKETCLUSTER_AUTH_ENABLED from the PROJECT .env,
- # the one Compose loads, keeps a value that is already there and generates the
- # key; the socket server starts in log mode, so nothing is enforced. The API
- # then publishes events over the socket server's signed HTTP endpoint; a
- # published socket image without it drops them, and no request in the run
+ # Token). SocketToken::enabled() needs BOTH the switch and a key of at least 32
+ # characters, read from the API's own .env like the mail settings above: the
+ # overlaid core (1.6.69+) reads them from config, and the compose file this
+ # branch boots passes no SOCKETCLUSTER_AUTH_* environment into the container.
+ # The key is a per-run secret for a throwaway stack.
+ #
+ # The switch is ALSO written to the project .env, which Compose loads. Once the
+ # socket-auth release (fleetbase/fleetbase#710) is on main, the installer reads
+ # it from there, generates the shared key, passes both to the socket server and
+ # the API (container env wins over api/.env), and starts the socket server in
+ # log mode — so this keeps working unchanged.
+ #
+ # With auth on the API publishes events over the socket server's signed HTTP
+ # endpoint; a socket image without it drops them, and no request in the run
# depends on a delivered event.
+ set_env SOCKETCLUSTER_AUTH_ENABLED true
+ set_env SOCKETCLUSTER_AUTH_KEY "$(openssl rand -hex 32)"
if grep -q '^SOCKETCLUSTER_AUTH_ENABLED=' .env 2>/dev/null; then
sed -i 's|^SOCKETCLUSTER_AUTH_ENABLED=.*|SOCKETCLUSTER_AUTH_ENABLED=true|' .env
else
diff --git a/scripts/ci/order-collection-requests.py b/scripts/ci/order-collection-requests.py
index 1e513c9c..814ce3af 100755
--- a/scripts/ci/order-collection-requests.py
+++ b/scripts/ci/order-collection-requests.py
@@ -85,12 +85,14 @@ EXCLUDED = {
# complete), so `times` is well above the stop count rather than equal to it.
#
# A surplus cycle used to be a counted failure: once the flow is exhausted updateActivity
-# answers "Order is already completed." with a 400. The collection now ends the cycle
+# answers "Order is already completed." with a 400. The collection now absorbs that
# itself — Get Order Next Activity records an empty answer as `order_flow_exhausted`, and
-# both requests skip (pm.execution.skipRequest) from then on, which is neither a pass nor
-# a failure. So `times` only has to be an upper bound: a flow that needs more passes than
-# this fails at Complete an Order with "Not all waypoints completed", and the fix is to
-# raise it, not to treat it as an API problem. Six stops took eight to twelve passes.
+# Update Order Activity then asserts the documented 400 (`expected_status`) instead of a
+# 2xx. (Skipping the surplus passes with pm.execution.skipRequest looked cleaner, but the
+# Postman CLI counts a skipped request as "Request could not be completed" and exits 1.)
+# So `times` only has to be an upper bound: a flow that needs more passes than this fails
+# at Complete an Order with "Not all waypoints completed", and the fix is to raise it, not
+# to treat it as an API problem. Six stops took eleven passes.
#
# `then` runs after the cycle, which is the only way Complete an Order can see every
# waypoint COMPLETED.