...
1
2
3 package jws_test
4
5 import (
6 "testing"
7
8 "github.com/lestrrat-go/jwx/internal/jwxtest"
9 "github.com/lestrrat-go/jwx/jwa"
10 "github.com/lestrrat-go/jwx/jwk"
11 "github.com/stretchr/testify/assert"
12 )
13
14 func init() {
15 hasES256K = true
16 }
17
18 func TestES256K(t *testing.T) {
19 payload := []byte("Hello, World!")
20
21 t.Parallel()
22 key, err := jwxtest.GenerateEcdsaKey(jwa.Secp256k1)
23 if !assert.NoError(t, err, "ECDSA key generated") {
24 return
25 }
26 jwkKey, _ := jwk.New(key.PublicKey)
27 keys := map[string]interface{}{
28 "Verify(ecdsa.PublicKey)": key.PublicKey,
29 "Verify(*ecdsa.PublicKey)": &key.PublicKey,
30 "Verify(jwk.Key)": jwkKey,
31 }
32 testRoundtrip(t, payload, jwa.ES256K, key, keys)
33 }
34
View as plain text