Merge branch 'cassandra-4.1' into cassandra-5.0

This commit is contained in:
Stefan Miklosovic 2026-06-24 13:11:36 +02:00
commit 4b821d1bc7
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
1 changed files with 19 additions and 7 deletions

View File

@ -70,7 +70,7 @@ public class CassandraRoleManagerTest
public void getGrantedRolesImplMinimizesReads() public void getGrantedRolesImplMinimizesReads()
{ {
// IRoleManager::getRoleDetails was not in the initial API, so a default impl // IRoleManager::getRoleDetails was not in the initial API, so a default impl
// was added which uses the existing methods on IRoleManager as primitive to // was added which uses the existing methods on IRoleManager as primitives to
// construct the Role objects. While this will work for any IRoleManager impl // construct the Role objects. While this will work for any IRoleManager impl
// it is inefficient, so CassandraRoleManager has its own implementation which // it is inefficient, so CassandraRoleManager has its own implementation which
// collects all of the necessary info with a single query for each granted role. // collects all of the necessary info with a single query for each granted role.
@ -93,7 +93,7 @@ public class CassandraRoleManagerTest
fetchRolesAndCheckReadCount(roleManager, ROLE_A); fetchRolesAndCheckReadCount(roleManager, ROLE_A);
// Check that when granted roles appear multiple times in parallel levels of the hierarchy, we don't // Check that when granted roles appear multiple times in parallel levels of the hierarchy, we don't
// do redundant reads. E.g. here role_b_1, role_b_2 and role_b3 are granted to both role_b and role_c // do redundant reads. E.g. here role_b_1, role_b_2 and role_b_3 are granted to both role_b and role_c
// but we only want to actually read them once // but we only want to actually read them once
grantRolesTo(roleManager, ROLE_C, ROLE_B_1, ROLE_B_2, ROLE_B_3); grantRolesTo(roleManager, ROLE_C, ROLE_B_1, ROLE_B_2, ROLE_B_3);
fetchRolesAndCheckReadCount(roleManager, ROLE_A); fetchRolesAndCheckReadCount(roleManager, ROLE_A);
@ -154,6 +154,7 @@ public class CassandraRoleManagerTest
} }
} }
@Test
public void testPasswordUpdateRateLimiting() throws Exception public void testPasswordUpdateRateLimiting() throws Exception
{ {
try try
@ -183,7 +184,7 @@ public class CassandraRoleManagerTest
} }
catch (OverloadedException e) catch (OverloadedException e)
{ {
assertEquals("Password for role test_password_role can only be changed every 100ms. ", e.getMessage()); assertEquals("Password for role test_password_role can only be changed every 100ms.", e.getMessage());
} }
// Wait for the rate limit interval to pass // Wait for the rate limit interval to pass
@ -262,15 +263,12 @@ public class CassandraRoleManagerTest
RoleOptions options2 = getLoginRoleOptions("password2"); RoleOptions options2 = getLoginRoleOptions("password2");
roleManager.createRole(AuthenticatedUser.ANONYMOUS_USER, role2, options2); roleManager.createRole(AuthenticatedUser.ANONYMOUS_USER, role2, options2);
// Wait for the rate limit interval to pass // Wait for the rate limit interval to pass since creation
Thread.sleep(150); Thread.sleep(150);
RoleOptions newOptions1 = getLoginRoleOptions("new_password1"); RoleOptions newOptions1 = getLoginRoleOptions("new_password1");
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role1, newOptions1); roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role1, newOptions1);
RoleOptions newOptions2 = getLoginRoleOptions("new_password2");
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role2, newOptions2);
try try
{ {
RoleOptions newOptions1Again = getLoginRoleOptions("another_password1"); RoleOptions newOptions1Again = getLoginRoleOptions("another_password1");
@ -282,6 +280,20 @@ public class CassandraRoleManagerTest
assertEquals("Password for role test_role_1 can only be changed every 100ms.", e.getMessage()); assertEquals("Password for role test_role_1 can only be changed every 100ms.", e.getMessage());
} }
RoleOptions newOptions2 = getLoginRoleOptions("new_password2");
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role2, newOptions2);
try
{
RoleOptions newOptions2Again = getLoginRoleOptions("another_password2");
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role2, newOptions2Again);
fail("Expected OverloadedException for test_role_2");
}
catch (OverloadedException e)
{
assertEquals("Password for role test_role_2 can only be changed every 100ms.", e.getMessage());
}
roleManager.dropRole(AuthenticatedUser.ANONYMOUS_USER, role1); roleManager.dropRole(AuthenticatedUser.ANONYMOUS_USER, role1);
roleManager.dropRole(AuthenticatedUser.ANONYMOUS_USER, role2); roleManager.dropRole(AuthenticatedUser.ANONYMOUS_USER, role2);
} }