Loading…
Loading…
Proxies test execution requests to the runtime environment. Mints a short-lived JWT for authentication and records successful runs for readiness checks.
The Test Execution endpoint is an administrative API that functions as a secure proxy to the platform's test execution runtime. It allows an authorized API publisher to invoke a specific API operation with a custom payload and receive a direct response from the backend system, as mediated by the runtime.
This endpoint solves the problem of providing a secure and convenient way to perform live integration tests. Instead of exposing the internal runtime test service, this endpoint validates the request, authenticates to the runtime using a short-lived, auto-provisioned credential, and forwards the request.
Key capabilities include:
Content-Type for the runtime to process correctly.This endpoint is called by an API publisher, typically through a user interface, to manually test an operation's behavior before publishing it.
The test execution process involves a sequence of steps to securely proxy the request from the administrative environment to the runtime environment.
sequenceDiagram
participant C as API Consumer
participant P as Test Execution Proxy
participant R as Test Execution Runtime
participant DB as Platform Database
C->>+P: POST /.../test-execute
P->>P: Resolve runtime URL from request host
P->>DB: Resolve HMAC key (read s2r_secret)
alt Key not in DB
P->>P: Check for legacy env var
alt Env var exists
P->>DB: Seed key into s2r_secret
DB-->>P: Return seeded key
else No env var
P->>P: Generate 64-byte random key
P->>DB: Seed key into s2r_secret (idempotent)
DB-->>P: Return winning key
end
end
DB-->>P: HMAC Secret Key
P->>DB: Validate service/version/operation exist
DB-->>P: Validation OK
P->>P: Mint 5-minute JWT
P->>+R: POST /_test/v1/... (with JWT)
R-->>-P: Proxied Response (e.g., HTTP 200)
P->>DB: Write audit log (best-effort)
alt Successful Test Run
P->>DB: Write to s2r_backend_test_preview (best-effort)
DB-->>P:
end
P-->>-C: Return Proxied ResponseThe process flow is as follows:
POST request to the /admin/v1/services/{serviceId}/versions/{versionId}/operations/{operationKey}/test-execute endpoint.Host of the incoming request. This removes the need for static configuration.serviceId, versionId, and operationKey exist and are correctly associated with each other. If not, it returns a 404 Not Found error.JWT_TTL). It includes the versionId and operationKey as claims and is signed with the resolved HMAC key using the HS256 algorithm.POST request to the runtime's internal /_test/v1/{versionId}/{operationKey} endpoint.
Authorization header is set to Bearer <jwt>.Content-Type header from the original request is preserved for XML/SOAP, or normalized to application/json for JSON payloads.service.test-execute-via-runtime) is recorded.text/plain.The security of the test execution proxy relies on an HMAC-signed JWT, which requires a shared secret key between the Admin API and the runtime. This key, identified as TEST_EXECUTE_HMAC_KEY, is managed automatically to ensure operational simplicity.
The key is resolved on the first test-execute call and cached in memory. The resolution follows a specific order:
s2r_secret table): The system first attempts to retrieve the key from the s2r_secret table. This is the standard steady-state mechanism.S2R_TEST_EXECUTE_HMAC_KEY): If the key is not in the database, the system checks for a legacy environment variable S2R_TEST_EXECUTE_HMAC_KEY. If found, its value is immediately seeded into the s2r_secret table to be used for all subsequent lookups. This allows the environment variable to be retired after first use.s2r_secret table using an idempotent INSERT ... ON CONFLICT DO NOTHING operation. It then re-reads the key from the database to ensure that in a concurrent environment, all service replicas converge on the single key that won the insertion race.This self-healing mechanism ensures that a newly deployed system can become operational without any manual key provisioning steps.
A primary feature of this endpoint is its integration with the publish-readiness gate. A successful manual test run provides valid evidence that an operation is configured correctly, and the system records this to satisfy the relevant readiness check.
A test run is recorded in the s2r_backend_test_preview table only if it meets all the following criteria:
executionResult object, indicating the backend was invoked.httpStatus within the executionResult is 200.BLOCK.SoapMessageMapper to parse the response and detect faults.errorOrigin field in the runtime response is NONE or absent).If these conditions are met, a record with overall_status='ok' is created. If the backend returns an HTTP 200 response but contains a SOAP Fault or a classified applicative error, the run is recorded with overall_status='failed' and will not satisfy the readiness gate. This ensures that only truly successful interactions are counted.
NOTE
The persistence of audit logs and readiness previews is a best-effort operation. A failure in these steps will be logged but will not cause the test-execute request itself to fail.
Proxies a test request for a specific operation to the runtime environment.
POST /admin/v1/services/{serviceId}/versions/{versionId}/operations/{operationKey}/test-execute
IMPORTANT
Access to this endpoint requires OPERATOR+ role permissions.
| Name | Type | Required | Description |
|---|---|---|---|
serviceId | UUID | Yes | The unique identifier of the service. |
versionId | UUID | Yes | The unique identifier of the service version. |
operationKey | String | Yes | The key identifying the operation within the version. |
The request body is optional and its content depends on the Content-Type header.
application/json: The body should be a valid JSON object. If the body is empty or omitted, it is treated as an empty JSON object ({}). The system validates the JSON structure before proxying.application/xml or text/xml: The body should be a valid XML or SOAP document. The body is proxied to the runtime verbatim without validation by the proxy.The source does not provide a concrete example request payload.
2xx/4xx/5xx: The endpoint proxies the HTTP status code and response body directly from the downstream runtime service. If the runtime response is valid JSON, the Content-Type will be application/json. Otherwise, it may be text/plain.{
"error": {
"code": "S2R-ADM-0404",
"message": "service not found",
"correlationId": "f8c3de3d-1fea-4d7c-a8b0-29d6a2a044e1",
"time": "2023-10-27T10:00:00Z"
}
}
The endpoint's behavior is primarily configured through the database. However, it supports one environment variable for backward compatibility and initial seeding of the HMAC key.
| Name | Type | Default | Description |
|---|---|---|---|
S2R_TEST_EXECUTE_HMAC_KEY | String | — | A legacy fallback for the internal HMAC shared secret. If set on a fresh deployment, its value will be automatically migrated into the s2r_secret database table on the first test-execute call. |
The following are common errors originating from the test execution proxy itself. Errors from the downstream runtime will be passed through.
| Status Code | Error Code | Message | Cause |
|---|---|---|---|
400 | S2R-VAL-0401 | request body is not valid JSON: ... | The Content-Type was application/json (or compatible), but the provided request body could not be parsed as valid JSON. |
404 | S2R-ADM-0404 | service not found | The serviceId in the URL does not correspond to an existing service. |
404 | S2R-ADM-0404 | service version not found for service | The versionId does not exist or is not associated with the given serviceId. |
404 | S2R-ADM-0404 | operation not found in version | The operationKey does not exist within the given versionId. |
502 | S2R-ADM-0502 | runtime call failed: ... | The proxy failed to send the request to the runtime service. This may be due to a network issue, a timeout (60s read, 5s connect), or the runtime service being unavailable. The specific exception is included in the message. |
503 | S2R-ADM-0423 | test_execute_unreachable — runtime base URL could not be resolved... | The proxy could not determine the runtime service's URL from the incoming request's host information. |
503 | S2R-ADM-0423 | test_execute_initializing — internal HMAC key not yet available... | The proxy is attempting to resolve or generate the HMAC secret key for the first time, but the operation has not yet completed (e.g., transient database issue). Retrying the request shortly should succeed. |
Internal system logs contain more detailed error information, correlated by the X-Correlation-Id header. Look for log messages with codes like S2R-ADM-0423 and S2R-ADM-0502.