File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
main/java/org/keycloak/common/crypto
test/java/org/keycloak/common/crypto Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public static String dumpSecurityProperties() {
9494 }
9595
9696 public static void setProvider (CryptoProvider provider ) {
97- logger .debugf ("Using the crypto provider: %s" , provider .getClass ().getName ());
97+ logger .debugf ("Using the crypto provider: %s" , provider != null ? provider .getClass ().getName () : "null" );
9898 cryptoProvider = provider ;
9999 }
100100}
Original file line number Diff line number Diff line change 1+ package org .keycloak .common .crypto ;
2+
3+ import static org .junit .Assert .assertNull ;
4+
5+ import org .junit .AfterClass ;
6+ import org .junit .BeforeClass ;
7+ import org .junit .Test ;
8+
9+ public class CryptoIntegrationTest {
10+ private static CryptoProvider originalProvider ;
11+
12+ @ BeforeClass
13+ public static void keepOriginalProvider () {
14+ CryptoIntegrationTest .originalProvider = getSelectedProvider ();
15+ }
16+
17+ // doing our best to avoid any side effects on other tests by restoring the initial state of CryptoIntegration
18+ @ AfterClass
19+ public static void restoreOriginalProvider () {
20+ CryptoIntegration .setProvider (originalProvider );
21+ }
22+
23+ @ Test
24+ public void canSetNullProvider () {
25+ CryptoIntegration .setProvider (null );
26+ assertNull (getSelectedProvider ());
27+ }
28+
29+ private static CryptoProvider getSelectedProvider () {
30+ try {
31+ return CryptoIntegration .getProvider ();
32+ } catch (IllegalStateException e ) {
33+ return null ;
34+ }
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments