Sandbox test operators — CI 用 headless login tokens

operator-facing flow (mobile operator app、warehouse terminal、PDP-gated resource access など) の automated acceptance tests を作成する場合、CI には account_id claim を持つ実際の end-user token が必要です。これは人間の operator がログイン後に受け取るものと同じ形です。人間のログインを script 化することはできません (意図的に email OTP + CAPTCHA で保護されています)。また、単に admin が作成した user には account_id は含まれません。

sandbox test-operator API はこれを解決する: AK/SK-authenticated call 1 回で自分の account 内に workforce operator を provision し、CI が即座に使用できる実際の Keycloak-issued operator token を返す。

TL;DR. POST https://api.flexgalaxy.ai/developer/v1/test-users, signed with your account's access key (FGAI-HMAC). Pass the service_id of the product your CI is about to call. You get back { user_id, email, access_token, expires_in }. The access_token is a real operator token (carries account_id + user_type=workforce), valid for 5 minutes. It is addressed to the product you named, plus the DotID base audience — the product's own API accepts it, and the PDP accepts it everywhere. Delete the operator with DELETE /developer/v1/test-users/{user_id} when the suite finishes.

Prerequisites — one-time account setup

これを Account root または認可済み account admin に転送してください:

  1. 組織内の sandbox アカウント。 テストオペレーターは、Identity Center instance 内の workforce user として作成されるため、プロビジョニング先のアカウントは組織に属している必要があります(スタンドアロンアカウントではありません)。

  2. そのアカウント内の principal 用 access key(Profile → Credentials → Access keys、または developer credential API)。

  3. iam:CreateTestUser capability を grant します その principal に対して — account に scope された IAM policy statement:

    {
      "Effect": "Allow",
      "Action": "iam:CreateTestUser",
      "Resource": "frn:<accountId>:iam:account/<accountId>"
    }
    

    この機能により、アカウントは "sandbox" になります。admin が明示的に許可したアカウントだけが test operator を発行でき、呼び出し元は常に自分自身のアカウントにのみプロビジョニングできます (アカウントは AK/SK token から取得され、request body からは決して取得されません)。

operator を作成

他の /developer/v1/* または /identity/v1/* 呼び出しに署名する場合と同じ方法で、FGAI-HMAC-SHA256 により request に署名する(Integrate with access keys を参照)。

POST /developer/v1/test-users
Authorization: FGAI-HMAC-SHA256 Credential=AKIA.../.../identity/fgai4_request, ...
Content-Type: application/json

{ "user_type": "workforce", "service_id": "bazaar" }

service_id names the registered product your CI will call; the minted token is addressed to that product's API audience so the product's API accepts it. Omit it and the token carries only the DotID base audience — usable against DotID's own APIs, but a product API will reject it. An unregistered id is refused with 400 {"error":"unknown_service_id"}. user_type is optional (only workforce is supported today) and email is optional (a @sandbox.flexgalaxy.test address is generated when omitted).

201 レスポンス:

{
  "user_id": "b3a0de58-318f-41f9-bba5-dfe8fdbaa17d",
  "email": "op-2124a427b3@sandbox.flexgalaxy.test",
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUI...",
  "expires_in": 300
}

access_token は genuine operator token に decode される:

{
  "iss": "https://auth.flexgalaxy.ai/auth/realms/flexgalaxy",
  "aud": ["<the product's audience>", "flexgalaxy-api"],
  "sub": "b3a0de58-318f-41f9-bba5-dfe8fdbaa17d",
  "account_id": "<your sandbox account UUID>",
  "user_type": "workforce",
  "exp": "<iat + 300>"
}

(aud with the service_id above; without it, aud is just "flexgalaxy-api".)

Present it to any FlexGalaxy.AI API as Authorization: Bearer <access_token>. It validates against the realm JWKS like a real login, resolves the correct account_id, and is denied on cross-account access — exactly what your acceptance test asserts. (The policy simulator is a different credential class: it is called with FGAI-HMAC-signed service-user keys, never this token.)

短い TTL、refresh なし。 トークンの有効期間は 5 分です。より長い suite では、fresh token のために POST /developer/v1/test-users を再度呼び出してください(または同じ operator user_id を再利用できます — 削除するまで存続します)。

一覧表示と削除

GET    /developer/v1/test-users            → [{ "user_id", "email" }, ...]
DELETE /developer/v1/test-users/{user_id}  → 204

DELETE はオペレーターとそのアカウント割り当てを削除します。サンドボックスオペレーターが蓄積しないよう、テスト実行の最後にクリーンアップしてください。

Scope と safety

  • operator は実際の workforce user であり、実際の Identity Center assignment によってあなたの sandbox account への entitlement を持つ。platform がその gate を強制するため、token が保持できる account_id は実際に所有するものだけである。

  • これは自分の account 内に限定され、別 tenant には触れられません。

  • すべての create と delete は audit されます (DeveloperTestUserCreated / DeveloperTestUserDeleted)。

  • これは sandbox/testing 用の機能です。test operator を production identity として使用しないでください。