@Test public void testDropLegacyTableWithNonSuperIsRejected() { RoleOptions options = createRoleOptions( Collections.singletonMap("drop_legacy_audit_whitelist_table", "now")); assertThatExceptionOfType(UnauthorizedException.class) .isThrownBy(() -> whitelistManager.alterRoleOption(performer, role, options)); }
void alterRoleOption(AuthenticatedUser performer, RoleResource role, RoleOptions options) { if (!options.getCustomOptions().isPresent()) { return; } if (options.getCustomOptions().get().size() != 1) { throw new InvalidRequestException("Exactly one whitelist option is supported in ALTER ROLE statements"); } Map.Entry<String, String> optionEntry = options.getCustomOptions().get().entrySet().iterator().next(); WhitelistOperation whitelistOperation = whitelistOptionParser.parseWhitelistOperation(optionEntry.getKey()); dispatchOperation(whitelistOperation, performer, role, optionEntry); }
AuditWhitelistManager { void alterRoleOption(AuthenticatedUser performer, RoleResource role, RoleOptions options) { if (!options.getCustomOptions().isPresent()) { return; } if (options.getCustomOptions().get().size() != 1) { throw new InvalidRequestException("Exactly one whitelist option is supported in ALTER ROLE statements"); } Map.Entry<String, String> optionEntry = options.getCustomOptions().get().entrySet().iterator().next(); WhitelistOperation whitelistOperation = whitelistOptionParser.parseWhitelistOperation(optionEntry.getKey()); dispatchOperation(whitelistOperation, performer, role, optionEntry); } }
AuditWhitelistManager { void alterRoleOption(AuthenticatedUser performer, RoleResource role, RoleOptions options) { if (!options.getCustomOptions().isPresent()) { return; } if (options.getCustomOptions().get().size() != 1) { throw new InvalidRequestException("Exactly one whitelist option is supported in ALTER ROLE statements"); } Map.Entry<String, String> optionEntry = options.getCustomOptions().get().entrySet().iterator().next(); WhitelistOperation whitelistOperation = whitelistOptionParser.parseWhitelistOperation(optionEntry.getKey()); dispatchOperation(whitelistOperation, performer, role, optionEntry); } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); }
AuditWhitelistManager { void alterRoleOption(AuthenticatedUser performer, RoleResource role, RoleOptions options) { if (!options.getCustomOptions().isPresent()) { return; } if (options.getCustomOptions().get().size() != 1) { throw new InvalidRequestException("Exactly one whitelist option is supported in ALTER ROLE statements"); } Map.Entry<String, String> optionEntry = options.getCustomOptions().get().entrySet().iterator().next(); WhitelistOperation whitelistOperation = whitelistOptionParser.parseWhitelistOperation(optionEntry.getKey()); dispatchOperation(whitelistOperation, performer, role, optionEntry); } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); void setup(); }
AuditWhitelistManager { void alterRoleOption(AuthenticatedUser performer, RoleResource role, RoleOptions options) { if (!options.getCustomOptions().isPresent()) { return; } if (options.getCustomOptions().get().size() != 1) { throw new InvalidRequestException("Exactly one whitelist option is supported in ALTER ROLE statements"); } Map.Entry<String, String> optionEntry = options.getCustomOptions().get().entrySet().iterator().next(); WhitelistOperation whitelistOperation = whitelistOptionParser.parseWhitelistOperation(optionEntry.getKey()); dispatchOperation(whitelistOperation, performer, role, optionEntry); } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); void setup();  }