gcpsim guide
Overview
gcpsim packages floci-gcp 0.11.0 together with a deterministic CLI, Pub/Sub ack-deadline overlay, and OAuth/IAM enforcement filter into a single native GraalVM executable. In open mode, REST and gRPC share loopback port 4588, enabling in-process Google Cloud Storage (GCS) and Cloud Pub/Sub testing without Docker containers, a Java runtime, or a GCP account.
Architecture and provenance overlays
The build script (scripts/build.py) verifies the upstream floci-gcp archive against upstream.lock.json and applies SHA-256-locked source overlays (overlay.lock.json):
- Shared port 4588: serves GCS JSON/multipart/resumable REST APIs, Pub/Sub v1 REST APIs, gRPC endpoints, and GET /health on 127.0.0.1:4588 with default project gcpsim-local.
- Pub/Sub modifyAckDeadline overlay: ensures queue_nack visibility updates and ack-deadline extensions or zero-second resets behave deterministically for Google Cloud SDKs and lmcloud queue conformance tests.
- Mock-by-default container services: Docker-backed services remain in in-process mock mode unless explicitly overridden via FLOCI_GCP_SERVICES_<SERVICE>_MOCK=false.
Authentication and IAM permission enforcement (--auth enforce)
By default, gcpsim runs in open mode (--auth open). Passing --auth enforce --auth-config auth.json (or setting SIM_AUTH=enforce and SIM_AUTH_CONFIG=auth.json) enables two-layer security checks:
- Dummy OAuth Bearer validation: inspects Authorization: Bearer <token> headers against tokens declared in auth.json, rejecting missing or unknown tokens with HTTP 401.
- GCP IAM permission evaluation: checks the authenticated principal's granted permissions (such as storage.buckets.create, storage.objects.get, pubsub.topics.publish, pubsub.subscriptions.consume) against the target project, bucket, topic, or subscription resource, rejecting unauthorized calls with HTTP 403 and redacting token values from logs.
Connecting lmgcp, lmgcp cloud, and gcloud
You can drive gcpsim from three different client surfaces:
- Native lmgcp host: export LMGCP_ENDPOINT=http://127.0.0.1:4588 (and LMGCP_ACCESS_TOKEN=<token> for enforce mode) before running lmgcp or lmscript.
- Shared lmcloud mode (lmgcp cloud): call cloud.set_endpoint("all", "http://127.0.0.1:4588") or export LMCLOUD_ENDPOINT=http://127.0.0.1:4588.
- Google Cloud SDK (gcloud): set CLOUDSDK_CORE_PROJECT=gcpsim-local, CLOUDSDK_AUTH_ACCESS_TOKEN=gcpsim-local-token, CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE=http://127.0.0.1:4588/storage/v1/, and CLOUDSDK_API_ENDPOINT_OVERRIDES_PUBSUB=http://127.0.0.1:4588/.