@@ -48,17 +48,17 @@ func publicKeyPEMForTest(t *testing.T, key interface{ Raw(any) error }) []byte {
4848
4949func TestGenerateDPoPKeyForAlg_EC (t * testing.T ) {
5050 tests := []struct {
51- alg string
51+ alg SigningAlgorithm
5252 wantAlg jwa.SignatureAlgorithm
5353 curve elliptic.Curve
5454 }{
55- {dpopAlgES256 , jwa .ES256 , elliptic .P256 ()},
56- {dpopAlgES384 , jwa .ES384 , elliptic .P384 ()},
57- {dpopAlgES512 , jwa .ES512 , elliptic .P521 ()},
55+ {ES256 , jwa .ES256 , elliptic .P256 ()},
56+ {ES384 , jwa .ES384 , elliptic .P384 ()},
57+ {ES512 , jwa .ES512 , elliptic .P521 ()},
5858 }
5959
6060 for _ , tt := range tests {
61- t .Run (tt .alg , func (t * testing.T ) {
61+ t .Run (string ( tt .alg ) , func (t * testing.T ) {
6262 key , err := generateDPoPKeyForAlg (tt .alg )
6363 require .NoErrorf (t , err , "generateDPoPKeyForAlg(%q)" , tt .alg )
6464 assert .Equal (t , tt .wantAlg , key .Algorithm (), "algorithm" )
@@ -71,16 +71,16 @@ func TestGenerateDPoPKeyForAlg_EC(t *testing.T) {
7171
7272func TestGenerateDPoPKeyForAlg_RSA (t * testing.T ) {
7373 tests := []struct {
74- alg string
74+ alg SigningAlgorithm
7575 wantAlg jwa.SignatureAlgorithm
7676 }{
77- {dpopAlgRS256 , jwa .RS256 },
78- {dpopAlgRS384 , jwa .RS384 },
79- {dpopAlgRS512 , jwa .RS512 },
77+ {RS256 , jwa .RS256 },
78+ {RS384 , jwa .RS384 },
79+ {RS512 , jwa .RS512 },
8080 }
8181
8282 for _ , tt := range tests {
83- t .Run (tt .alg , func (t * testing.T ) {
83+ t .Run (string ( tt .alg ) , func (t * testing.T ) {
8484 key , err := generateDPoPKeyForAlg (tt .alg )
8585 require .NoErrorf (t , err , "generateDPoPKeyForAlg(%q)" , tt .alg )
8686 assert .Equal (t , tt .wantAlg , key .Algorithm (), "algorithm" )
@@ -91,16 +91,16 @@ func TestGenerateDPoPKeyForAlg_RSA(t *testing.T) {
9191}
9292
9393func TestGenerateDPoPKeyForAlg_Invalid (t * testing.T ) {
94- for _ , alg := range []string {"INVALID" , "" , "HS256" , "PS256" } {
95- t .Run (alg , func (t * testing.T ) {
94+ for _ , alg := range []SigningAlgorithm {"INVALID" , "" , "HS256" , "PS256" } {
95+ t .Run (string ( alg ) , func (t * testing.T ) {
9696 _ , err := generateDPoPKeyForAlg (alg )
9797 assert .Errorf (t , err , "expected error for alg %q" , alg )
9898 })
9999 }
100100}
101101
102102func TestLoadDPoPKeyFromPEM_RSA (t * testing.T ) {
103- generated , err := generateDPoPKeyForAlg (dpopAlgRS256 )
103+ generated , err := generateDPoPKeyForAlg (RS256 )
104104 require .NoError (t , err , "failed to generate RSA test key" )
105105 pemBytes := jwkToPEMForTest (t , generated )
106106
@@ -111,16 +111,16 @@ func TestLoadDPoPKeyFromPEM_RSA(t *testing.T) {
111111
112112func TestLoadDPoPKeyFromPEM_EC (t * testing.T ) {
113113 tests := []struct {
114- alg string
114+ alg SigningAlgorithm
115115 wantAlg jwa.SignatureAlgorithm
116116 }{
117- {dpopAlgES256 , jwa .ES256 },
118- {dpopAlgES384 , jwa .ES384 },
119- {dpopAlgES512 , jwa .ES512 },
117+ {ES256 , jwa .ES256 },
118+ {ES384 , jwa .ES384 },
119+ {ES512 , jwa .ES512 },
120120 }
121121
122122 for _ , tt := range tests {
123- t .Run (tt .alg , func (t * testing.T ) {
123+ t .Run (string ( tt .alg ) , func (t * testing.T ) {
124124 generated , err := generateDPoPKeyForAlg (tt .alg )
125125 require .NoError (t , err , "failed to generate EC test key" )
126126 pemBytes := jwkToPEMForTest (t , generated )
@@ -138,8 +138,8 @@ func TestLoadDPoPKeyFromPEM_InvalidPEM(t *testing.T) {
138138}
139139
140140func TestLoadDPoPKeyFromPEM_PublicKeyRejected (t * testing.T ) {
141- for _ , alg := range []string { dpopAlgRS256 , dpopAlgES256 } {
142- t .Run (alg , func (t * testing.T ) {
141+ for _ , alg := range []SigningAlgorithm { RS256 , ES256 } {
142+ t .Run (string ( alg ) , func (t * testing.T ) {
143143 generated , err := generateDPoPKeyForAlg (alg )
144144 require .NoError (t , err , "generate test key" )
145145 pubPEM := publicKeyPEMForTest (t , generated )
@@ -152,7 +152,7 @@ func TestLoadDPoPKeyFromPEM_PublicKeyRejected(t *testing.T) {
152152}
153153
154154func TestResolveDPoPKey (t * testing.T ) {
155- ecKey , err := generateDPoPKeyForAlg (dpopAlgES256 )
155+ ecKey , err := generateDPoPKeyForAlg (ES256 )
156156 require .NoError (t , err , "generate EC key" )
157157 ecPEM := jwkToPEMForTest (t , ecKey )
158158
@@ -177,16 +177,16 @@ func TestResolveDPoPKey(t *testing.T) {
177177 })
178178
179179 t .Run ("PEM with algorithm override" , func (t * testing.T ) {
180- rsaKey , err := generateDPoPKeyForAlg (dpopAlgRS256 )
180+ rsaKey , err := generateDPoPKeyForAlg (RS256 )
181181 require .NoError (t , err , "generate RSA key" )
182- c := & config {dpopKeyPEM : jwkToPEMForTest (t , rsaKey ), dpopAlgorithm : dpopAlgRS512 }
182+ c := & config {dpopKeyPEM : jwkToPEMForTest (t , rsaKey ), dpopAlgorithm : RS512 }
183183 key , err := resolveDPoPKey (c )
184184 require .NoError (t , err )
185185 assert .Equal (t , jwa .RS512 , key .Algorithm (), "alg override" )
186186 })
187187
188188 t .Run ("generate from algorithm" , func (t * testing.T ) {
189- key , err := resolveDPoPKey (& config {dpopAlgorithm : dpopAlgES384 })
189+ key , err := resolveDPoPKey (& config {dpopAlgorithm : ES384 })
190190 require .NoError (t , err )
191191 assert .Equal (t , jwa .ES384 , key .Algorithm (), "alg" )
192192 })
0 commit comments