m1a2st commented on code in PR #19635: URL: https://github.com/apache/kafka/pull/19635#discussion_r2072616754
########## core/src/test/scala/unit/kafka/server/KafkaApisTest.scala: ########## @@ -2354,6 +2354,65 @@ class KafkaApisTest extends Logging { } } + @Test + def shouldReturnUnauthorizationForNonExistingTopicInProduceResponse(): Unit = { + val topic = "topic" + val topicId = Uuid.fromString("d2Gg8tgzJa2JYK2eTHUapg") + val tp = new TopicIdPartition(topicId, 0, topic) + + val authorizer: Authorizer = mock(classOf[Authorizer]) + when(authorizer.authorize(any[RequestContext], any[util.List[Action]])) + .thenReturn(Seq(AuthorizationResult.DENIED).asJava) + for (version <- ApiKeys.PRODUCE.oldestVersion to ApiKeys.PRODUCE.latestVersion) { + + reset(replicaManager, clientQuotaManager, clientRequestQuotaManager, requestChannel, txnCoordinator) + + val produceData = new ProduceRequestData.TopicProduceData() + .setPartitionData(Collections.singletonList( Review Comment: ```suggestion .setPartitionData(util.List.of( ``` ########## core/src/test/scala/unit/kafka/server/KafkaApisTest.scala: ########## @@ -2354,6 +2354,65 @@ class KafkaApisTest extends Logging { } } + @Test + def shouldReturnUnauthorizationForNonExistingTopicInProduceResponse(): Unit = { + val topic = "topic" + val topicId = Uuid.fromString("d2Gg8tgzJa2JYK2eTHUapg") + val tp = new TopicIdPartition(topicId, 0, topic) + + val authorizer: Authorizer = mock(classOf[Authorizer]) + when(authorizer.authorize(any[RequestContext], any[util.List[Action]])) + .thenReturn(Seq(AuthorizationResult.DENIED).asJava) + for (version <- ApiKeys.PRODUCE.oldestVersion to ApiKeys.PRODUCE.latestVersion) { + + reset(replicaManager, clientQuotaManager, clientRequestQuotaManager, requestChannel, txnCoordinator) + + val produceData = new ProduceRequestData.TopicProduceData() + .setPartitionData(Collections.singletonList( + new ProduceRequestData.PartitionProduceData() + .setIndex(tp.partition) + .setRecords(MemoryRecords.withRecords(Compression.NONE, new SimpleRecord("test".getBytes))))) + + if (version >= 13 ) { + produceData.setTopicId(topicId) + } else { + produceData.setName(tp.topic) + } + + val produceRequest = ProduceRequest.builder(new ProduceRequestData() + .setTopicData(new ProduceRequestData.TopicProduceDataCollection( + Collections.singletonList(produceData) Review Comment: ```suggestion util.List.of(produceData) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org