MCPcopy
hub / github.com/golang-jwt/jwt / TestECDSAVerify

Function TestECDSAVerify

ecdsa_test.go:55–77  ·  ecdsa_test.go::TestECDSAVerify
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestECDSAVerify(t *testing.T) {
56 for _, data := range ecdsaTestData {
57 var err error
58
59 key, _ := os.ReadFile(data.keys["public"])
60
61 var ecdsaKey *ecdsa.PublicKey
62 if ecdsaKey, err = jwt.ParseECPublicKeyFromPEM(key); err != nil {
63 t.Errorf("Unable to parse ECDSA public key: %v", err)
64 }
65
66 parts := strings.Split(data.tokenString, ".")
67
68 method := jwt.GetSigningMethod(data.alg)
69 err = method.Verify(strings.Join(parts[0:2], "."), decodeSegment(t, parts[2]), ecdsaKey)
70 if data.valid && err != nil {
71 t.Errorf("[%v] Error while verifying key: %v", data.name, err)
72 }
73 if !data.valid && err == nil {
74 t.Errorf("[%v] Invalid key passed validation", data.name)
75 }
76 }
77}
78
79func TestECDSASign(t *testing.T) {
80 for _, data := range ecdsaTestData {

Callers

nothing calls this directly

Calls 2

decodeSegmentFunction · 0.85
VerifyMethod · 0.65

Tested by

no test coverage detected