{
  "info": {
    "name": "Finger — Onboarding e autenticação",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Teste manual da API Online no ambiente fornecido para sua aplicação. Preencha as variáveis da coleção localmente. Use capturas reais e execute token → onboarding → autenticação, verificando cada resposta. Os testes não exigem aprovação biométrica. Preencha os IDs manualmente e preserve-os para duplicidade; use um novo ID antes de uma nova coleta. Preencha fingers diretamente no body de cada requisição biométrica. Postman não executa captura ou liveness. Importe e selecione o ambiente Finger — Imagens de teste; preencha finger_image_onboarding e finger_image_authentication com os Base64 das respectivas capturas. nfiq2 tem valor inicial 55 no body."
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "",
      "type": "string"
    },
    {
      "key": "key",
      "value": "",
      "type": "string"
    },
    {
      "key": "secret",
      "value": "",
      "type": "string"
    },
    {
      "key": "token",
      "value": "",
      "type": "string"
    },
    {
      "key": "cpf",
      "value": "",
      "type": "string"
    },
    {
      "key": "onboarding_collection_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "authentication_collection_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "identification_collection_id",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "01 — Gerar token",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Token gerado — HTTP 200', () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.test('Resposta contém token', () => pm.expect(body.token).to.be.a('string').and.not.empty);",
              "  if (typeof body.token === 'string' && body.token) pm.collectionVariables.set('token', body.token);",
              "}"
            ]
          }
        }
      ],
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"key\": \"{{key}}\",\n  \"secret\": \"{{secret}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{base_url}}/api/v1/app-credentials/token",
        "description": "Preencha base_url, key e secret da aplicação Online. O token retornado é salvo na coleção."
      },
      "response": []
    },
    {
      "name": "02 — Onboarding",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Fluxo processado — HTTP 200', () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.test('Resposta contém status de negócio e resultCode', () => {",
              "    pm.expect(body.status).to.be.oneOf(['APPROVED', 'REJECTED', 'PENDING']);",
              "    pm.expect(body.resultCode).to.be.a('string').and.not.empty;",
              "  });",
              "  pm.test('collectionId corresponde ao envio', () => pm.expect(body.collectionId).to.eql(pm.collectionVariables.get('onboarding_collection_id')));",
              "  pm.test('Resultado: ' + body.status + ' / ' + body.resultCode + ' / ' + body.decision, () => pm.expect(body).to.have.property('transactionId'));",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"collectionId\": \"{{onboarding_collection_id}}\",\n  \"cpf\": \"{{cpf}}\",\n  \"fingers\": [\n    {\n      \"position\": 7,\n      \"nfiq2\": 55,\n      \"image\": \"{{finger_image_onboarding}}\"\n    }\n  ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{base_url}}/api/v1/services/biometric/onboarding",
        "description": "Preencha fingers diretamente em Body → raw → JSON: image usa a variável de ambiente finger_image_onboarding; preencha-a com o Base64 real e selecione o ambiente no Postman. Ajuste position conforme o dedo. nfiq2 começa em 55; substitua pela qualidade real da captura quando disponível. Use a captura de onboarding. Preencha onboarding_collection_id com um identificador único. Preserve-o para reenviar a mesma coleta e troque-o para uma nova coleta/comparação. Confira o resultado da resposta."
      },
      "response": []
    },
    {
      "name": "03 — Autenticação 1:1",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Fluxo processado — HTTP 200', () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.test('Resposta contém status de negócio e resultCode', () => {",
              "    pm.expect(body.status).to.be.oneOf(['APPROVED', 'REJECTED', 'PENDING']);",
              "    pm.expect(body.resultCode).to.be.a('string').and.not.empty;",
              "  });",
              "  pm.test('collectionId corresponde ao envio', () => pm.expect(body.collectionId).to.eql(pm.collectionVariables.get('authentication_collection_id')));",
              "  pm.test('Resultado: ' + body.status + ' / ' + body.resultCode + ' / ' + body.decision, () => pm.expect(body).to.have.property('transactionId'));",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"collectionId\": \"{{authentication_collection_id}}\",\n  \"cpf\": \"{{cpf}}\",\n  \"mode\": \"ONE_TO_ONE\",\n  \"fingers\": [\n    {\n      \"position\": 7,\n      \"nfiq2\": 55,\n      \"image\": \"{{finger_image_authentication}}\"\n    }\n  ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{base_url}}/api/v1/services/biometric/authenticate",
        "description": "Preencha fingers diretamente em Body → raw → JSON: image usa a variável de ambiente finger_image_authentication; preencha-a com o Base64 real e selecione o ambiente no Postman. Ajuste position conforme o dedo. nfiq2 começa em 55; substitua pela qualidade real da captura quando disponível. Use uma nova captura dos dedos cadastrados. Preencha authentication_collection_id com um identificador único. Preserve-o para reenviar a mesma coleta e troque-o para uma nova coleta/comparação. Confira o resultado da resposta."
      },
      "response": []
    },
    {
      "name": "04 — Identificação 1:N",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Fluxo processado — HTTP 200', () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.test('Resposta contém status de negócio e resultCode', () => {",
              "    pm.expect(body.status).to.be.oneOf(['APPROVED', 'REJECTED', 'PENDING']);",
              "    pm.expect(body.resultCode).to.be.a('string').and.not.empty;",
              "  });",
              "  pm.test('collectionId corresponde ao envio', () => pm.expect(body.collectionId).to.eql(pm.collectionVariables.get('identification_collection_id')));",
              "  pm.test('Resultado: ' + body.status + ' / ' + body.resultCode + ' / ' + body.decision, () => pm.expect(body).to.have.property('transactionId'));",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"collectionId\": \"{{identification_collection_id}}\",\n  \"mode\": \"ONE_TO_N\",\n  \"fingers\": [\n    {\n      \"position\": 7,\n      \"nfiq2\": 55,\n      \"image\": \"{{finger_image_authentication}}\"\n    }\n  ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{base_url}}/api/v1/services/biometric/authenticate",
        "description": "Preencha fingers diretamente em Body → raw → JSON: image usa a variável de ambiente finger_image_authentication; preencha-a com o Base64 real e selecione o ambiente no Postman. Ajuste position conforme o dedo. nfiq2 começa em 55; substitua pela qualidade real da captura quando disponível. Use uma nova captura dos dedos cadastrados. Preencha identification_collection_id com um identificador único. Preserve-o para reenviar a mesma coleta e troque-o para uma nova coleta/comparação. Confira o resultado da resposta."
      },
      "response": []
    }
  ]
}
