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