Skip to content

Commit

Permalink
Based on RedisModuleCommandsTestBase
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Jan 29, 2025
1 parent 2272430 commit 08476a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
public abstract class JedisCommandsTestBase {

@Rule
public RedisVersionRule versionRule = new RedisVersionRule(
HostAndPorts.getRedisEndpoint("standalone0"));
public RedisVersionRule versionRule = new RedisVersionRule(endpoint);
@Rule
public EnabledOnCommandRule enabledOnCommandRule = new EnabledOnCommandRule(
HostAndPorts.getRedisEndpoint("standalone0"));
public EnabledOnCommandRule enabledOnCommandRule = new EnabledOnCommandRule(endpoint);

/**
* Input data for parameterized tests. In principle all subclasses of this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.bloom.RedisBloomProtocol.*;
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;
import redis.clients.jedis.exceptions.JedisAccessControlException;
import redis.clients.jedis.json.JsonProtocol.JsonCommand;
import redis.clients.jedis.search.SearchProtocol.SearchCommand;
Expand All @@ -27,7 +26,7 @@

@SinceRedisVersion(value = "7.9.0")
@RunWith(Parameterized.class)
public class ConsolidatedAccessControlListCommandsTest extends JedisCommandsTestBase {
public class ConsolidatedAccessControlListCommandsTest extends RedisModuleCommandsTestBase {

public static final String USER_NAME = "moduser";
public static final String USER_PASSWORD = "secret";
Expand Down Expand Up @@ -139,7 +138,7 @@ private void grantModuleCommandTest(ProtocolCommand command, Consumer<UnifiedJed
jedis.aclSetUser(USER_NAME, ">" + USER_PASSWORD, "on", "~*");

// client object with new user
try (UnifiedJedis client = new UnifiedJedis(endpoint.getHostAndPort(),
try (UnifiedJedis client = new UnifiedJedis(hnp,
DefaultJedisClientConfig.builder().user(USER_NAME).password(USER_PASSWORD).build())) {

// user can't execute commands
Expand All @@ -161,7 +160,7 @@ private void grantModuleCommandCatTest(String category, ProtocolCommand command,
jedis.aclSetUser(USER_NAME, ">" + USER_PASSWORD, "on", "~*");

// client object with new user
try (UnifiedJedis client = new UnifiedJedis(endpoint.getHostAndPort(),
try (UnifiedJedis client = new UnifiedJedis(hnp,
DefaultJedisClientConfig.builder().user(USER_NAME).password(USER_PASSWORD).build())) {

// user can't execute category commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public abstract class RedisModuleCommandsTestBase {

@Rule
public RedisVersionRule versionRule = new RedisVersionRule(hnp,DefaultJedisClientConfig.builder().build() );
public RedisVersionRule versionRule = new RedisVersionRule(hnp, DefaultJedisClientConfig.builder().build());

/**
* Input data for parameterized tests. In principle all subclasses of this
Expand All @@ -39,6 +39,7 @@ public static Collection<Object[]> data() {
protected static final HostAndPort hnp = HostAndPort.from(address);
protected final RedisProtocol protocol;

protected Jedis jedis;
protected UnifiedJedis client;

/**
Expand All @@ -65,15 +66,15 @@ public static void prepare() {

@Before
public void setUp() {
try (Jedis jedis = new Jedis(hnp)) {
jedis.flushAll();
}
jedis = new Jedis(hnp, DefaultJedisClientConfig.builder().protocol(protocol).build());
jedis.flushAll();
client = new UnifiedJedis(hnp, DefaultJedisClientConfig.builder().protocol(protocol).build());
}

@After
public void tearDown() throws Exception {
client.close();
jedis.close();
}

}

0 comments on commit 08476a4

Please sign in to comment.