Skip to content

Commit bfb09aa

Browse files
author
Valentin Brückel
committed
make sleep dependent on configured refresh interval
1 parent 95395fc commit bfb09aa

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

core/src/test/java/com/predic8/membrane/core/interceptor/jwt/JwksRefreshTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class JwksRefreshTest {
3434

3535
public static final int PROVIDER_PORT = 3000;
3636
public static final int AUTH_INTERCEPTOR_PORT = 3001;
37+
public static final int JWKS_REFRESH_INTERVAL = 1;
3738
static DefaultRouter jwksProvider;
3839
static DefaultRouter jwtValidator;
3940

@@ -89,7 +90,7 @@ public Outcome handleRequest(Exchange exc) {
8990
private static @NotNull JwtAuthInterceptor jwtAuthInterceptor() {
9091
Jwks jwks = new Jwks();
9192
jwks.setJwksUris("http://localhost:%d/jwks".formatted(PROVIDER_PORT));
92-
jwks.setAuthorizationService(buildAuthorizationService(1));
93+
jwks.setAuthorizationService(buildAuthorizationService(JWKS_REFRESH_INTERVAL));
9394

9495
JwtAuthInterceptor jwtAuth = new JwtAuthInterceptor();
9596
jwtAuth.setExpectedAud("some-audience");
@@ -147,7 +148,7 @@ public void testRefresh() throws Exception {
147148

148149
// 2. switch keys
149150
currentJwkSet.set(new JsonWebKeySet(publicKey2));
150-
Thread.sleep(2000); // wait for refresh
151+
Thread.sleep(JWKS_REFRESH_INTERVAL * 1_000 * 2); // wait for refresh
151152

152153
// 3. new key works
153154
Exchange exc3 = new Request.Builder()

0 commit comments

Comments
 (0)