Validar FALHA quando o consentimento é REVOGADO pelo cliente na Instituição Detentora
[JSR-CONS-008] - Fluxo e Condições para Erro após Cancelamento
Introdução
Este documento descreve as condições necessárias e o fluxo de status para reproduzir o cenário de erro após cancelamento de enrollment no teste [JSR-CONS-008].
Condições Necessárias
Ação Crítica
| Etapa | Ação | Status Resultante |
|---|---|---|
| 9 | Cancelar Enrollment (PATCH) | REVOKED |
Status Necessários por Etapa
| Etapa | Requisição | Status Esperado | Observação |
|---|---|---|---|
| 1 | Get Application Token | - | Autenticação bem-sucedida |
| 2 | Enrollment Payment initiation | AWAITING_ACCOUNT_HOLDER_VALIDATION | Enrollment criado |
| 3 | URL Autorização | - | URL gerada |
| 4 | Login | AWAITING_ACCOUNT_HOLDER_VALIDATION | Login bem-sucedido |
| 5 | Approve | AWAITING_ENROLLMENT | Consentimento aprovado |
| 6 | Callback Payment Initiation | AWAITING_ENROLLMENT | Callback processado |
| 7 | fido-registration-options | - | Opções geradas |
| 8 | fido-registration | AUTHORISED | Enrollment autorizado |
| 9 | Enrollment (PATCH) | REVOKED | ⚠️ CANCELAMENTO |
| 10 | payment-initiation | AWAITING_AUTHORISATION | Payment criado (ainda funciona) |
| 11 | fido-sign-options | 422 ERROR | Erro: Enrollment REVOKED |
Fluxo de Status
┌─────────────────────────────────────────────────────────────┐
│ 1-5. Fluxo Inicial de Enrollment │
│ Status: AWAITING_ENROLLMENT │
└────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ 6-7. FIDO Registration │
│ Status: AUTHORISED │
│ ✅ Enrollment completo e autorizado │
└────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ 8. Enrollment (PATCH) - CANCELAMENTO │
│ Status: REVOKED │
│ ⚠️ Enrollment cancelado pelo usuário │
└────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ 9. Payment Initiation │
│ Status: AWAITING_AUTHORISATION │
│ ⚠️ Ainda é possível criar payment │
└────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ 10. fido-sign-options │
│ ❌ ERRO 422: Enrollment REVOKED │
│ "cannot generate fido sign options to enrollment. │
│ current status: REVOKED" │
└─────────────────────────────────────────────────────────────┘
Detalhamento do Cancelamento (Etapa 9)
Requisição de Cancelamento
PATCH {{BASE_URL}}/open-keys/itp/api/v2/enrollments/v2/payment-initiation/{{itp_enrollment_id}}
Content-Type: application/json
Authorization: Bearer {{application_token}}
{
"data": {
"cancellation": {
"cancelledBy": {
"document": {
"identification": "98765432100",
"rel": "CPF"
}
},
"reason": {
"revocationReason": "REJEITADO_MANUALMENTE"
}
},
"cancelledFrom": "INICIADORA"
}
}
Status Antes e Depois
| Momento | Status do Enrollment | Observação |
|---|---|---|
| Antes do PATCH | AUTHORISED | Enrollment válido e autorizado |
| Após o PATCH | REVOKED | Enrollment cancelado |
Pontos Críticos
1. Momento do Cancelamento
O cancelamento deve ocorrer após:
- ✅ Enrollment estar autorizado (
AUTHORISED) - ✅ FIDO registration completo
- ✅ Antes de tentar gerar fido-sign-options
2. Comportamento após Cancelamento
| Ação | Status | Resultado |
|---|---|---|
| Criar payment-initiation | AWAITING_AUTHORISATION | ✅ Ainda funciona |
| Gerar fido-sign-options | - | ❌ ERRO 422 |
3. Validação do Erro
O sistema valida o status do enrollment ao tentar gerar fido-sign-options:
if (enrollment.status === 'REVOKED') {
throw Error('cannot generate fido sign options to enrollment. current status: REVOKED')
}
Validação do Erro
Resposta Esperada
{
"name": "UnprocessableEntityError",
"message": "Unprocessable Entity",
"code": 422,
"type": {
"data": {
"description": "cannot generate fido sign options to enrollment. current status: REVOKED"
}
}
}Condições para Reproduzir
- ✅ Enrollment deve estar no status
AUTHORISEDantes do cancelamento - ✅ Cancelamento deve ser executado via PATCH com
revocationReason: "REJEITADO_MANUALMENTE" - ✅ Enrollment deve estar no status
REVOKEDapós o cancelamento - ✅ Tentativa de gerar fido-sign-options deve ocorrer após o cancelamento
- ✅ Payment-initiation pode ser criado mesmo com enrollment REVOKED
Sequência de Status do Enrollment
PENDING
↓
AWAITING_ACCOUNT_HOLDER_VALIDATION
↓
AWAITING_ENROLLMENT
↓
AUTHORISED ← Enrollment completo
↓
REVOKED ← Cancelamento (Etapa 9)
↓
❌ ERRO ao tentar fido-sign-options (Etapa 11)
Observações Importantes
- O cancelamento pode ser feito a qualquer momento após a autorização
- A criação de payment-initiation ainda funciona após o cancelamento
- O erro ocorre apenas ao tentar gerar fido-sign-options
- O sistema valida o status do enrollment antes de gerar opções de assinatura
- O erro retorna código HTTP 422 (Unprocessable Entity)
- A mensagem de erro indica claramente o status atual:
REVOKED
Diferenças entre os Fluxos
| Aspecto | Fluxo Normal | Fluxo com Cancelamento |
|---|---|---|
| Status final do Enrollment | AUTHORISED | REVOKED |
| Criação de Payment | ✅ Permitida | ✅ Permitida |
| Geração de fido-sign-options | ✅ Permitida | ❌ Bloqueada |
| Processamento de PIX | ✅ Permitido | ❌ Não alcançado |
Updated 3 days ago