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

Function TestToken_SigningString

token_test.go:9–60  ·  view source on GitHub ↗
(t1 *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestToken_SigningString(t1 *testing.T) {
10 type fields struct {
11 Raw string
12 Method jwt.SigningMethod
13 Header map[string]any
14 Claims jwt.Claims
15 Signature []byte
16 Valid bool
17 }
18 tests := []struct {
19 name string
20 fields fields
21 want string
22 wantErr bool
23 }{
24 {
25 name: "",
26 fields: fields{
27 Raw: "",
28 Method: jwt.SigningMethodHS256,
29 Header: map[string]any{
30 "typ": "JWT",
31 "alg": jwt.SigningMethodHS256.Alg(),
32 },
33 Claims: jwt.RegisteredClaims{},
34 Valid: false,
35 },
36 want: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30",
37 wantErr: false,
38 },
39 }
40 for _, tt := range tests {
41 t1.Run(tt.name, func(t1 *testing.T) {
42 t := &jwt.Token{
43 Raw: tt.fields.Raw,
44 Method: tt.fields.Method,
45 Header: tt.fields.Header,
46 Claims: tt.fields.Claims,
47 Signature: tt.fields.Signature,
48 Valid: tt.fields.Valid,
49 }
50 got, err := t.SigningString()
51 if (err != nil) != tt.wantErr {
52 t1.Errorf("SigningString() error = %v, wantErr %v", err, tt.wantErr)
53 return
54 }
55 if got != tt.want {
56 t1.Errorf("SigningString() got = %v, want %v", got, tt.want)
57 }
58 })
59 }
60}
61
62func BenchmarkToken_SigningString(b *testing.B) {
63 t := &jwt.Token{

Callers

nothing calls this directly

Calls 2

SigningStringMethod · 0.95
AlgMethod · 0.65

Tested by

no test coverage detected