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

Function TestRSASign

rsa_test.go:67–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestRSASign(t *testing.T) {
68 keyData, _ := os.ReadFile("test/sample_key")
69 key, _ := jwt.ParseRSAPrivateKeyFromPEM(keyData)
70
71 for _, data := range rsaTestData {
72 if data.valid {
73 parts := strings.Split(data.tokenString, ".")
74 method := jwt.GetSigningMethod(data.alg)
75 sig, err := method.Sign(strings.Join(parts[0:2], "."), key)
76 if err != nil {
77 t.Errorf("[%v] Error signing token: %v", data.name, err)
78 }
79 if !reflect.DeepEqual(sig, decodeSegment(t, parts[2])) {
80 t.Errorf("[%v] Incorrect signature.\nwas:\n%v\nexpecting:\n%v", data.name, sig, parts[2])
81 }
82 }
83 }
84}
85
86func TestRSAVerifyWithPreParsedPrivateKey(t *testing.T) {
87 key, _ := os.ReadFile("test/sample_key.pub")

Callers

nothing calls this directly

Calls 2

decodeSegmentFunction · 0.85
SignMethod · 0.65

Tested by

no test coverage detected