use of org.apache.cassandra.auth.AuthenticatedUser in project cassandra by apache.
the class InvalidateNetworkPermissionsCacheTest method testInvalidateSingleNetworkPermission.
@Test
public void testInvalidateSingleNetworkPermission() {
AuthenticatedUser role = new AuthenticatedUser(ROLE_A.getRoleName());
// cache network permission
role.hasLocalAccess();
long originalReadsCount = getNetworkPermissionsReadCount();
// enure network permission is cached
assertThat(role.hasLocalAccess()).isTrue();
assertThat(originalReadsCount).isEqualTo(getNetworkPermissionsReadCount());
// invalidate network permission
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("invalidatenetworkpermissionscache", ROLE_A.getRoleName());
tool.assertOnCleanExit();
assertThat(tool.getStdout()).isEmpty();
// ensure network permission is reloaded
assertThat(role.hasLocalAccess()).isTrue();
assertThat(originalReadsCount).isLessThan(getNetworkPermissionsReadCount());
}
use of org.apache.cassandra.auth.AuthenticatedUser in project cassandra by apache.
the class InvalidateRolesCacheTest method testInvalidateSingleRole.
@Test
public void testInvalidateSingleRole() {
AuthenticatedUser role = new AuthenticatedUser(ROLE_A.getRoleName());
// cache role
role.canLogin();
long originalReadsCount = getRolesReadCount();
// enure role is cached
assertThat(role.canLogin()).isTrue();
assertThat(originalReadsCount).isEqualTo(getRolesReadCount());
// invalidate role
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("invalidaterolescache", ROLE_A.getRoleName());
tool.assertOnCleanExit();
assertThat(tool.getStdout()).isEmpty();
// ensure role is reloaded
assertThat(role.canLogin()).isTrue();
assertThat(originalReadsCount).isLessThan(getRolesReadCount());
}
use of org.apache.cassandra.auth.AuthenticatedUser in project cassandra by apache.
the class InvalidateRolesCacheTest method testInvalidateAllRoles.
@Test
public void testInvalidateAllRoles() {
AuthenticatedUser roleA = new AuthenticatedUser(ROLE_A.getRoleName());
AuthenticatedUser roleB = new AuthenticatedUser(ROLE_B.getRoleName());
// cache roles
roleA.canLogin();
roleB.canLogin();
long originalReadsCount = getRolesReadCount();
// enure roles are cached
assertThat(roleA.canLogin()).isTrue();
assertThat(roleB.canLogin()).isTrue();
assertThat(originalReadsCount).isEqualTo(getRolesReadCount());
// invalidate both roles
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("invalidaterolescache");
tool.assertOnCleanExit();
assertThat(tool.getStdout()).isEmpty();
// ensure role for roleA is reloaded
assertThat(roleA.canLogin()).isTrue();
long readsCountAfterFirstReLoad = getRolesReadCount();
assertThat(originalReadsCount).isLessThan(readsCountAfterFirstReLoad);
// ensure role for roleB is reloaded
assertThat(roleB.canLogin()).isTrue();
long readsCountAfterSecondReLoad = getRolesReadCount();
assertThat(readsCountAfterFirstReLoad).isLessThan(readsCountAfterSecondReLoad);
}
Aggregations