use of org.apache.kafka.common.metadata.RemoveAccessControlEntryRecord in project kafka by apache.
the class AclControlManagerTest method testAddAndDelete.
@Test
public void testAddAndDelete() {
SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext());
AclControlManager manager = new AclControlManager(snapshotRegistry, Optional.empty());
MockClusterMetadataAuthorizer authorizer = new MockClusterMetadataAuthorizer();
authorizer.loadSnapshot(manager.idToAcl());
manager.replay(StandardAclWithIdTest.TEST_ACLS.get(0).toRecord(), Optional.empty());
assertEquals(new ApiMessageAndVersion(TEST_ACLS.get(0).toRecord(), (short) 0), manager.iterator(Long.MAX_VALUE).next().get(0));
manager.replay(new RemoveAccessControlEntryRecord().setId(TEST_ACLS.get(0).id()), Optional.empty());
assertFalse(manager.iterator(Long.MAX_VALUE).hasNext());
}
use of org.apache.kafka.common.metadata.RemoveAccessControlEntryRecord in project kafka by apache.
the class AclControlManager method deleteAclsForFilter.
AclDeleteResult deleteAclsForFilter(AclBindingFilter filter, List<ApiMessageAndVersion> records) {
List<AclBindingDeleteResult> deleted = new ArrayList<>();
for (Entry<Uuid, StandardAcl> entry : idToAcl.entrySet()) {
Uuid id = entry.getKey();
StandardAcl acl = entry.getValue();
AclBinding binding = acl.toBinding();
if (filter.matches(binding)) {
deleted.add(new AclBindingDeleteResult(binding));
records.add(new ApiMessageAndVersion(new RemoveAccessControlEntryRecord().setId(id), (short) 0));
}
}
return new AclDeleteResult(deleted);
}
Aggregations