34
34
func TestSign (t * testing.T ) {
35
35
type testCase struct {
36
36
alg jwt.Algorithm
37
- hd jwt.Header
38
37
payload interface {}
39
38
40
39
verifyAlg jwt.Algorithm
@@ -49,7 +48,6 @@ func TestSign(t *testing.T) {
49
48
"HMAC" : []testCase {
50
49
{
51
50
alg : jwt .NewHS256 (hmacKey1 ),
52
- hd : jwt.Header {},
53
51
payload : tp ,
54
52
verifyAlg : jwt .NewHS256 (hmacKey1 ),
55
53
wantHeader : jwt.Header {
@@ -62,7 +60,6 @@ func TestSign(t *testing.T) {
62
60
},
63
61
{
64
62
alg : jwt .NewHS384 (hmacKey1 ),
65
- hd : jwt.Header {},
66
63
payload : tp ,
67
64
verifyAlg : jwt .NewHS384 (hmacKey1 ),
68
65
wantHeader : jwt.Header {
@@ -75,7 +72,6 @@ func TestSign(t *testing.T) {
75
72
},
76
73
{
77
74
alg : jwt .NewHS512 (hmacKey1 ),
78
- hd : jwt.Header {},
79
75
payload : tp ,
80
76
verifyAlg : jwt .NewHS512 (hmacKey1 ),
81
77
wantHeader : jwt.Header {
@@ -90,7 +86,6 @@ func TestSign(t *testing.T) {
90
86
"RSA" : []testCase {
91
87
{
92
88
alg : jwt .NewRS256 (rsaPrivateKey1 , nil ),
93
- hd : jwt.Header {},
94
89
payload : tp ,
95
90
verifyAlg : jwt .NewRS256 (rsaPrivateKey1 , nil ),
96
91
wantHeader : jwt.Header {
@@ -103,7 +98,6 @@ func TestSign(t *testing.T) {
103
98
},
104
99
{
105
100
alg : jwt .NewRS256 (rsaPrivateKey1 , nil ),
106
- hd : jwt.Header {},
107
101
payload : tp ,
108
102
verifyAlg : jwt .NewRS256 (nil , rsaPublicKey1 ),
109
103
wantHeader : jwt.Header {
@@ -116,7 +110,6 @@ func TestSign(t *testing.T) {
116
110
},
117
111
{
118
112
alg : jwt .NewRS384 (rsaPrivateKey1 , nil ),
119
- hd : jwt.Header {},
120
113
payload : tp ,
121
114
verifyAlg : jwt .NewRS384 (rsaPrivateKey1 , nil ),
122
115
wantHeader : jwt.Header {
@@ -129,7 +122,6 @@ func TestSign(t *testing.T) {
129
122
},
130
123
{
131
124
alg : jwt .NewRS384 (rsaPrivateKey1 , nil ),
132
- hd : jwt.Header {},
133
125
payload : tp ,
134
126
verifyAlg : jwt .NewRS384 (nil , rsaPublicKey1 ),
135
127
wantHeader : jwt.Header {
@@ -142,7 +134,6 @@ func TestSign(t *testing.T) {
142
134
},
143
135
{
144
136
alg : jwt .NewRS512 (rsaPrivateKey1 , nil ),
145
- hd : jwt.Header {},
146
137
payload : tp ,
147
138
verifyAlg : jwt .NewRS512 (rsaPrivateKey1 , nil ),
148
139
wantHeader : jwt.Header {
@@ -155,7 +146,6 @@ func TestSign(t *testing.T) {
155
146
},
156
147
{
157
148
alg : jwt .NewRS512 (rsaPrivateKey1 , nil ),
158
- hd : jwt.Header {},
159
149
payload : tp ,
160
150
verifyAlg : jwt .NewRS512 (nil , rsaPublicKey1 ),
161
151
wantHeader : jwt.Header {
@@ -170,7 +160,6 @@ func TestSign(t *testing.T) {
170
160
"RSA-PSS" : []testCase {
171
161
{
172
162
alg : jwt .NewPS256 (rsaPrivateKey1 , nil ),
173
- hd : jwt.Header {},
174
163
payload : tp ,
175
164
verifyAlg : jwt .NewPS256 (rsaPrivateKey1 , nil ),
176
165
wantHeader : jwt.Header {
@@ -183,7 +172,6 @@ func TestSign(t *testing.T) {
183
172
},
184
173
{
185
174
alg : jwt .NewPS256 (rsaPrivateKey1 , nil ),
186
- hd : jwt.Header {},
187
175
payload : tp ,
188
176
verifyAlg : jwt .NewPS256 (nil , rsaPublicKey1 ),
189
177
wantHeader : jwt.Header {
@@ -196,7 +184,6 @@ func TestSign(t *testing.T) {
196
184
},
197
185
{
198
186
alg : jwt .NewPS384 (rsaPrivateKey1 , nil ),
199
- hd : jwt.Header {},
200
187
payload : tp ,
201
188
verifyAlg : jwt .NewPS384 (rsaPrivateKey1 , nil ),
202
189
wantHeader : jwt.Header {
@@ -209,7 +196,6 @@ func TestSign(t *testing.T) {
209
196
},
210
197
{
211
198
alg : jwt .NewPS384 (rsaPrivateKey1 , nil ),
212
- hd : jwt.Header {},
213
199
payload : tp ,
214
200
verifyAlg : jwt .NewPS384 (nil , rsaPublicKey1 ),
215
201
wantHeader : jwt.Header {
@@ -222,7 +208,6 @@ func TestSign(t *testing.T) {
222
208
},
223
209
{
224
210
alg : jwt .NewPS512 (rsaPrivateKey1 , nil ),
225
- hd : jwt.Header {},
226
211
payload : tp ,
227
212
verifyAlg : jwt .NewPS512 (rsaPrivateKey1 , nil ),
228
213
wantHeader : jwt.Header {
@@ -235,7 +220,6 @@ func TestSign(t *testing.T) {
235
220
},
236
221
{
237
222
alg : jwt .NewPS512 (rsaPrivateKey1 , nil ),
238
- hd : jwt.Header {},
239
223
payload : tp ,
240
224
verifyAlg : jwt .NewPS512 (nil , rsaPublicKey1 ),
241
225
wantHeader : jwt.Header {
@@ -250,7 +234,6 @@ func TestSign(t *testing.T) {
250
234
"ECDSA" : []testCase {
251
235
{
252
236
alg : jwt .NewES256 (es256PrivateKey1 , nil ),
253
- hd : jwt.Header {},
254
237
payload : tp ,
255
238
verifyAlg : jwt .NewES256 (nil , es256PublicKey1 ),
256
239
wantHeader : jwt.Header {
@@ -263,7 +246,6 @@ func TestSign(t *testing.T) {
263
246
},
264
247
{
265
248
alg : jwt .NewES256 (es256PrivateKey1 , nil ),
266
- hd : jwt.Header {},
267
249
payload : tp ,
268
250
verifyAlg : jwt .NewES256 (es256PrivateKey1 , nil ),
269
251
wantHeader : jwt.Header {
@@ -276,7 +258,6 @@ func TestSign(t *testing.T) {
276
258
},
277
259
{
278
260
alg : jwt .NewES384 (es384PrivateKey1 , nil ),
279
- hd : jwt.Header {},
280
261
payload : tp ,
281
262
verifyAlg : jwt .NewES384 (nil , es384PublicKey1 ),
282
263
wantHeader : jwt.Header {
@@ -289,7 +270,6 @@ func TestSign(t *testing.T) {
289
270
},
290
271
{
291
272
alg : jwt .NewES384 (es384PrivateKey1 , nil ),
292
- hd : jwt.Header {},
293
273
payload : tp ,
294
274
verifyAlg : jwt .NewES384 (es384PrivateKey1 , nil ),
295
275
wantHeader : jwt.Header {
@@ -302,7 +282,6 @@ func TestSign(t *testing.T) {
302
282
},
303
283
{
304
284
alg : jwt .NewES512 (es512PrivateKey1 , nil ),
305
- hd : jwt.Header {},
306
285
payload : tp ,
307
286
verifyAlg : jwt .NewES512 (nil , es512PublicKey1 ),
308
287
wantHeader : jwt.Header {
@@ -315,7 +294,6 @@ func TestSign(t *testing.T) {
315
294
},
316
295
{
317
296
alg : jwt .NewES512 (es512PrivateKey1 , nil ),
318
- hd : jwt.Header {},
319
297
payload : tp ,
320
298
verifyAlg : jwt .NewES512 (es512PrivateKey1 , nil ),
321
299
wantHeader : jwt.Header {
@@ -330,7 +308,6 @@ func TestSign(t *testing.T) {
330
308
"Ed25519" : []testCase {
331
309
{
332
310
alg : jwt .NewEd25519 (ed25519PrivateKey1 , nil ),
333
- hd : jwt.Header {},
334
311
payload : tp ,
335
312
verifyAlg : jwt .NewEd25519 (ed25519PrivateKey1 , nil ),
336
313
wantHeader : jwt.Header {
@@ -359,7 +336,7 @@ func TestSign(t *testing.T) {
359
336
hd jwt.Header
360
337
payload testPayload
361
338
)
362
- hd , err = jwt .Verify (token , & payload , tc .verifyAlg )
339
+ hd , err = jwt .Verify (token , tc .verifyAlg , & payload )
363
340
if want , got := tc .verifyErr , err ; got != want {
364
341
t .Fatalf ("want %v, got %v" , want , got )
365
342
}
0 commit comments