@@ -35,7 +35,7 @@ import org.apache.kafka.common.compress.Compression
35
35
import org .apache .kafka .common .config .ConfigResource
36
36
import org .apache .kafka .common .config .ConfigResource .Type .{BROKER , BROKER_LOGGER }
37
37
import org .apache .kafka .common .errors .{ClusterAuthorizationException , UnsupportedVersionException }
38
- import org .apache .kafka .common .internals .{ KafkaFutureImpl , Topic }
38
+ import org .apache .kafka .common .internals .Topic
39
39
import org .apache .kafka .common .memory .MemoryPool
40
40
import org .apache .kafka .common .message .AddPartitionsToTxnRequestData .{AddPartitionsToTxnTopic , AddPartitionsToTxnTopicCollection , AddPartitionsToTxnTransaction , AddPartitionsToTxnTransactionCollection }
41
41
import org .apache .kafka .common .message .AddPartitionsToTxnResponseData .AddPartitionsToTxnResult
@@ -61,7 +61,6 @@ import org.apache.kafka.common.message._
61
61
import org .apache .kafka .common .metrics .Metrics
62
62
import org .apache .kafka .common .network .{ClientInformation , ListenerName }
63
63
import org .apache .kafka .common .protocol .{ApiKeys , Errors , MessageUtil }
64
- import org .apache .kafka .common .quota .{ClientQuotaAlteration , ClientQuotaEntity }
65
64
import org .apache .kafka .common .record ._
66
65
import org .apache .kafka .common .requests .FindCoordinatorRequest .CoordinatorType
67
66
import org .apache .kafka .common .requests .MetadataResponse .TopicMetadata
@@ -730,48 +729,6 @@ class KafkaApisTest extends Logging {
730
729
assertEquals(expectedResults, responseMap)
731
730
}
732
731
733
- @ Test
734
- def testAlterClientQuotasWithAuthorizer (): Unit = {
735
- val authorizer : Authorizer = mock(classOf [Authorizer ])
736
-
737
- authorizeResource(authorizer, AclOperation .ALTER_CONFIGS , ResourceType .CLUSTER ,
738
- Resource .CLUSTER_NAME , AuthorizationResult .DENIED )
739
-
740
- val quotaEntity = new ClientQuotaEntity (Collections .singletonMap(ClientQuotaEntity .USER , " user" ))
741
- val quotas = Seq (new ClientQuotaAlteration (quotaEntity, Seq .empty.asJavaCollection))
742
-
743
- val requestHeader = new RequestHeader (ApiKeys .ALTER_CLIENT_QUOTAS , ApiKeys .ALTER_CLIENT_QUOTAS .latestVersion, clientId, 0 )
744
-
745
- val alterClientQuotasRequest = new AlterClientQuotasRequest .Builder (quotas.asJavaCollection, false )
746
- .build(requestHeader.apiVersion)
747
- val request = buildRequest(alterClientQuotasRequest,
748
- fromPrivilegedListener = true , requestHeader = Option (requestHeader))
749
-
750
- when(controller.isActive).thenReturn(true )
751
- when(clientRequestQuotaManager.maybeRecordAndGetThrottleTimeMs(any[RequestChannel .Request ](),
752
- anyLong)).thenReturn(0 )
753
- kafkaApis = createKafkaApis(authorizer = Some (authorizer))
754
- kafkaApis.handleAlterClientQuotasRequest(request)
755
-
756
- val capturedResponse = verifyNoThrottling[AlterClientQuotasResponse ](request)
757
- verifyAlterClientQuotaResult(capturedResponse, Map (quotaEntity -> Errors .CLUSTER_AUTHORIZATION_FAILED ))
758
-
759
- verify(authorizer).authorize(any(), any())
760
- verify(clientRequestQuotaManager).maybeRecordAndGetThrottleTimeMs(any(), anyLong)
761
- }
762
-
763
- private def verifyAlterClientQuotaResult (response : AlterClientQuotasResponse ,
764
- expected : Map [ClientQuotaEntity , Errors ]): Unit = {
765
- val futures = expected.keys.map(quotaEntity => quotaEntity -> new KafkaFutureImpl [Void ]()).toMap
766
- response.complete(futures.asJava)
767
- futures.foreach {
768
- case (entity, future) =>
769
- future.whenComplete((_, thrown) =>
770
- assertEquals(thrown, expected(entity).exception())
771
- ).isDone
772
- }
773
- }
774
-
775
732
@ ParameterizedTest
776
733
@ CsvSource (value = Array (" 0,1500" , " 1500,0" , " 3000,1000" ))
777
734
def testKRaftControllerThrottleTimeEnforced (
@@ -10027,13 +9984,6 @@ class KafkaApisTest extends Logging {
10027
9984
setResourceType(BROKER_LOGGER .id()))),
10028
9985
response.data())
10029
9986
}
10030
-
10031
- @ Test
10032
- def testRaftShouldAlwaysForwardAlterClientQuotasRequest (): Unit = {
10033
- metadataCache = MetadataCache .kRaftMetadataCache(brokerId, () => KRaftVersion .KRAFT_VERSION_0 )
10034
- kafkaApis = createKafkaApis(raftSupport = true )
10035
- verifyShouldAlwaysForwardErrorMessage(kafkaApis.handleAlterClientQuotasRequest)
10036
- }
10037
9987
10038
9988
@ Test
10039
9989
def testConsumerGroupHeartbeatReturnsUnsupportedVersion (): Unit = {
0 commit comments