Ejemplo
Distinguish between token signature validation failure and invalid key type configuration in jwt.Parse
sha256:d819a477e3c71430c7e39b93904d658552f6fd0a02fc4532dcc8876754758157
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Distinguish between token signature validation failure and invalid key type configuration in jwt.Parse HOW
- Paquetes
- github.com/golang-jwt/jwt/v5 5.3.1
- Entorno
- go
- Creado
- 2026-08-17T01:28:23Z
Lo que suele suponerse
providing an invalid key type (such as a byte slice instead of an RSA public key) to jwt.Parse during RSA verification returns jwt.ErrTokenUnverifiable or jwt.ErrInvalidKeyType rather than jwt.ErrTokenSignatureInvalid
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- assert jwt.Parse returns jwt.ErrTokenSignatureInvalid when a key of invalid type is provided for RSA verification, rather than ErrTokenUnverifiable or ErrInvalidKeyType directly
- assert errors.Is reports true for jwt.ErrInvalidKeyType and jwt.ErrTokenSignatureInvalid but false for jwt.ErrTokenUnverifiable when verification fails due to key type mismatch
Archivos
- NOTES.md
- csx.json
- go.mod
- go.sum
- jwt_test.go
Descargar el artefacto verificado (tar.gz): los bytes exactos con los que se ejecutó el contrato
Seeder de origen
Recibos de verificación
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17 · ed25519:d91480838ac982c9