@@ -107,39 +107,6 @@ public void encodeWhenJwkSelectFailedThenThrowJwtEncodingException() throws Exce
107107			.withMessageContaining ("Failed to select a JWK signing key -> key source error" );
108108	}
109109
110- 	@ Test 
111- 	public  void  encodeWhenJwkMultipleSelectedThenThrowJwtEncodingException () {
112- 		RSAKey  rsaJwk  = TestJwks .DEFAULT_RSA_JWK ;
113- 		this .jwkList .add (rsaJwk );
114- 		this .jwkList .add (rsaJwk );
115- 
116- 		JwsHeader  jwsHeader  = JwsHeader .with (SignatureAlgorithm .RS256 ).build ();
117- 		JwtClaimsSet  jwtClaimsSet  = TestJwtClaimsSets .jwtClaimsSet ().build ();
118- 
119- 		assertThatExceptionOfType (JwtEncodingException .class )
120- 			.isThrownBy (() -> this .jwtEncoder .encode (JwtEncoderParameters .from (jwsHeader , jwtClaimsSet )))
121- 			.withMessageContaining ("Found multiple JWK signing keys for algorithm 'RS256'" );
122- 	}
123- 
124- 	@ Test 
125- 	public  void  encodeWhenJwkMultipleSelectedWithJwkSelector () {
126- 		RSAKey  rsaJwk  = TestJwks .DEFAULT_RSA_JWK ;
127- 		this .jwkList .add (rsaJwk );
128- 		this .jwkList .add (rsaJwk );
129- 		this .jwtEncoder .setJwkSelector (jwkSelector  -> jwkSelector .get (0 ));
130- 
131- 		JwsHeader  jwsHeader  = JwsHeader .with (SignatureAlgorithm .RS256 ).build ();
132- 		JwtClaimsSet  jwtClaimsSet  = TestJwtClaimsSets .jwtClaimsSet ().build ();
133- 
134- 		Jwt  encodedJws  = this .jwtEncoder .encode (JwtEncoderParameters .from (jwsHeader ,jwtClaimsSet ));
135- 		assertThat (encodedJws .getHeaders ()).containsEntry (JoseHeaderNames .ALG , SignatureAlgorithm .RS256 );
136- 
137- 		this .jwtEncoder .setJwkSelector (jwkSelector  -> jwkSelector .get (jwkSelector .size () - 1 ));
138- 		jwtClaimsSet  = TestJwtClaimsSets .jwtClaimsSet ().build ();
139- 		encodedJws  = this .jwtEncoder .encode (JwtEncoderParameters .from (jwtClaimsSet ));
140- 		assertThat (encodedJws .getHeaders ()).containsEntry (JoseHeaderNames .ALG , SignatureAlgorithm .RS256 );
141- 		this .jwtEncoder .setJwkSelector (null );
142- 	}
143110
144111	@ Test 
145112	public  void  encodeWhenJwkSelectEmptyThenThrowJwtEncodingException () {
0 commit comments