Modular logistics and supply chain operating system (LSOS)
JavaScript driver-appfleet-managementfreight-managementinfrastructureinventory-managementlast-mile-deliverylogisticsondemandopen-sourceorder-managementroute-optimizationsupply-chain-managementtracking-and-monitoringtransport-management-systemtransportationwarehouse-management
ci(api-contract): seed a storefront key so that collection can authenticate
Ronald A. Richardson697bc648e968
diff --git a/.github/actions/postman-contract/action.yml b/.github/actions/postman-contract/action.ymlindex 915ad8a7..50eaad9f 100644--- a/.github/actions/postman-contract/action.yml+++ b/.github/actions/postman-contract/action.yml@@ -110,6 +110,7 @@ runs:KEY="$(printf '%s\n' "$OUT" | grep -oE 'flb_(live|test)_[A-Za-z0-9_-]+' | tail -1 || true)"PLATFORM_TOKEN="$(printf '%s\n' "$OUT" | grep -oE 'flb_platform_[A-Za-z0-9]+' | tail -1 || true)"ORGANIZATION_ID="$(printf '%s\n' "$OUT" | grep -oE 'MINTED_COMPANY_ID=company_[A-Za-z0-9]+' | tail -1 | cut -d= -f2 || true)"+ STOREFRONT_KEY="$(printf '%s\n' "$OUT" | grep -oE 'MINTED_STOREFRONT_KEY=store_[A-Za-z0-9]+' | tail -1 | cut -d= -f2 || true)"if [[ -z "$KEY" ]]; thenecho "::error::Could not mint an API key from the running stack. Tinker output:"printf '%s\n' "$OUT"@@ -138,6 +139,14 @@ runs:# The organizations listing sits behind the platform API token rather than an# org credential and answers 401 to an flb_live_ key. Absent is not fatal —# only those requests will 401.+ # The Storefront API rejects any bearer token that is not a store/network key,+ # so its collection cannot use the organization credential at all.+ if [[ -n "$STOREFRONT_KEY" ]]; then+ echo "::add-mask::$STOREFRONT_KEY"+ echo "storefront_key=$STOREFRONT_KEY" >> "$GITHUB_OUTPUT"+ else+ echo "::warning::No storefront key minted; the Storefront collection will 401."+ fiif [[ -n "$PLATFORM_TOKEN" ]]; thenecho "::add-mask::$PLATFORM_TOKEN"echo "platform_token=$PLATFORM_TOKEN" >> "$GITHUB_OUTPUT"@@ -180,6 +189,7 @@ runs:env:API_KEY: ${{ steps.key.outputs.api_key }}PLATFORM_TOKEN: ${{ steps.key.outputs.platform_token }}+ STOREFRONT_KEY: ${{ steps.key.outputs.storefront_key }}ORGANIZATION_ID: ${{ steps.key.outputs.organization_id }}COLLECTIONS: ${{ inputs.collections }}BASE_URL: ${{ inputs.base-url }}@@ -226,6 +236,7 @@ runs:' --env-var "namespace=${NAMESPACE}" \' \' --env-var "api_key=${API_KEY}" \' \' --env-var "platform_token=${PLATFORM_TOKEN}" \' \+ ' --env-var "storefront_key=${STOREFRONT_KEY}" \' \' --env-var "organization_id=${ORGANIZATION_ID}" \' \' --env-var "customer_identity=${CUSTOMER_IDENTITY}" \' \' --env-var "customer_email=${CUSTOMER_IDENTITY}" \' \diff --git a/scripts/ci/mint-api-key.php b/scripts/ci/mint-api-key.phpindex e5b9fbcc..c0a5469c 100644--- a/scripts/ci/mint-api-key.php+++ b/scripts/ci/mint-api-key.php@@ -142,6 +142,36 @@ try {$seedVerificationCode('fleetops_customer_login');$seedVerificationCode('fleetops_customer_password_reset', ['identity' => $customerIdentity]);+ // The Storefront API authenticates with a store/network key, not an organization+ // API credential: SetStorefrontSession rejects any bearer token that does not start+ // with "store" or "network", so the flb_live_ key above can never authenticate a+ // Storefront request. Seed a store so the Storefront collection has a usable key.+ // Guarded because the extension is not installed in every stack.+ if (class_exists(\Fleetbase\Storefront\Models\Store::class)) {+ $store = \Fleetbase\Storefront\Models\Store::where([+ 'company_uuid' => $company->uuid,+ 'name' => 'CI Contract Store',+ ])->first();++ if (!$store) {+ // Store::boot() sets `key` to 'store_' . md5(...) on creating, so the key+ // exists only after the insert — it cannot be supplied.+ $store = \Fleetbase\Storefront\Models\Store::create([+ 'company_uuid' => $company->uuid,+ 'created_by_uuid' => $user->uuid,+ 'name' => 'CI Contract Store',+ 'description' => 'Seeded by the API contract run.',+ 'currency' => 'USD',+ 'online' => 1,+ ]);+ }++ echo 'MINTED_STOREFRONT_KEY=' . $store->fresh()->key . PHP_EOL;+ echo 'MINTED_STOREFRONT_ID=' . $store->public_id . PHP_EOL;+ } else {+ echo 'MINTED_STOREFRONT_KEY=' . PHP_EOL;+ }+echo 'SEEDED_CUSTOMER_IDENTITY=' . $customerIdentity . PHP_EOL;echo 'SEEDED_CUSTOMER_PHONE=' . $customerPhone . PHP_EOL;echo 'SEEDED_VERIFICATION_CODE=' . $customerCode . PHP_EOL;