From edf631aec3115f7998b1af04e4452e9f41ca2edc Mon Sep 17 00:00:00 2001 From: atakavci Date: Fri, 20 Dec 2024 03:06:42 +0300 Subject: [PATCH] - review from @sazzad16 : make JedisSafeAuthenticator protected - fix failing unit tests --- .../redis/clients/jedis/JedisSafeAuthenticator.java | 2 +- .../TokenBasedAuthenticationUnitTests.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/redis/clients/jedis/JedisSafeAuthenticator.java b/src/main/java/redis/clients/jedis/JedisSafeAuthenticator.java index 16b72f1684..9c7f95dba1 100644 --- a/src/main/java/redis/clients/jedis/JedisSafeAuthenticator.java +++ b/src/main/java/redis/clients/jedis/JedisSafeAuthenticator.java @@ -16,7 +16,7 @@ import redis.clients.jedis.exceptions.JedisException; import redis.clients.jedis.util.SafeEncoder; -public class JedisSafeAuthenticator { +class JedisSafeAuthenticator { private static final Token PLACEHOLDER_TOKEN = new SimpleToken(null, null, 0, 0, null); private static final Logger logger = LoggerFactory.getLogger(JedisSafeAuthenticator.class); diff --git a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java index ce5f3b9245..802dda2b86 100644 --- a/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java +++ b/src/test/java/redis/clients/jedis/authentication/TokenBasedAuthenticationUnitTests.java @@ -31,6 +31,7 @@ import redis.clients.authentication.core.TokenListener; import redis.clients.authentication.core.TokenManager; import redis.clients.authentication.core.TokenManagerConfig; +import redis.clients.authentication.core.TokenManagerConfig.RetryPolicy; import redis.clients.jedis.ConnectionPool; import redis.clients.jedis.EndpointConfig; import redis.clients.jedis.HostAndPort; @@ -67,7 +68,7 @@ public void withExpirationRefreshRatio_testJedisAuthXManagerTriggersEvict() thro System.currentTimeMillis(), Collections.singletonMap("oid", "default"))); TokenManager tokenManager = new TokenManager(idProvider, - new TokenManagerConfig(0.4F, 100, 1000, null)); + new TokenManagerConfig(0.4F, 100, 1000, new RetryPolicy(1, 1))); AuthXManager jedisAuthXManager = new AuthXManager(tokenManager); AtomicInteger numberOfEvictions = new AtomicInteger(0); @@ -92,7 +93,7 @@ public void withLowerRefreshBounds_testJedisAuthXManagerTriggersEvict() throws E System.currentTimeMillis(), Collections.singletonMap("oid", "default"))); TokenManager tokenManager = new TokenManager(idProvider, - new TokenManagerConfig(0.9F, 600, 1000, null)); + new TokenManagerConfig(0.9F, 600, 1000, new RetryPolicy(1, 1))); AuthXManager jedisAuthXManager = new AuthXManager(tokenManager); AtomicInteger numberOfEvictions = new AtomicInteger(0); @@ -126,6 +127,11 @@ public int getLowerRefreshBoundMillis() { public float getExpirationRefreshRatio() { return ratio; } + + @Override + public RetryPolicy getRetryPolicy() { + return new RetryPolicy(1, 1); + } } @Test @@ -210,7 +216,7 @@ public void testAuthXManagerReceivesNewToken() Collections.singletonMap("oid", "user1")); TokenManager tokenManager = new TokenManager(identityProvider, - new TokenManagerConfig(0.7F, 200, 2000, null)); + new TokenManagerConfig(0.7F, 200, 2000, new RetryPolicy(1, 1))); AuthXManager manager = spy(new AuthXManager(tokenManager));