Skip to content

Commit f30c278

Browse files
committed
Harden test reflection and log fallback
1 parent 6251adb commit f30c278

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

sdk/spring/scripts/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
try:
88
from termcolor import colored
99
except ImportError:
10-
def colored(content, _):
10+
def colored(content, *args, **kwargs):
1111
return content
1212

1313

sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/aad/configuration/AadResourceServerConfigurationTests.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,10 @@ private static void verifyJwtDecoderRestTemplateTimeouts(ApplicationContext cont
460460
int expectedConnectTimeoutMs,
461461
int expectedReadTimeoutMs) {
462462
RemoteJWKSet<?> remoteJwkSet = getRemoteJwkSet(jwtDecoder);
463-
Object resourceRetriever = ReflectionTestUtils.getField(remoteJwkSet, "jwkSetRetriever");
463+
Object resourceRetriever = getFieldIfExists(remoteJwkSet, "resourceRetriever");
464+
if (resourceRetriever == null) {
465+
resourceRetriever = getFieldIfExists(remoteJwkSet, "jwkSetRetriever");
466+
}
464467
assertThat(resourceRetriever).isInstanceOf(RestOperationsResourceRetriever.class);
465468

466469
Object restOperations = ReflectionTestUtils.getField(resourceRetriever, "restOperations");
@@ -506,4 +509,12 @@ private static Object getJwkSource(JwtDecoder jwtDecoder) {
506509
((com.nimbusds.jose.proc.JWSVerificationKeySelector<?>) keySelector).getJWKSource();
507510
return jwkSource;
508511
}
512+
513+
private static Object getFieldIfExists(Object target, String name) {
514+
try {
515+
return ReflectionTestUtils.getField(target, name);
516+
} catch (IllegalArgumentException ignored) {
517+
return null;
518+
}
519+
}
509520
}

0 commit comments

Comments
 (0)