use of org.apache.kafka.common.errors.GroupAuthorizationException in project rest-utils by confluentinc.
the class KafkaExceptionMapperTest method testAuthorizationExceptions.
@Test
public void testAuthorizationExceptions() {
verifyMapperResponse(new AuthorizationException("some message"), Status.FORBIDDEN, KAFKA_AUTHORIZATION_ERROR_CODE);
verifyMapperResponse(new ClusterAuthorizationException("some message"), Status.FORBIDDEN, KAFKA_AUTHORIZATION_ERROR_CODE);
verifyMapperResponse(new DelegationTokenAuthorizationException("some message"), Status.FORBIDDEN, KAFKA_AUTHORIZATION_ERROR_CODE);
verifyMapperResponse(new GroupAuthorizationException("some message"), Status.FORBIDDEN, KAFKA_AUTHORIZATION_ERROR_CODE);
verifyMapperResponse(new TopicAuthorizationException("some message"), Status.FORBIDDEN, KAFKA_AUTHORIZATION_ERROR_CODE);
verifyMapperResponse(new TransactionalIdAuthorizationException("some message"), Status.FORBIDDEN, KAFKA_AUTHORIZATION_ERROR_CODE);
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testGroupAuthorizationFailureInTxnOffsetCommit.
@Test
public void testGroupAuthorizationFailureInTxnOffsetCommit() {
final String consumerGroupId = "consumer";
final long pid = 13131L;
final short epoch = 1;
final TopicPartition tp = new TopicPartition("foo", 0);
doInitTransactions(pid, epoch);
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp, new OffsetAndMetadata(39L)), consumerGroupId);
prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, pid, epoch);
// AddOffsetsToTxn Handled, TxnOffsetCommit Enqueued
sender.run(time.milliseconds());
// FindCoordinator Enqueued
sender.run(time.milliseconds());
prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.GROUP, consumerGroupId);
// FindCoordinator Returned
sender.run(time.milliseconds());
prepareTxnOffsetCommitResponse(consumerGroupId, pid, epoch, singletonMap(tp, Errors.GROUP_AUTHORIZATION_FAILED));
// TxnOffsetCommit Handled
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof GroupAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) sendOffsetsResult.error();
assertEquals(consumerGroupId, exception.groupId());
assertAbortableError(GroupAuthorizationException.class);
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testGroupAuthorizationFailureInFindCoordinator.
@Test
public void testGroupAuthorizationFailureInFindCoordinator() {
final String consumerGroupId = "consumer";
final long pid = 13131L;
final short epoch = 1;
doInitTransactions(pid, epoch);
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(new TopicPartition("foo", 0), new OffsetAndMetadata(39L)), consumerGroupId);
prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, pid, epoch);
// AddOffsetsToTxn Handled, TxnOffsetCommit Enqueued
sender.run(time.milliseconds());
// FindCoordinator Enqueued
sender.run(time.milliseconds());
prepareFindCoordinatorResponse(Errors.GROUP_AUTHORIZATION_FAILED, false, CoordinatorType.GROUP, consumerGroupId);
// FindCoordinator Failed
sender.run(time.milliseconds());
// TxnOffsetCommit Aborted
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof GroupAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) sendOffsetsResult.error();
assertEquals(consumerGroupId, exception.groupId());
assertAbortableError(GroupAuthorizationException.class);
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project kafka by apache.
the class TransactionManagerTest method testGroupAuthorizationFailureInTxnOffsetCommit.
@Test
public void testGroupAuthorizationFailureInTxnOffsetCommit() {
final TopicPartition tp1 = new TopicPartition("foo", 0);
doInitTransactions();
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp1, new OffsetAndMetadata(39L)), new ConsumerGroupMetadata(consumerGroupId));
prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, producerId, epoch);
runUntil(() -> !transactionManager.hasPartitionsToAdd());
prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.GROUP, consumerGroupId);
prepareTxnOffsetCommitResponse(consumerGroupId, producerId, epoch, singletonMap(tp1, Errors.GROUP_AUTHORIZATION_FAILED));
runUntil(transactionManager::hasError);
assertTrue(transactionManager.lastError() instanceof GroupAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof GroupAuthorizationException);
assertFalse(transactionManager.hasPendingOffsetCommits());
GroupAuthorizationException exception = (GroupAuthorizationException) sendOffsetsResult.error();
assertEquals(consumerGroupId, exception.groupId());
assertAbortableError(GroupAuthorizationException.class);
}
Aggregations