{
  "description": "SDK-only reference vectors and lifecycle COVERAGE MANIFEST; lifecycle entries require native executable tests. Fake credential strings; no AHP wire-schema change. In token_responses, requested is the caller's current requested set, always within allowed (requested scopes outside the ceiling are invalid_configuration); a response scope that is absent, null or blank inherits like an omitted one; wire_request, present for exchange reacquire, is the scope set actually sent: previous_granted plus ceiling-filtered requested and required. keys use client_identity (preregistered:id, cimd:url or dcr), never an issued client_id; registration_keys are client-credentials only; client_selection inputs describe host configuration and authorization-server metadata; registration_responses use now as the current Unix time. scope_decisions and completions fields, and the optional requires features (token_validation_callback, complete_handle, legacy_prepare_time_host_required), are defined in spec/draft/sdk-auth-lifecycle.md (Executable coverage); every defined field must be asserted and an unknown field fails the run. In token_responses, error_scopes is the scope set carried by access_denied.",
  "recovery": [
    {
      "code": "invalid_configuration",
      "recovery": "configure"
    },
    {
      "code": "unsupported_binding",
      "recovery": "configure"
    },
    {
      "code": "credential_unavailable",
      "recovery": "configure"
    },
    {
      "code": "interaction_required",
      "recovery": "login"
    },
    {
      "code": "access_denied",
      "recovery": "none"
    },
    {
      "code": "refresh_rejected",
      "recovery": "login"
    },
    {
      "code": "discovery_failed",
      "recovery": "retry"
    },
    {
      "code": "untrusted_destination",
      "recovery": "configure"
    },
    {
      "code": "provider_failed",
      "recovery": "retry"
    }
  ],
  "keys": [
    {
      "id": "default-event",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ]
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "default-upload",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "upload",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ]
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend6:upload25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce80:binding:ahp.oauth.binding:7:account7:backend6:upload25:https://api.example/hooks"
    },
    {
      "id": "shared-event",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ],
        "grant_partition": "approved-events-and-uploads"
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce34:shared:approved-events-and-uploads"
    },
    {
      "id": "shared-upload",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "upload",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ],
        "grant_partition": "approved-events-and-uploads"
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend6:upload25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce34:shared:approved-events-and-uploads"
    },
    {
      "id": "unicode-namespace",
      "input": {
        "namespace": "account-\ud83d\ude00",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ]
      },
      "binding_key": "ahp.oauth.binding:12:account-\ud83d\ude007:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:12:account-\ud83d\ude0022:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce85:binding:ahp.oauth.binding:12:account-\ud83d\ude007:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "scope-ceiling-widening",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "write",
          "offline_access"
        ]
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "resource-trailing-slash",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example/",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ]
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example20:https://api.example/20:preregistered:client23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "secret-auth-method-and-capability-rotation",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "preregistered:client",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ],
        "client_secret": "not-a-real-secret",
        "metadata": {
          "grant_types_supported": [
            "authorization_code",
            "refresh_token",
            "client_credentials"
          ]
        },
        "token_endpoint_auth_method": "client_secret_basic"
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example20:preregistered:client23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "cimd-client-id",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "cimd:https://adapter.example/oauth/client.json",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ]
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example46:cimd:https://adapter.example/oauth/client.json23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "dcr-client-identity",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "dcr",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ],
        "issued_client_id": "dcr-client-1"
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example3:dcr23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    },
    {
      "id": "dcr-reissued-client-same-key",
      "input": {
        "namespace": "account",
        "backend_id": "backend",
        "purpose": "event",
        "destination": "https://api.example/hooks",
        "issuer": "https://issuer.example",
        "resource": "https://api.example",
        "client_identity": "dcr",
        "flow": "authorization_code_pkce",
        "allowed_scopes": [
          "read",
          "offline_access"
        ],
        "issued_client_id": "dcr-client-2"
      },
      "binding_key": "ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks",
      "grant_key": "ahp.oauth.grant:7:account22:https://issuer.example19:https://api.example3:dcr23:authorization_code_pkce79:binding:ahp.oauth.binding:7:account7:backend5:event25:https://api.example/hooks"
    }
  ],
  "token_responses": [
    {
      "id": "unknown-expiry",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "known-expiry",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "expires_in": 3600
      },
      "accepted": true,
      "expiry": "known",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "allowed-added-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "offline_access"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read offline_access"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read",
        "offline_access"
      ],
      "refresh_preserved": true
    },
    {
      "id": "narrowed-scope",
      "requested": [
        "read",
        "write"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "required-scope-missing",
      "requested": [
        "read",
        "write"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [
        "write"
      ],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": false,
      "granted": [
        "read"
      ],
      "error": "access_denied",
      "refresh_preserved": true,
      "error_scopes": [
        "write"
      ]
    },
    {
      "id": "unallowed-added-scope-ignored",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read openid admin"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-inherits-narrowed-grant",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-preserves-allowed-extra-scope",
      "exchange": "refresh",
      "requested": [
        "read"
      ],
      "previous_granted": [
        "read",
        "offline_access"
      ],
      "allowed": [
        "read",
        "offline_access"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read",
        "offline_access"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-broadening-scope-ignored",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": "read write"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "invalid-token-type",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "refresh_token": "fixture-refresh-rotated",
        "token_type": "mac"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "zero-expires-in",
      "exchange": "refresh",
      "requested": [
        "read"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "refresh_token": "fixture-refresh-rotated",
        "token_type": "Bearer",
        "expires_in": 0
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": true
    },
    {
      "id": "initial-without-refresh-token",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "expires_in": 3600
      },
      "accepted": true,
      "expiry": "known",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": false
    },
    {
      "id": "string-expires-in",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "expires_in": "3600"
      },
      "accepted": true,
      "expiry": "known",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "fractional-expires-in",
      "requested": [
        "read"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "expires_in": 3600.5
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "refresh-narrow-ceiling-keeps-grant",
      "exchange": "refresh",
      "requested": [
        "read"
      ],
      "previous_granted": [
        "read",
        "write"
      ],
      "allowed": [
        "read"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read",
        "write"
      ],
      "effective": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "step-up-keeps-previous-grant",
      "exchange": "reacquire",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "files",
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [
        "write"
      ],
      "wire_request": [
        "files",
        "read",
        "write"
      ],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "files read write openid"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "files",
        "read",
        "write"
      ],
      "effective": [
        "read",
        "write"
      ],
      "refresh_preserved": true
    },
    {
      "id": "initial-empty-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": ""
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "initial-whitespace-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": " \t "
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "initial-null-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": null
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "initial-numeric-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": 123
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "initial-array-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": [
          "read"
        ]
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "refresh-empty-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": ""
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-whitespace-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": " \t "
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-null-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": null
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-numeric-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": 123
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": true
    },
    {
      "id": "refresh-array-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": [
          "read"
        ]
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": true
    },
    {
      "id": "initial-repeated-separator-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read  write"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "initial-leading-separator-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": " read"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "initial-tab-separator-scope",
      "requested": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read\twrite"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": false
    },
    {
      "id": "refresh-repeated-separator-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": "read  write"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": true
    },
    {
      "id": "refresh-leading-separator-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": " read"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": true
    },
    {
      "id": "refresh-tab-separator-scope",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": "read\twrite"
      },
      "accepted": false,
      "usable": false,
      "error": "provider_failed",
      "refresh_preserved": true
    },
    {
      "id": "preset-scope-not-granted-usable",
      "requested": [
        "files",
        "read"
      ],
      "allowed": [
        "files",
        "read"
      ],
      "required": [
        "read"
      ],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh",
        "scope": "read"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": true,
      "granted": [
        "read"
      ],
      "refresh_preserved": true
    },
    {
      "id": "refresh-narrower-than-required",
      "exchange": "refresh",
      "requested": [
        "read",
        "write"
      ],
      "previous_granted": [
        "read",
        "write"
      ],
      "allowed": [
        "read",
        "write"
      ],
      "required": [
        "read",
        "write"
      ],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "refresh_token": "fixture-refresh-rotated",
        "scope": "read"
      },
      "accepted": true,
      "expiry": "unknown",
      "usable": false,
      "granted": [
        "read"
      ],
      "error": "access_denied",
      "error_scopes": [
        "read",
        "write"
      ],
      "refresh_preserved": true
    },
    {
      "id": "client-credentials-narrower-than-required",
      "requested": [
        "files",
        "read",
        "write"
      ],
      "allowed": [
        "files",
        "read",
        "write"
      ],
      "required": [
        "write",
        "read"
      ],
      "response": {
        "access_token": "fixture-access",
        "token_type": "Bearer",
        "expires_in": 3600,
        "scope": "files read"
      },
      "accepted": true,
      "expiry": "known",
      "usable": false,
      "granted": [
        "files",
        "read"
      ],
      "error": "access_denied",
      "error_scopes": [
        "read",
        "write"
      ],
      "refresh_preserved": false
    }
  ],
  "scope_decisions": [
    {
      "id": "preset-scopes-requested-not-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "cached",
        "binding": "preset",
        "requested": [
          "files",
          "read"
        ],
        "preset_scopes": [
          "files",
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "preset-scopes-not-in-error-set",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "preset",
        "requested": [
          "files",
          "read"
        ],
        "preset_scopes": [
          "files",
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": null
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "read"
        ],
        "required": [
          "read"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "preset-scopes-omitted-no-constraint",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "cached",
        "binding": "preset",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "preset-scopes-differ-from-client-invalid-configuration",
      "input": {
        "flow": "client_credentials",
        "path": "credential",
        "binding": "preset",
        "requested": [
          "read"
        ],
        "preset_scopes": [
          "files"
        ],
        "host_required": [],
        "explicit": [],
        "grant": null
      },
      "expect": {
        "code": "invalid_configuration",
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "step-up-carries-full-required-set",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "read",
          "write"
        ],
        "required": [
          "read",
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "prepare-explicit-and-host-required-union",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "stored",
        "requested": [
          "files",
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [
          "files"
        ],
        "grant": null
      },
      "expect": {
        "code": null,
        "action": "login",
        "required": [
          "files",
          "read"
        ],
        "acquisition_scopes": [
          "files",
          "read",
          "write"
        ]
      }
    },
    {
      "id": "client-credentials-step-up-acquires",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": null,
        "action": "acquire",
        "required": [
          "write"
        ],
        "acquisition_scopes": [
          "read",
          "write"
        ]
      }
    },
    {
      "id": "stored-grant-lacking-required-interaction-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "write"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "ceiling-refusal-fresh",
      "input": {
        "flow": "client_credentials",
        "path": "fresh",
        "binding": "unbound",
        "client_source": "preregistered",
        "requested": [
          "read"
        ],
        "host_required": [
          "admin"
        ],
        "explicit": [],
        "grant": null,
        "sent": null,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        }
      },
      "expect": {
        "retired": false,
        "code": "access_denied",
        "authorization_server_requests": 0,
        "network_calls_max": 1,
        "scopes": [
          "admin"
        ],
        "required": [
          "admin"
        ]
      }
    },
    {
      "id": "unbound-unparseable-challenge-denied",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "fresh",
        "binding": "unbound",
        "client_source": "preregistered",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": null,
        "sent": null,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer scope"
        }
      },
      "expect": {
        "retired": false,
        "code": "access_denied",
        "authorization_server_requests": 0,
        "network_calls_max": 2,
        "scopes": []
      }
    },
    {
      "id": "unbound-preregistered-pkce-interaction-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "fresh",
        "binding": "unbound",
        "client_source": "preregistered",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": null,
        "sent": null,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        }
      },
      "expect": {
        "retired": false,
        "code": "interaction_required",
        "scopes": [
          "read"
        ],
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls_max": 1
      }
    },
    {
      "id": "unbound-usable-grant-uses",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "fresh",
        "binding": "unbound",
        "client_source": "preregistered",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": null,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        }
      },
      "expect": {
        "retired": false,
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls_max": 1
      }
    },
    {
      "id": "prepare-unbound-usable-grant-uses",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "unbound",
        "client_source": "preregistered",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls_max": 2
      }
    },
    {
      "id": "ceiling-refusal-fresh-preset",
      "input": {
        "flow": "client_credentials",
        "path": "fresh",
        "binding": "preset",
        "requested": [
          "read"
        ],
        "preset_scopes": [
          "read"
        ],
        "host_required": [
          "admin"
        ],
        "explicit": [],
        "grant": null
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "admin"
        ],
        "required": [
          "admin"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "ceiling-refusal-cached",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "cached",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read",
          "admin"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "admin",
          "read"
        ],
        "required": [
          "admin",
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "ceiling-refusal-prepare",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [
          "admin"
        ],
        "grant": null
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "admin"
        ],
        "required": [
          "admin"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "ceiling-refusal-credential",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "admin"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "admin"
        ],
        "required": [
          "admin"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "ceiling-refusal-preemptive",
      "input": {
        "flow": "client_credentials",
        "path": "preemptive",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "admin"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "admin"
        ],
        "required": [
          "admin"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "ceiling-refusal-challenge",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"admin\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "admin",
          "read"
        ],
        "required": [
          "admin",
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "ceiling-refusal-401-retires-first",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "admin"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        }
      },
      "expect": {
        "retired": true,
        "code": "access_denied",
        "scopes": [
          "admin"
        ],
        "required": [
          "admin"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "requested-outside-ceiling-invalid-configuration",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "stored",
        "requested": [
          "read",
          "admin"
        ],
        "ceiling": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": null
      },
      "expect": {
        "code": "invalid_configuration",
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "preset-outside-ceiling-invalid-configuration",
      "input": {
        "flow": "client_credentials",
        "path": "credential",
        "binding": "preset",
        "requested": [
          "files",
          "read"
        ],
        "ceiling": [
          "read"
        ],
        "preset_scopes": [
          "files",
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": null
      },
      "expect": {
        "code": "invalid_configuration",
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "invalid-host-required-token-invalid-configuration",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "r\u00e9ad"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": "invalid_configuration",
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "challenge-401-scope-added-to-request",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer scope=\"write admin\""
        }
      },
      "expect": {
        "retired": true,
        "code": null,
        "action": "acquire",
        "required": [],
        "acquisition_scopes": [
          "read",
          "write"
        ]
      }
    },
    {
      "id": "challenge-401-scope-not-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer error=\"invalid_token\", scope=\"write\""
        }
      },
      "expect": {
        "retired": true,
        "code": "interaction_required",
        "scopes": [
          "read"
        ],
        "required": [
          "read"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "challenge-401-scope-outside-ceiling-not-denied",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer scope=admin"
        }
      },
      "expect": {
        "retired": true,
        "code": "interaction_required",
        "scopes": [],
        "required": [],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "challenge-401-hint-not-used-by-later-operation",
      "input": {
        "flow": "client_credentials",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "expired",
          "refresh": false
        },
        "prior_401_hint": [
          "write"
        ]
      },
      "expect": {
        "code": null,
        "action": "acquire",
        "required": [],
        "acquisition_scopes": [
          "read"
        ]
      }
    },
    {
      "id": "challenge-401-insufficient-scope-error-is-401",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "retired": true,
        "code": "interaction_required",
        "scopes": [
          "read"
        ],
        "required": [
          "read"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "challenge-401-older-generation-uses-current",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 2,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        }
      },
      "expect": {
        "retired": false,
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "insufficient-scope-without-scope-uses-host-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "write"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\""
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "insufficient-scope-without-scope-or-requirement-denied",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "challenge-403-other-denied",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"invalid_token\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-empty",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-repeated-space",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"read  write\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-leading-space",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\" read\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-trailing-space",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"read \""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-tab-separator",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"read\twrite\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-invalid-character",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"r\u00e9ad\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-duplicated-parameter",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"read\", scope=\"write\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-two-bearer-challenges",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"read\", Bearer scope=\"write\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "malformed-challenge-scope-bad-auth-param",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"read"
        }
      },
      "expect": {
        "code": "access_denied",
        "authorization_server_requests": 0,
        "network_calls": 0,
        "scopes": []
      }
    },
    {
      "id": "challenge-bare-name-after-comma-is-new-scheme",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "write"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope"
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "malformed-challenge-bearer-token68",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer abc=="
        }
      },
      "expect": {
        "retired": true,
        "code": "access_denied",
        "authorization_server_requests": 0,
        "network_calls": 0,
        "scopes": []
      }
    },
    {
      "id": "challenge-non-bearer-token68-skipped",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Basic YWxhZGRpbjpvcGVuc2VzYW1l, Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "malformed-challenge-scope-401",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer scope=\"read  write\""
        }
      },
      "expect": {
        "retired": true,
        "code": "access_denied",
        "scopes": [],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "challenge-401-invalid-configuration-retires-first",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "admin"
        ],
        "ceiling": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer scope=\"read\""
        }
      },
      "expect": {
        "retired": true,
        "code": "invalid_configuration",
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "challenge-401-unsupported-binding-retires-first",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        },
        "target_error": {
          "check": "unsupported_binding",
          "code": "unsupported_binding"
        }
      },
      "expect": {
        "retired": true,
        "code": "unsupported_binding"
      }
    },
    {
      "id": "challenge-401-host-callback-failure-retires-first",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 401,
          "www_authenticate": "Bearer resource_metadata=\"https://api.example/.well-known/oauth-protected-resource\""
        },
        "host_error": {
          "callback": "client_selection",
          "code": "credential_unavailable",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "retired": true,
        "code": "credential_unavailable"
      }
    },
    {
      "id": "insufficient-scope-already-granted-denied",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read",
            "write"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "read",
          "write"
        ],
        "required": [
          "read",
          "write"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "insufficient-scope-already-granted-client-credentials",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read",
            "write"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "insufficient-scope-newer-generation-uses-current",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 2,
          "granted": [
            "read",
            "write"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "write"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "insufficient-scope-anonymous-grant-covers-denied",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read",
            "write"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": null,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "expired-token-refreshes",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read",
            "write"
          ],
          "token": "expired",
          "refresh": true
        }
      },
      "expect": {
        "code": null,
        "action": "refresh",
        "required": [
          "read"
        ]
      }
    },
    {
      "id": "expired-token-refresh-cannot-cover-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "write"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "expired",
          "refresh": true
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "stored-without-metadata-use",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored_without_metadata",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "stored-without-metadata-interaction-required",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored_without_metadata",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [
          "write"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "expired",
          "refresh": false
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [
          "write"
        ],
        "required": [
          "write"
        ],
        "authorization_server_requests": 0
      }
    },
    {
      "id": "prepare-stored-without-metadata-serves-cached-token",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "stored_without_metadata",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        }
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "prepare-forced-reregistration-acquires",
      "input": {
        "flow": "client_credentials",
        "path": "prepare",
        "binding": "stored",
        "client_source": "dcr",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "force_registration": true
      },
      "expect": {
        "code": null,
        "action": "acquire",
        "required": [
          "read"
        ],
        "acquisition_scopes": [
          "read"
        ],
        "authorization_server_requests_min": 1
      }
    },
    {
      "id": "prepare-forced-registration-pkce-keeps-usable-token",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "stored",
        "client_source": "dcr",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "force_registration": true
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "prepare-forced-registration-preregistered-keeps-usable-token",
      "input": {
        "flow": "client_credentials",
        "path": "prepare",
        "binding": "stored",
        "client_source": "preregistered",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "force_registration": true
      },
      "expect": {
        "code": null,
        "action": "use",
        "required": [
          "read"
        ],
        "authorization_server_requests": 0,
        "network_calls": 0
      }
    },
    {
      "id": "client-credentials-with-refresh-token-reissues",
      "input": {
        "flow": "client_credentials",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "expired",
          "refresh": true
        }
      },
      "expect": {
        "code": null,
        "action": "acquire",
        "required": [
          "read"
        ],
        "acquisition_scopes": [
          "read"
        ]
      }
    },
    {
      "id": "host-policy-access-denied-scopes-stripped",
      "requires": [
        "token_validation_callback"
      ],
      "input": {
        "flow": "authorization_code_pkce",
        "path": "credential",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "host_error": {
          "callback": "token_validation",
          "code": "access_denied",
          "scopes": [
            "admin"
          ]
        }
      },
      "expect": {
        "code": "access_denied",
        "scopes": []
      }
    },
    {
      "id": "host-policy-interaction-required-scopes-stripped",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "prepare",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": null,
        "host_error": {
          "callback": "client_selection",
          "code": "interaction_required",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "code": "interaction_required",
        "scopes": []
      }
    },
    {
      "id": "host-policy-registration-destination-scopes-stripped",
      "input": {
        "flow": "client_credentials",
        "path": "prepare",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": null,
        "host_error": {
          "callback": "destination",
          "target": "registration_endpoint",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "code": "untrusted_destination"
      }
    },
    {
      "id": "host-policy-issuer-metadata-destination-refused",
      "input": {
        "flow": "client_credentials",
        "path": "prepare",
        "binding": "stored",
        "requested": [
          "read"
        ],
        "host_required": [
          "read"
        ],
        "explicit": [],
        "grant": null,
        "host_error": {
          "callback": "destination",
          "target": "issuer_metadata",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "code": "untrusted_destination"
      }
    },
    {
      "id": "host-policy-issuer-metadata-destination-refused-challenge",
      "input": {
        "flow": "client_credentials",
        "path": "challenge",
        "binding": "stored_without_metadata",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        },
        "host_error": {
          "callback": "destination",
          "target": "issuer_metadata",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "code": "untrusted_destination"
      }
    },
    {
      "id": "host-policy-client-selection-refuses-challenged-target",
      "input": {
        "flow": "authorization_code_pkce",
        "path": "challenge",
        "binding": "stored",
        "requested": [
          "read",
          "write"
        ],
        "host_required": [],
        "explicit": [],
        "grant": {
          "generation": 1,
          "granted": [
            "read",
            "write"
          ],
          "token": "valid",
          "refresh": false
        },
        "sent": 1,
        "challenge": {
          "status": 403,
          "www_authenticate": "Bearer error=\"insufficient_scope\", scope=\"write\""
        },
        "host_error": {
          "callback": "client_selection",
          "code": "credential_unavailable",
          "scopes": [
            "write"
          ]
        }
      },
      "expect": {
        "code": "credential_unavailable"
      }
    }
  ],
  "completions": [
    {
      "id": "complete-covers-stored-required",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": null,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-requested-scope-not-required",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read"
        ],
        "granted": [
          "read"
        ],
        "ceiling": [
          "files",
          "read"
        ]
      },
      "expect": {
        "code": null,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-with-server-added-params",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid_with_server_params",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": null,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-narrower-than-stored-required",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "read",
          "write"
        ],
        "login_ended": true,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-current-ceiling-hides-stored-required",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "read",
          "write"
        ],
        "login_ended": true,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-legacy-record-prepare-time-host-required",
      "requires": [
        "legacy_prepare_time_host_required"
      ],
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": null,
        "prepare_time_host_required": [
          "write"
        ],
        "current_host_required": [
          "read"
        ],
        "granted": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "write"
        ],
        "login_ended": true,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-legacy-record-current-host-required",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": null,
        "current_host_required": [
          "write"
        ],
        "granted": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [
          "write"
        ],
        "login_ended": true,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-legacy-record-empty-prepare-time-host-required",
      "requires": [
        "legacy_prepare_time_host_required"
      ],
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": null,
        "prepare_time_host_required": [],
        "current_host_required": [
          "write"
        ],
        "granted": [
          "read"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": null,
        "grant_persisted": true
      }
    },
    {
      "id": "complete-invalid-callback-redirect-mismatch",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "redirect_mismatch",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-redirect-query-mismatch",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "redirect_query_mismatch",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-state-duplicated",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "state_duplicated",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-iss-mismatch",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "iss_mismatch",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-fragment",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "fragment",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-userinfo",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "userinfo",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-missing-code",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "missing_code",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-code-and-error",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "code_and_error",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-duplicate-param",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "duplicate_param",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-callback-unparseable",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "unparseable",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-handle-names-other-login",
      "requires": [
        "complete_handle"
      ],
      "input": {
        "pending": "pending",
        "handle": "other",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-host-client-selection-failure-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "host_error": {
          "callback": "client_selection",
          "code": "access_denied",
          "scopes": [
            "admin"
          ]
        },
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-host-client-unavailable-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "host_error": {
          "callback": "client_selection",
          "code": "credential_unavailable",
          "scopes": [
            "read"
          ]
        },
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "credential_unavailable",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-client-source-not-permitted-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "dcr",
        "source_permitted": false,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "invalid_configuration",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-unknown-state-failing-host-callback",
      "input": {
        "pending": "unknown",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "host_error": {
          "callback": "client_selection",
          "code": "credential_unavailable",
          "scopes": []
        },
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-claim-uncertain-login-gone",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": {
          "outcome": "uncertain",
          "error_code": "provider_failed",
          "reread": "gone"
        },
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-claim-uncertain-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": {
          "outcome": "uncertain",
          "error_code": "provider_failed",
          "reread": "pending"
        },
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-claim-uncertain-undetermined",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": {
          "outcome": "uncertain",
          "error_code": "provider_failed",
          "reread": "undetermined"
        },
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-consent-denied-source-not-permitted-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "dcr",
        "source_permitted": false,
        "callback": "denied",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "invalid_configuration",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-consent-denied-client-selection-failure-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "denied",
        "host_error": {
          "callback": "client_selection",
          "code": "credential_unavailable",
          "scopes": [
            "read"
          ]
        },
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "credential_unavailable",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-endpoint-destination-refused-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "host_error": {
          "callback": "destination",
          "target": "token_endpoint",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        },
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "untrusted_destination",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-consent-denied-destination-refused-login-pending",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "denied",
        "host_error": {
          "callback": "destination",
          "target": "token_endpoint",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        },
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "untrusted_destination",
        "login_ended": false,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-consent-denied-login-ended",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "denied",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-consent-denied-invalid-client-preregistered",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "denied_invalid_client",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "access_denied",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-consent-denied-invalid-client-cimd",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "cimd",
        "source_permitted": true,
        "callback": "denied_invalid_client",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "invalid_configuration",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-expired-login-ended",
      "input": {
        "pending": "expired",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-ended-login-callback",
      "input": {
        "pending": "ended",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-unknown-state-with-handle",
      "requires": [
        "complete_handle"
      ],
      "input": {
        "pending": "unknown",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-unknown-state-without-handle",
      "input": {
        "pending": "unknown",
        "handle": "none",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-missing-state-login-ended",
      "input": {
        "pending": "absent",
        "handle": "none",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "ok",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-grant-login-ended",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "invalid_grant",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-client-preregistered",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "invalid_client",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "credential_unavailable",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-client-cimd",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "cimd",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "invalid_client",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "invalid_configuration",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-client-dcr",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "dcr",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "invalid_client",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "interaction_required",
        "scopes": [],
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-error-unauthorized-client-provider-failed",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "unauthorized_client",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-error-access-denied-provider-failed",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "access_denied",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-error-invalid-scope-provider-failed",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "invalid_scope",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-endpoint-failure-login-ended",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "server_error",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-endpoint-unreachable",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "unreachable",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-token-endpoint-not-found",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "not_found",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    },
    {
      "id": "complete-invalid-token-response-login-ended",
      "input": {
        "pending": "pending",
        "handle": "matching",
        "client_source": "preregistered",
        "source_permitted": true,
        "callback": "valid",
        "claim": "ok",
        "exchange": "invalid_response",
        "stored_required": [
          "read",
          "write"
        ],
        "granted": [
          "read",
          "write"
        ],
        "ceiling": [
          "read",
          "write"
        ]
      },
      "expect": {
        "code": "provider_failed",
        "login_ended": true,
        "grant_persisted": false
      }
    }
  ],
  "token_errors": [
    {
      "id": "refresh-preregistered-invalid-grant",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "invalid_grant"
      },
      "expect": {
        "code": "refresh_rejected"
      }
    },
    {
      "id": "refresh-preregistered-unauthorized-client",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "unauthorized_client"
      },
      "expect": {
        "code": "credential_unavailable"
      }
    },
    {
      "id": "refresh-preregistered-invalid-client",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "invalid_client"
      },
      "expect": {
        "code": "credential_unavailable"
      }
    },
    {
      "id": "refresh-cimd-invalid-client",
      "input": {
        "grant_type": "refresh",
        "client_source": "cimd",
        "error": "invalid_client"
      },
      "expect": {
        "code": "invalid_configuration"
      }
    },
    {
      "id": "refresh-dcr-invalid-client",
      "input": {
        "grant_type": "refresh",
        "client_source": "dcr",
        "error": "invalid_client"
      },
      "expect": {
        "code": "interaction_required"
      }
    },
    {
      "id": "refresh-preregistered-access-denied",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "access_denied"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "refresh-preregistered-invalid-scope",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "invalid_scope"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "refresh-preregistered-server-error",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "server_error"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "refresh-preregistered-unreachable",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "unreachable"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "refresh-unreachable-refetch-destination-refused",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "unreachable",
        "refetch": {
          "callback": "destination",
          "target": "issuer_metadata",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "code": "untrusted_destination"
      }
    },
    {
      "id": "refresh-not-found-refetch-failed",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "not_found",
        "refetch": "failed"
      },
      "expect": {
        "code": "discovery_failed"
      }
    },
    {
      "id": "refresh-preregistered-not-found",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "not_found"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "refresh-preregistered-invalid-response",
      "input": {
        "grant_type": "refresh",
        "client_source": "preregistered",
        "error": "invalid_response"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "client-credentials-preregistered-invalid-grant",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "invalid_grant"
      },
      "expect": {
        "code": "credential_unavailable"
      }
    },
    {
      "id": "client-credentials-preregistered-unauthorized-client",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "unauthorized_client"
      },
      "expect": {
        "code": "credential_unavailable"
      }
    },
    {
      "id": "client-credentials-preregistered-invalid-client",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "invalid_client"
      },
      "expect": {
        "code": "credential_unavailable"
      }
    },
    {
      "id": "client-credentials-dcr-invalid-client",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "dcr",
        "error": "invalid_client"
      },
      "expect": {
        "code": "credential_unavailable",
        "reregistrations": 1
      }
    },
    {
      "id": "client-credentials-preregistered-access-denied",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "access_denied"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "client-credentials-preregistered-invalid-scope",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "invalid_scope"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "client-credentials-preregistered-server-error",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "server_error"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "client-credentials-preregistered-unreachable",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "unreachable"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "client-credentials-unreachable-refetch-destination-refused",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "unreachable",
        "refetch": {
          "callback": "destination",
          "target": "issuer_metadata",
          "code": "untrusted_destination",
          "scopes": [
            "read"
          ]
        }
      },
      "expect": {
        "code": "untrusted_destination"
      }
    },
    {
      "id": "client-credentials-preregistered-not-found",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "not_found"
      },
      "expect": {
        "code": "provider_failed"
      }
    },
    {
      "id": "client-credentials-preregistered-invalid-response",
      "input": {
        "grant_type": "client_credentials",
        "client_source": "preregistered",
        "error": "invalid_response"
      },
      "expect": {
        "code": "provider_failed"
      }
    }
  ],
  "lifecycle": [
    {
      "id": "cached-token-metadata-outage",
      "expect": "valid stored grant works without metadata HTTP, including a recreated provider"
    },
    {
      "id": "unbound-preemptive-unsafe-delivery",
      "expect": "known authorized binding sends stored token on first attempt; no 401/replay for upload or notification"
    },
    {
      "id": "unreplayed-challenge-prepares-next-attempt",
      "expect": "401/insufficient_scope on a notification or upload is not replayed but runs challenge handling (discovery, client-credentials acquisition, no login creation); the next operation sends a credential"
    },
    {
      "id": "challenge-renews-rejected-unexpired-token",
      "expect": "401 for a stored token with unknown or future expiry retires it before any other decision and renews it, so the next operation does not resend the rejected token"
    },
    {
      "id": "unbound-lookup-anonymous-fallback",
      "expect": "up-front lookup never creates a pending login or performs protected-resource discovery; only a store miss or host policy refusal sends an anonymous attempt"
    },
    {
      "id": "unbound-lookup-refreshes-expired-token",
      "expect": "up-front lookup refreshes an expired stored token non-interactively using cached authorization-server metadata"
    },
    {
      "id": "up-front-client-credentials-reacquire",
      "expect": "expired client-credentials token without refresh token is re-acquired non-interactively by the up-front lookup using persisted metadata"
    },
    {
      "id": "up-front-lookup-issuer-metadata-only",
      "expect": "binding record lacking persisted authorization-server metadata fetches only the stored issuer's metadata, never protected-resource metadata; failure is discovery_failed"
    },
    {
      "id": "stale-metadata-refetch-once",
      "expect": "renewal failing before the token endpoint processed it (DNS, TCP connect, TLS handshake, token-endpoint 404/410) refetches the stored issuer's metadata once, persists it if the issuer is unchanged and retries once; changed issuer or failed refetch is discovery_failed"
    },
    {
      "id": "ambiguous-renewal-failure-no-refetch",
      "expect": "read timeout, reset after send, 5xx, non-OAuth body or OAuth error during renewal returns its error (provider_failed/retry for ambiguous failures) with no metadata refetch and no immediate retry; the presented refresh token is not replayed"
    },
    {
      "id": "up-front-refresh-failure-no-anonymous-fallback",
      "expect": "known binding whose non-interactive refresh fails (transient, invalid_grant, missing cached metadata) fails the operation with that error, never sends anonymously"
    },
    {
      "id": "known-binding-without-token-requires-login",
      "expect": "known PKCE binding whose tokens were dropped fails interaction_required at lookup; a later prepare restores it"
    },
    {
      "id": "refresh-unknown-expiry-rotation",
      "expect": "rotated refresh credential persisted and reusable when expires_in absent"
    },
    {
      "id": "transient-refresh-failure",
      "expect": "5xx/non-OAuth/timeout retains credentials and returns retry, never permanent fabricated login state"
    },
    {
      "id": "refresh-invalid-grant-drops-tokens",
      "expect": "definitive interactive refresh invalid_grant removes access and refresh tokens when the record still holds the presented refresh token, and returns refresh_rejected"
    },
    {
      "id": "refresh-invalid-grant-stale-does-not-wipe",
      "expect": "invalid_grant for a refresh token already replaced by a newer record leaves the newer record intact"
    },
    {
      "id": "token-validation-failure-clears-in-flight",
      "expect": "invalid code-exchange response persists nothing; invalid refresh response persists only a valid rotated refresh token; no in-flight/refreshing state remains; returns provider_failed"
    },
    {
      "id": "client-credentials-transient-reissue",
      "expect": "retry can acquire with current client credentials without any human-login outcome"
    },
    {
      "id": "delivery-never-creates-pending-login",
      "expect": "delivery/credential/challenge paths return interaction_required without creating a pending login; only explicit prepare creates one"
    },
    {
      "id": "pending-login-fixed-lifetime",
      "expect": "pending login lifetime is host-configured and bounded (default 10 minutes), fixed at creation and survives the creating prepare's deadline or cancellation"
    },
    {
      "id": "pending-login-owned-by-creating-process",
      "expect": "by default a pending login lives in the creating process, which receives its callback on its own listener and completes it by state"
    },
    {
      "id": "pending-login-persisted-cross-process-completion",
      "expect": "when the host opts to persist pending logins, another process sharing the store completes one by state (paste flow); the PKCE verifier stays only in the pending record, never in metadata or logs"
    },
    {
      "id": "pending-logins-concurrent-per-state",
      "expect": "two prepares for one grant key create two pending logins keyed by state, each with its own redirect and client; each callback completes only its own login"
    },
    {
      "id": "pending-logins-capped-per-grant-key",
      "expect": "a pending login beyond the host-configurable cap (default 5) for one grant key, per process or per store when persisted, cancels the oldest, atomically in a persisted store; expired pending logins are deleted"
    },
    {
      "id": "pending-completion-newest-grant-wins",
      "expect": "completing one pending login leaves the others valid; each completion replaces the grant's client and tokens, so the newest completed login wins"
    },
    {
      "id": "pending-login-end-states",
      "expect": "a pending login ends exactly once by completion, cancel (including by the cap) or expiry; later callbacks for it fail interaction_required"
    },
    {
      "id": "metadata-and-secret-rotation",
      "expect": "nonidentity metadata, token-endpoint auth method and runtime secret changes do not permanently fail stored session or persist secret"
    },
    {
      "id": "scope-ceiling-widening-keeps-grant",
      "expect": "widening the allowed ceiling finds the existing grant; effective scopes are granted scopes intersected with the current ceiling at use"
    },
    {
      "id": "scope-ceiling-narrowing-keeps-grant",
      "expect": "narrowing the ceiling hides scopes at use only; after a refresh under the narrow ceiling and widening it again the scope is still available"
    },
    {
      "id": "insufficient-scope-step-up",
      "expect": "only a Bearer 403 insufficient_scope creates a step-up requirement (Ch) for the challenged operation; a 401 or any other 403 never does"
    },
    {
      "id": "step-up-requirement-operation-scoped",
      "expect": "a challenge requirement is not persisted on the binding; later operations use the stored grant, including scopes added by step-up consent"
    },
    {
      "id": "step-up-keeps-previous-grant",
      "expect": "step-up or re-acquisition requests previously granted plus new ceiling-filtered scopes and records response scopes within previously granted plus acquisition ceiling; earlier scopes are not lost"
    },
    {
      "id": "step-up-required-scopes-round-trip",
      "expect": "interaction_required carries the full required set R = H \u222a E \u222a Ch, deduplicated and byte-sorted; the host passes it to prepare as explicit required scopes and consent includes them; every scoped access_denied also carries R"
    },
    {
      "id": "prepare-required-outside-ceiling-denied",
      "expect": "prepare with explicit required scopes outside the caller's ceiling fails access_denied carrying R before any network I/O"
    },
    {
      "id": "challenged-replay-once",
      "expect": "401 or Bearer 403 insufficient_scope on hooks/intercept, hooks/configuration or hooks/capabilities replays once with the same request id and body; second rejection fails"
    },
    {
      "id": "configured-preset-no-protected-resource-metadata",
      "expect": "explicit trusted preset uses issuer metadata and does not require PRM"
    },
    {
      "id": "explicit-shared-grant",
      "expect": "independently approved event/upload bindings share consent only with same explicit grant partition"
    },
    {
      "id": "invalid-callback-does-not-consume",
      "expect": "an invalid or unparseable callback (redirect or its own query, state, iss, fragment, userinfo, missing code, both code and error, duplicated parameter) fails access_denied with login_ended false and does not consume the login; authorization-server-added parameters such as session_state are accepted"
    },
    {
      "id": "loopback-redirect",
      "expect": "literal IPv4/IPv6 loopback HTTP redirect accepted; remote HTTP rejected"
    },
    {
      "id": "loopback-redirect-ephemeral-port-per-login",
      "expect": "each login may bind a new loopback port; authorization, DCR and token requests and callback validation use that login's exact redirect including the port"
    },
    {
      "id": "cimd-portless-loopback-redirect-matches",
      "expect": "a host-declared CIMD redirect_uris entry without a port, or with another port, matches a loopback http redirect without userinfo on any port; localhost is never accepted"
    },
    {
      "id": "narrowed-refresh-scope-inheritance",
      "expect": "initial request read+write grants read; refresh with no scope stays read and cannot fabricate write"
    },
    {
      "id": "scope-challenge-without-required-scope",
      "expect": "insufficient_scope without scope uses H \u222a E when non-empty, otherwise fails access_denied with no scopes; it never invents permissions"
    },
    {
      "id": "refresh-broadening-scope-ignored",
      "expect": "initial read+write request grants read; refresh response scoped read write records read only, persists rotated refresh and stays usable; a write-requiring operation fails access_denied"
    },
    {
      "id": "extra-granted-scope-ignored",
      "expect": "response scopes outside the allowed ceiling (e.g. openid, offline_access) are dropped from the recorded grant, not an error"
    },
    {
      "id": "registration-order-preregistered-cimd-dcr",
      "expect": "with every source available the SDK selects a pre-registered client, else CIMD (PKCE, client_id_metadata_document_supported true), else permitted DCR with registration_endpoint, else credential_unavailable"
    },
    {
      "id": "dcr-preregistered-wins",
      "expect": "a host-supplied pre-registered client is used even when CIMD and DCR are available; adding one later makes a recorded CIMD/DCR selection obsolete, selecting a new grant key whose old tokens are never presented under the new client"
    },
    {
      "id": "cimd-used-when-supported",
      "expect": "PKCE with a configured CIMD URL and client_id_metadata_document_supported true sends the URL as client_id with no client secret, token auth none and no stored registration record"
    },
    {
      "id": "cimd-not-supported-falls-back-to-dcr",
      "expect": "absent or non-true client_id_metadata_document_supported skips CIMD and uses permitted DCR"
    },
    {
      "id": "cimd-redirect-mismatch-invalid-configuration",
      "expect": "a redirect matching no host-declared CIMD redirect_uris entry (loopback compared without port) fails invalid_configuration before any pending login"
    },
    {
      "id": "cimd-never-fetched-by-sdk",
      "expect": "no SDK network request targets the CIMD URL or a URL derived from it"
    },
    {
      "id": "cimd-client-credentials-not-used",
      "expect": "client_credentials never uses CIMD; it uses a pre-registered client or DCR with a secret-based method"
    },
    {
      "id": "cimd-invalid-client-no-dcr-fallback",
      "expect": "invalid_client for a CIMD client is invalid_configuration and never triggers DCR for that operation"
    },
    {
      "id": "dcr-policy-disallows-registration",
      "expect": "registration_endpoint advertised but host policy does not permit the exact issuer: no registration request; credential_unavailable"
    },
    {
      "id": "dcr-registration-endpoint-destination-policy",
      "expect": "non-HTTPS, destination-policy-refused or redirecting registration endpoint sends no further request and fails untrusted_destination"
    },
    {
      "id": "dcr-pkce-registers-per-login",
      "expect": "only host prepare registers a PKCE client, inside the prepare that creates the pending login, with that login's exact redirect and application_type native for loopback; each new login registers anew; lookup and delivery never register"
    },
    {
      "id": "dcr-issued-client-stored-with-grant",
      "expect": "completion commits the issued client_id with the tokens into the grant record under the dcr client identity; a re-registered client replaces it without changing the grant key; refresh uses the stored client"
    },
    {
      "id": "dcr-pkce-invalid-client-drops-grant",
      "expect": "invalid_client at PKCE completion ends only that pending login (the stored grant is kept); at refresh it returns interaction_required and compare-and-deletes the grant only if it still holds the presented client_id and refresh token"
    },
    {
      "id": "dcr-registers-once-across-processes",
      "expect": "client-credentials registration: concurrent processes register once under the registration-key lock; a compare-and-set loser deletes its secret reference and uses the winner's record"
    },
    {
      "id": "dcr-registration-reused-across-grants",
      "expect": "a client-credentials registration record is reused by every client-credentials grant with the same namespace and issuer"
    },
    {
      "id": "dcr-expired-secret-reregisters",
      "expect": "a passed nonzero client_secret_expires_at or unresolvable secret reference makes the record unusable; client-credentials acquisition, including the up-front lookup, re-registers under coordination before any token-endpoint request"
    },
    {
      "id": "dcr-invalid-client-reregisters-once",
      "expect": "client credentials: token-endpoint invalid_client compare-and-deletes that registration generation, re-registers at most once and re-acquires once; a repeated invalid_client is credential_unavailable; no metadata refetch"
    },
    {
      "id": "dcr-secret-not-in-token-record",
      "expect": "the client secret is written only through the host secret-storage hook; registration, binding, grant and pending-login records and errors never contain it"
    },
    {
      "id": "dcr-no-secret-hook-no-confidential-registration",
      "expect": "without a host secret-storage hook a client-credentials DCR fails credential_unavailable with no registration request; PKCE DCR is unaffected"
    },
    {
      "id": "dcr-metadata-change-keeps-selection",
      "expect": "newly advertised CIMD support or a removed registration_endpoint does not move a working grant off its recorded client"
    },
    {
      "id": "dcr-management-fields-not-persisted",
      "expect": "registration_access_token and registration_client_uri are ignored, never persisted and never used"
    },
    {
      "id": "dcr-initial-access-token-scoped",
      "expect": "a host initial access token configured for one exact issuer is sent only to that issuer's registration endpoint, never to another issuer's, and never persisted"
    },
    {
      "id": "lookup-never-registers-pkce",
      "expect": "the up-front lookup never registers a PKCE client and returns interaction_required; for client credentials it may register when no usable record exists, subject to the backoff"
    },
    {
      "id": "dcr-response-validation-invalid-configuration",
      "expect": "a 2xx JSON registration response failing validation (secret for PKCE, replaced redirect, swapped auth method) persists nothing and returns invalid_configuration, not retry"
    },
    {
      "id": "dcr-replaced-secret-deleted",
      "expect": "after a registration record is replaced or compare-and-deleted, the old secret reference is deleted through the host hook once the compare-and-set succeeds; a losing compare-and-set deletes only its own fresh reference"
    },
    {
      "id": "registration-transient-failure-backs-off",
      "expect": "after a failed client-credentials registration, no registration request is sent for that key until the backoff (default 1 minute doubling, capped at 1 hour) passes, shared through a shared store; meanwhile the last failure's code is returned (provider_failed for retryable failures); host prepare bypasses it"
    },
    {
      "id": "registration-retry-after-honoured",
      "expect": "a registration response with Retry-After sets the next attempt no earlier than Retry-After and no earlier than the exponential backoff, capped at the host maximum"
    },
    {
      "id": "configuration-401-diagnostic-carries-auth-code",
      "expect": "discovery answered 401 with no usable grant skips the backend and emits a host-visible diagnostic {backendId, code configuration_unavailable, authError interaction_required, recovery login}; no credentials or bodies; cancellation emits no diagnostic and propagates"
    },
    {
      "id": "configuration-unavailable-retried-after-prepare",
      "expect": "after a successful host prepare for the skipped backend's event endpoint, the next event admission re-attempts discovery without waiting for backoff and admits the backend's routes"
    },
    {
      "id": "configuration-unavailable-backoff",
      "expect": "a configuration_unavailable skip with no authError, or with recovery retry, is re-attempted only at the first admission or initialize after backoff (30s, doubling, capped at 1h, host-configurable); earlier admissions do not contact the backend"
    },
    {
      "id": "configuration-auth-failure-not-retried-on-backoff",
      "expect": "a configuration_unavailable skip whose recovery is login, configure or none is not re-attempted when backoff elapses; only a successful host prepare for that backend's endpoint or reinitialization re-attempts it"
    },
    {
      "id": "configuration-invalid-not-retried",
      "expect": "configuration_invalid, no_applicable_subscriptions and configuration_local_secret skips are never re-attempted before reinitialization, even after prepare or backoff elapses"
    },
    {
      "id": "configuration-retry-atomic-routes",
      "expect": "a retry runs inside the single shared admission: concurrent callers observe old or complete new routes, never partial; events admitted before the retry succeeded are not replayed"
    },
    {
      "id": "preset-scopes-requested-not-required",
      "expect": "omitted preset scopes are no constraint; present ones must equal the client's configured scopes (else invalid_configuration); they are requested, never required, and never appear in R or any error's scope set unless host-required"
    },
    {
      "id": "ceiling-refusal-before-network-every-path",
      "expect": "R outside the ceiling, including a host-required scope, fails access_denied carrying R on every entry point; with a stored binding or explicit preset there is no network I/O; an unbound target (an anonymous request answered by 401) runs at most one protected-resource discovery (one request to a usable resource_metadata, else at most the path-specific and origin-root well-known locations) and no authorization-server request"
    },
    {
      "id": "requested-outside-ceiling-invalid-configuration",
      "expect": "configured requested scopes (and so a preset's scopes) outside the ceiling fail invalid_configuration as an SDK auth error, never a native exception, provider_failed or a silent drop"
    },
    {
      "id": "challenge-401-scope-requested-not-required",
      "expect": "a 401 retires the sent generation, if current, before every other decision step and whatever the outcome (including a malformed challenge); its in-ceiling scope hint is used only by a client-credentials acquisition in the same operation, never stored, never added to R and never yields access_denied"
    },
    {
      "id": "malformed-challenge-scope-denied",
      "expect": "a bad auth-param, two Bearer challenges, a duplicated parameter or a malformed scope (empty, tab, repeated, leading or trailing space, invalid character) fails access_denied with no scopes; a 403 that is not insufficient_scope is access_denied and not an auth retry"
    },
    {
      "id": "insufficient-scope-already-granted-denied",
      "expect": "403 insufficient_scope when the sent generation (or no token) is current and its grant covers R within the ceiling fails access_denied carrying R without replaying the token or creating a login; a newer current generation that covers R is used instead"
    },
    {
      "id": "complete-enforces-stored-required-set",
      "expect": "complete() persists the grant, then fails access_denied carrying the pending login's stored R when granted \u2229 current ceiling does not cover it; a pending record without stored R uses its prepare-time H, else the current H"
    },
    {
      "id": "grant-narrower-than-required-denied",
      "expect": "a refresh or client-credentials grant narrower than R fails access_denied carrying R with the grant persisted"
    },
    {
      "id": "host-policy-errors-carry-no-scopes",
      "expect": "scopes are attached only by decide and complete step 7; errors from host callbacks, stores, the network and the token endpoint carry none, and login_ended appears only on complete() errors"
    },
    {
      "id": "complete-error-login-ended",
      "expect": "every complete() error carries login_ended: state lookup runs before any host callback (absent, unknown, expired or ended state: interaction_required/true); invalid callback, including a handle naming another login than the live state, access_denied/false with both logins pending; login_ended always describes the login named by state; pre-claim host policy keeps its code (client source no longer permitted: invalid_configuration)/false; an uncertain claim re-reads the store (gone: true, otherwise false); after the claim every error is /true"
    },
    {
      "id": "entry-points-route-through-decide",
      "expect": "every entry point that yields a credential or handles a challenge (credential/delivery, prepare, challenge, preemptive credential paths, legacy provider adapters) produces decide's outcome; the routing test lists them"
    },
    {
      "id": "transport-challenge-routing",
      "expect": "the transport hands every 401 to the provider, a 403 only when it parses as exactly one Bearer insufficient_scope challenge, and returns any other 403 without a retry"
    },
    {
      "id": "replay-rejection-retires-token",
      "expect": "a token rejected on the challenged replay is handed to the provider, so a 401 retires it"
    },
    {
      "id": "complete-token-endpoint-errors-classified",
      "expect": "after the claim invalid_grant is interaction_required; invalid_client is credential_unavailable (pre-registered), invalid_configuration (CIMD) or interaction_required (DCR); every other token-endpoint error, an unreachable or 404 endpoint and an invalid response are provider_failed; none carry scopes"
    },
    {
      "id": "renewal-token-errors-classified",
      "expect": "refresh and client-credentials token-endpoint errors: PKCE refresh invalid_grant is refresh_rejected, client-credentials invalid_grant and unauthorized_client are credential_unavailable, invalid_client maps by client source (a client-credentials DCR client re-registers once), every other error is provider_failed; none carry scopes"
    }
  ],
  "registration_keys": [
    {
      "id": "cc-registration",
      "input": {
        "namespace": "account",
        "issuer": "https://issuer.example"
      },
      "registration_key": "ahp.oauth.registration:7:account22:https://issuer.example"
    },
    {
      "id": "cc-registration-nonkey-metadata",
      "input": {
        "namespace": "account",
        "issuer": "https://issuer.example",
        "client_name": "Example Adapter",
        "software_id": "example-adapter",
        "software_version": "1.2.3",
        "registration_scope": [
          "read"
        ],
        "registration_endpoint": "https://issuer.example/register",
        "initial_access_token_ref": "vault:not-a-real-secret",
        "client_secret": "not-a-real-secret"
      },
      "registration_key": "ahp.oauth.registration:7:account22:https://issuer.example"
    },
    {
      "id": "cc-issuer-trailing-slash",
      "input": {
        "namespace": "account",
        "issuer": "https://issuer.example/"
      },
      "registration_key": "ahp.oauth.registration:7:account23:https://issuer.example/"
    },
    {
      "id": "cc-unicode-namespace",
      "input": {
        "namespace": "account-\ud83d\ude00",
        "issuer": "https://issuer.example"
      },
      "registration_key": "ahp.oauth.registration:12:account-\ud83d\ude0022:https://issuer.example"
    }
  ],
  "client_selection": [
    {
      "id": "registration-order-preregistered-wins",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": "client",
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "preregistered",
        "client_id": "client",
        "client_identity": "preregistered:client"
      }
    },
    {
      "id": "cimd-used-when-supported",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "cimd",
        "client_id": "https://adapter.example/oauth/client.json",
        "token_endpoint_auth_method": "none",
        "client_identity": "cimd:https://adapter.example/oauth/client.json"
      }
    },
    {
      "id": "cimd-not-supported-falls-back-to-dcr",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "dcr",
        "token_endpoint_auth_method": "none",
        "client_identity": "dcr"
      }
    },
    {
      "id": "cimd-supported-must-be-json-true",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": "true",
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "dcr",
        "token_endpoint_auth_method": "none",
        "client_identity": "dcr"
      }
    },
    {
      "id": "cimd-redirect-mismatch-invalid-configuration",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/other",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-loopback-port-mismatch-accepted",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://127.0.0.1:9999/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "cimd",
        "client_id": "https://adapter.example/oauth/client.json",
        "token_endpoint_auth_method": "none",
        "client_identity": "cimd:https://adapter.example/oauth/client.json"
      }
    },
    {
      "id": "cimd-portless-loopback-redirect-matches",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1/callback"
          ]
        },
        "redirect": "http://127.0.0.1:51004/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "cimd",
        "client_id": "https://adapter.example/oauth/client.json",
        "token_endpoint_auth_method": "none",
        "client_identity": "cimd:https://adapter.example/oauth/client.json"
      }
    },
    {
      "id": "cimd-loopback-userinfo-exact",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1/callback"
          ]
        },
        "redirect": "http://user@127.0.0.1:51004/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "localhost-redirect-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://localhost:51004/callback"
          ]
        },
        "redirect": "http://localhost:51004/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "preregistered-localhost-redirect-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": "client",
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": "http://localhost:51004/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-ipv6-loopback-redirect-matches",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://[::1]/callback"
          ]
        },
        "redirect": "http://[::1]:51004/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "cimd",
        "client_id": "https://adapter.example/oauth/client.json",
        "token_endpoint_auth_method": "none",
        "client_identity": "cimd:https://adapter.example/oauth/client.json"
      }
    },
    {
      "id": "cimd-url-fragment-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json#frag",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-url-http-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "http://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-url-without-path-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-url-dot-segment-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/../client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-url-userinfo-invalid",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://user@adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback"
          ]
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cimd-not-used-for-client-credentials",
      "input": {
        "flow": "client_credentials",
        "preregistered_client_id": null,
        "cimd": {
          "url": "https://adapter.example/oauth/client.json",
          "redirect_uris": [
            "http://127.0.0.1:8765/callback",
            "https://adapter.example/callback"
          ]
        },
        "redirect": null,
        "as_metadata": {
          "client_id_metadata_document_supported": true,
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "dcr",
        "token_endpoint_auth_method": "client_secret_basic",
        "client_identity": "dcr"
      }
    },
    {
      "id": "client-credentials-dcr-post-only",
      "input": {
        "flow": "client_credentials",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": null,
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register",
          "token_endpoint_auth_methods_supported": [
            "client_secret_post",
            "private_key_jwt"
          ]
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "dcr",
        "token_endpoint_auth_method": "client_secret_post",
        "client_identity": "dcr"
      }
    },
    {
      "id": "client-credentials-dcr-no-secret-method",
      "input": {
        "flow": "client_credentials",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": null,
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register",
          "token_endpoint_auth_methods_supported": [
            "private_key_jwt"
          ]
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "credential_unavailable"
      }
    },
    {
      "id": "client-credentials-dcr-without-secret-hook",
      "input": {
        "flow": "client_credentials",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": null,
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": false
      },
      "expect": {
        "error": "credential_unavailable"
      }
    },
    {
      "id": "pkce-dcr-without-secret-hook",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": false
      },
      "expect": {
        "source": "dcr",
        "token_endpoint_auth_method": "none",
        "client_identity": "dcr"
      }
    },
    {
      "id": "dcr-policy-disallows-registration",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": false,
        "secret_hook": true
      },
      "expect": {
        "error": "credential_unavailable"
      }
    },
    {
      "id": "dcr-registration-endpoint-absent",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {},
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "credential_unavailable"
      }
    },
    {
      "id": "dcr-registration-endpoint-not-https",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "registration_endpoint": "http://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "untrusted_destination"
      }
    },
    {
      "id": "no-client-available",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {},
        "dcr_permitted": false,
        "secret_hook": true
      },
      "expect": {
        "error": "credential_unavailable"
      }
    },
    {
      "id": "cimd-invalid-url-unadvertised-falls-back-to-dcr",
      "input": {
        "flow": "authorization_code_pkce",
        "preregistered_client_id": null,
        "cimd": {
          "url": "http://adapter.example/oauth/client.json#frag",
          "redirect_uris": []
        },
        "redirect": "http://127.0.0.1:8765/callback",
        "as_metadata": {
          "registration_endpoint": "https://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "source": "dcr",
        "token_endpoint_auth_method": "none",
        "client_identity": "dcr"
      }
    },
    {
      "id": "cc-missing-hook-checked-before-insecure-endpoint",
      "input": {
        "flow": "client_credentials",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": null,
        "as_metadata": {
          "registration_endpoint": "http://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": false
      },
      "expect": {
        "error": "credential_unavailable"
      }
    },
    {
      "id": "cc-insecure-endpoint-after-feasibility",
      "input": {
        "flow": "client_credentials",
        "preregistered_client_id": null,
        "cimd": null,
        "redirect": null,
        "as_metadata": {
          "registration_endpoint": "http://issuer.example/register"
        },
        "dcr_permitted": true,
        "secret_hook": true
      },
      "expect": {
        "error": "untrusted_destination"
      }
    }
  ],
  "registration_responses": [
    {
      "id": "pkce-minimal",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client"
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-client",
          "client_secret_expires_at": null,
          "secret_ref": false
        }
      }
    },
    {
      "id": "pkce-status-200",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 200,
      "response": {
        "client_id": "dcr-client"
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-client",
          "client_secret_expires_at": null,
          "secret_ref": false
        }
      }
    },
    {
      "id": "pkce-full-echo-management-ignored",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter",
        "client_id": "dcr-client",
        "client_id_issued_at": 1800000000,
        "scope": "read openid",
        "registration_access_token": "not-a-real-secret",
        "registration_client_uri": "https://issuer.example/register/dcr-client"
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-client",
          "client_secret_expires_at": null,
          "secret_ref": false
        }
      }
    },
    {
      "id": "pkce-secret-ignored",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client",
        "client_secret": "not-a-real-secret",
        "client_secret_expires_at": 0
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-client",
          "client_secret_expires_at": null,
          "secret_ref": false
        }
      }
    },
    {
      "id": "pkce-redirect-replaced",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client",
        "redirect_uris": [
          "https://evil.example/cb"
        ]
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "pkce-echo-superset-accepted",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client",
        "redirect_uris": [
          "http://127.0.0.1:8765/callback",
          "http://[::1]:8765/callback"
        ]
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-client",
          "client_secret_expires_at": null,
          "secret_ref": false
        }
      }
    },
    {
      "id": "pkce-echo-other-port-rejected",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client",
        "redirect_uris": [
          "http://127.0.0.1:9999/callback"
        ]
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "pkce-auth-method-changed",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client",
        "token_endpoint_auth_method": "client_secret_basic"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "pkce-grant-types-missing-flow",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-client",
        "grant_types": [
          "refresh_token"
        ]
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "missing-client-id",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_name": "Example Adapter"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "empty-client-id",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": ""
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "non-string-client-id",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": 42
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cc-secret-no-expiry",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret",
        "client_secret_expires_at": 0
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-cc",
          "client_secret_expires_at": 0,
          "secret_ref": true
        }
      }
    },
    {
      "id": "cc-secret-expiry-absent",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret"
      },
      "expect": {
        "accepted": true,
        "expiry": "none",
        "record": {
          "client_id": "dcr-cc",
          "client_secret_expires_at": null,
          "secret_ref": true
        }
      }
    },
    {
      "id": "cc-secret-known-expiry",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret",
        "client_secret_expires_at": 1800003600
      },
      "expect": {
        "accepted": true,
        "expiry": "known",
        "record": {
          "client_id": "dcr-cc",
          "client_secret_expires_at": 1800003600,
          "secret_ref": true
        }
      }
    },
    {
      "id": "cc-secret-already-expired",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret",
        "client_secret_expires_at": 1800000000
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cc-secret-negative-expiry",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret",
        "client_secret_expires_at": -1
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cc-secret-string-expiry",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret",
        "client_secret_expires_at": "1800003600"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cc-missing-secret",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "cc-auth-method-downgraded",
      "flow": "client_credentials",
      "request": {
        "grant_types": [
          "client_credentials"
        ],
        "token_endpoint_auth_method": "client_secret_basic",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": {
        "client_id": "dcr-cc",
        "client_secret": "not-a-real-secret",
        "token_endpoint_auth_method": "none"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "redirect-response",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 302,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "untrusted_destination"
      }
    },
    {
      "id": "invalid-redirect-uri",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 400,
      "response": {
        "error": "invalid_redirect_uri"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "invalid-client-metadata",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 400,
      "response": {
        "error": "invalid_client_metadata",
        "error_description": "x"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "unapproved-software-statement",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 400,
      "response": {
        "error": "unapproved_software_statement"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "initial-access-token-rejected",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 401,
      "response": {
        "error": "invalid_token"
      },
      "expect": {
        "accepted": false,
        "error": "credential_unavailable"
      }
    },
    {
      "id": "registration-forbidden",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 403,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "credential_unavailable"
      }
    },
    {
      "id": "server-error",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 503,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "provider_failed"
      }
    },
    {
      "id": "non-oauth-400",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 400,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "invalid-request-400",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 400,
      "response": {
        "error": "invalid_request"
      },
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "not-found-404",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 404,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "invalid_configuration"
      }
    },
    {
      "id": "rate-limited-429",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 429,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "provider_failed"
      }
    },
    {
      "id": "request-timeout-408",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 408,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "provider_failed"
      }
    },
    {
      "id": "accepted-202",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 202,
      "response": {
        "client_id": "dcr-client"
      },
      "expect": {
        "accepted": false,
        "error": "provider_failed"
      }
    },
    {
      "id": "non-json-201",
      "flow": "authorization_code_pkce",
      "request": {
        "redirect_uris": [
          "http://127.0.0.1:8765/callback"
        ],
        "application_type": "native",
        "grant_types": [
          "authorization_code",
          "refresh_token"
        ],
        "response_types": [
          "code"
        ],
        "token_endpoint_auth_method": "none",
        "client_name": "Example Adapter"
      },
      "now": 1800000000,
      "status": 201,
      "response": null,
      "expect": {
        "accepted": false,
        "error": "provider_failed"
      }
    }
  ]
}
