...

Source file src/github.com/lestrrat-go/jwx/jwa/secp2561k_test.go

Documentation: github.com/lestrrat-go/jwx/jwa

     1  // +build jwx_es256k
     2  
     3  package jwa_test
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/lestrrat-go/jwx/jwa"
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestSecp256k1(t *testing.T) {
    13  	t.Parallel()
    14  	t.Run(`accept jwa constant Secp256k1`, func(t *testing.T) {
    15  		t.Parallel()
    16  		var dst jwa.EllipticCurveAlgorithm
    17  		if !assert.NoError(t, dst.Accept(jwa.Secp256k1), `accept is successful`) {
    18  			return
    19  		}
    20  		if !assert.Equal(t, jwa.Secp256k1, dst, `accepted value should be equal to constant`) {
    21  			return
    22  		}
    23  	})
    24  	t.Run(`accept the string secp256k1`, func(t *testing.T) {
    25  		t.Parallel()
    26  		var dst jwa.EllipticCurveAlgorithm
    27  		if !assert.NoError(t, dst.Accept("secp256k1"), `accept is successful`) {
    28  			return
    29  		}
    30  		if !assert.Equal(t, jwa.Secp256k1, dst, `accepted value should be equal to constant`) {
    31  			return
    32  		}
    33  	})
    34  	t.Run(`accept fmt.Stringer for secp256k1`, func(t *testing.T) {
    35  		t.Parallel()
    36  		var dst jwa.EllipticCurveAlgorithm
    37  		if !assert.NoError(t, dst.Accept(stringer{src: "secp256k1"}), `accept is successful`) {
    38  			return
    39  		}
    40  		if !assert.Equal(t, jwa.Secp256k1, dst, `accepted value should be equal to constant`) {
    41  			return
    42  		}
    43  	})
    44  	t.Run(`stringification for secp256k1`, func(t *testing.T) {
    45  		t.Parallel()
    46  		if !assert.Equal(t, "secp256k1", jwa.Secp256k1.String(), `stringified value matches`) {
    47  			return
    48  		}
    49  	})
    50  }
    51  

View as plain text