version: 1
# PingCAP-managed Connected App seed (Zeno's and Tony's staging test clients).
#
# This module deploys the PingCAP staging test connected apps plus the User
# each runs as, so they are preserved across new-staging / EXP deployment resets
# (branch-reset wipes the manually-created app; this re-creates it in place).
#
# The run-as User is referenced through a record ref (not a lookup) so the
# adapter *creates* the User where it is absent (fresh EXP) and *reuses* the
# existing User where it already exists (new-staging, restored from the prod
# branch baseline). The logical ProfileId key is resolved by Profile Name for
# fresh-EXP create. A User restored into Staging is matched by its reviewed
# semantic Profile name instead of an environment-specific physical Salesforce
# Profile Id. The User is never patched: authorization drift fails closed
# instead of overwriting the real user or silently changing app authority.
environment:
  name: pingcap-connected-apps
  base_url_env: WATCHDOG_BASE_URL
  frontend_health_path: /health
  backend_base_url_env: WATCHDOG_BACKEND_BASE_URL
  backend_health_path: /health
  artifact_root: .runtime/pingcap-connected-apps/runs
  default_timeout_seconds: 30
actors:
  admin:
    username_env: WATCHDOG_ADMIN_USERNAME
    password_env: WATCHDOG_ADMIN_PASSWORD
    role: admin
lookup_records:
selectors: {}
inputs: {}
app_shells: []
scenes: {}
baseline_records:
  # Run-as User for the connected app. Matched on Username: created only when
  # absent (fresh EXP); when it already exists (new-staging via prod
  # branch-reset) the adapter resolves the User Id only after Username,
  # IsActive, and the reviewed semantic ExistingProfileName match. It never
  # PATCHes the User; Email/name/Alias and system_admin ProfileId remain
  # create-only fields for a fresh EXP environment.
  - key: connected_apps_zeno_user
    object: User
    match:
      Username: lu.wang@pingcap.com
      ExistingProfileName: Alliance & Channel
    fields:
      Username: lu.wang@pingcap.com
      Email: lu.wang@pingcap.com
      FirstName: Zeno
      LastName: Wang
      Alias: zeno
      ProfileId: system_admin
      IsActive: true
  # Zeno's staging test connected app. Confidential client (carries a
  # ConsumerSecret; the object has no separate client-type field). Matched on
  # ConsumerKey so refresh/reset upserts it in place instead of duplicating or
  # dropping it. RunAsUserId is a record ref to the seeded User above, so it
  # resolves to whatever Id that get-or-create produced in this environment.
  #
  # ConsumerSecret is NEVER a tracked literal: the adapter resolves it at apply
  # time from the CONNECTED_APPS_ZENO_CONSUMER_SECRET deploy env variable (same
  # {{ env.* }} convention exp-baseline.seed.yaml uses for its user Password).
  # Set that variable in the staging/EXP deploy environment to the partner's
  # secret. For an existing app, the adapter proves this value before any seed
  # mutation and preserves the stored secret hash; secret rotation is therefore
  # an explicit operator action outside this seed, never an unverified PATCH.
  # When the app is absent after reset, this value is used for its creation.
  - key: connected_apps_zeno_connected_app
    object: _System_ConnectedApp
    match:
      ConsumerKey: oXCHlm77BgAh6nJGfCqew41Mq9gdyPyGo6FzA2viLGw
    fields:
      Name: Zeno's Connected App - Staging
      ConsumerKey: oXCHlm77BgAh6nJGfCqew41Mq9gdyPyGo6FzA2viLGw
      ConsumerSecret: "{{ env.CONNECTED_APPS_ZENO_CONSUMER_SECRET }}"
      IsActive: true
      Scopes: api
      PermittedUsers: AllUsers
      RunAsUserId: "{{ record.connected_apps_zeno_user.id }}"
  # Run-as User for Tony's connected app. Matched on Username + the reviewed
  # ExistingProfileName; created only when absent (fresh EXP). When it already
  # exists (new-staging via prod branch-reset) the adapter resolves the Id after
  # Username, IsActive, and the profile match, and never PATCHes the User;
  # Email/name/Alias and the system_admin create-ProfileId stay create-only.
  - key: connected_apps_tony_user
    object: User
    match:
      Username: chenhao.huang@pingcap.com
      ExistingProfileName: Pre-Sales
    fields:
      Username: chenhao.huang@pingcap.com
      Email: chenhao.huang@pingcap.com
      FirstName: Tony
      LastName: Huang
      Alias: tony
      ProfileId: system_admin
      IsActive: true
  # Tony's staging test connected app. Confidential client (carries a
  # ConsumerSecret; the object has no separate client-type field). Matched on
  # ConsumerKey so refresh/reset upserts it in place instead of duplicating or
  # dropping it. RunAsUserId is a record ref to the seeded User above.
  #
  # ConsumerSecret is NEVER a tracked literal: the adapter resolves it at apply
  # time from the CONNECTED_APPS_TONY_CONSUMER_SECRET deploy env variable. Set
  # that variable in the staging/EXP deploy environment to the partner's secret.
  # For an existing app, the adapter proves this value before any seed mutation
  # and preserves the stored secret hash; when absent after reset it is created.
  - key: connected_apps_tony_connected_app
    object: _System_ConnectedApp
    match:
      ConsumerKey: xV6EN2In3lh8Co3MLUmgib4iW3KtSF3RW3n-yIVi5DU
    fields:
      Name: Tony's Connected App - Staging
      ConsumerKey: xV6EN2In3lh8Co3MLUmgib4iW3KtSF3RW3n-yIVi5DU
      ConsumerSecret: "{{ env.CONNECTED_APPS_TONY_CONSUMER_SECRET }}"
      IsActive: true
      Scopes: api
      PermittedUsers: AllUsers
      RunAsUserId: "{{ record.connected_apps_tony_user.id }}"
