Skip to content

Commit 4b821d1

Browse files
committed
Merge branch 'cassandra-4.1' into cassandra-5.0
2 parents a3ee4c4 + 19dcb2b commit 4b821d1

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

test/unit/org/apache/cassandra/auth/CassandraRoleManagerTest.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void setup() throws Exception
7070
public void getGrantedRolesImplMinimizesReads()
7171
{
7272
// IRoleManager::getRoleDetails was not in the initial API, so a default impl
73-
// was added which uses the existing methods on IRoleManager as primitive to
73+
// was added which uses the existing methods on IRoleManager as primitives to
7474
// construct the Role objects. While this will work for any IRoleManager impl
7575
// it is inefficient, so CassandraRoleManager has its own implementation which
7676
// collects all of the necessary info with a single query for each granted role.
@@ -93,7 +93,7 @@ public void getGrantedRolesImplMinimizesReads()
9393
fetchRolesAndCheckReadCount(roleManager, ROLE_A);
9494

9595
// Check that when granted roles appear multiple times in parallel levels of the hierarchy, we don't
96-
// do redundant reads. E.g. here role_b_1, role_b_2 and role_b3 are granted to both role_b and role_c
96+
// 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
9797
// but we only want to actually read them once
9898
grantRolesTo(roleManager, ROLE_C, ROLE_B_1, ROLE_B_2, ROLE_B_3);
9999
fetchRolesAndCheckReadCount(roleManager, ROLE_A);
@@ -154,6 +154,7 @@ public void warmCacheLoadsAllEntries()
154154
}
155155
}
156156

157+
@Test
157158
public void testPasswordUpdateRateLimiting() throws Exception
158159
{
159160
try
@@ -183,7 +184,7 @@ public void testPasswordUpdateRateLimiting() throws Exception
183184
}
184185
catch (OverloadedException e)
185186
{
186-
assertEquals("Password for role test_password_role can only be changed every 100ms. ", e.getMessage());
187+
assertEquals("Password for role test_password_role can only be changed every 100ms.", e.getMessage());
187188
}
188189

189190
// Wait for the rate limit interval to pass
@@ -262,15 +263,12 @@ public void testPasswordUpdateRateLimitingPerRole() throws Exception
262263
RoleOptions options2 = getLoginRoleOptions("password2");
263264
roleManager.createRole(AuthenticatedUser.ANONYMOUS_USER, role2, options2);
264265

265-
// Wait for the rate limit interval to pass
266+
// Wait for the rate limit interval to pass since creation
266267
Thread.sleep(150);
267268

268269
RoleOptions newOptions1 = getLoginRoleOptions("new_password1");
269270
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role1, newOptions1);
270271

271-
RoleOptions newOptions2 = getLoginRoleOptions("new_password2");
272-
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role2, newOptions2);
273-
274272
try
275273
{
276274
RoleOptions newOptions1Again = getLoginRoleOptions("another_password1");
@@ -282,6 +280,20 @@ public void testPasswordUpdateRateLimitingPerRole() throws Exception
282280
assertEquals("Password for role test_role_1 can only be changed every 100ms.", e.getMessage());
283281
}
284282

283+
RoleOptions newOptions2 = getLoginRoleOptions("new_password2");
284+
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role2, newOptions2);
285+
286+
try
287+
{
288+
RoleOptions newOptions2Again = getLoginRoleOptions("another_password2");
289+
roleManager.alterRole(AuthenticatedUser.ANONYMOUS_USER, role2, newOptions2Again);
290+
fail("Expected OverloadedException for test_role_2");
291+
}
292+
catch (OverloadedException e)
293+
{
294+
assertEquals("Password for role test_role_2 can only be changed every 100ms.", e.getMessage());
295+
}
296+
285297
roleManager.dropRole(AuthenticatedUser.ANONYMOUS_USER, role1);
286298
roleManager.dropRole(AuthenticatedUser.ANONYMOUS_USER, role2);
287299
}

0 commit comments

Comments
 (0)