chia7712 commented on code in PR #19635:
URL: https://github.com/apache/kafka/pull/19635#discussion_r2073486559


##########
core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala:
##########
@@ -924,6 +924,33 @@ class AuthorizerIntegrationTest extends 
AbstractAuthorizerIntegrationTest {
     sendRequests(requestKeyToRequest, false, topicNames)
   }
 
+  @Test
+  def 
testAuthorizationWithTopicNotExistingForProduceReqeustVersionLessThan13(): Unit 
= {

Review Comment:
   ```java
     @Test
     def 
testAuthorizationWithTopicNotExistingForProduceRequestVersionLessThan13(): Unit 
= {
       sendRequests(mutable.Map(ApiKeys.CREATE_TOPICS -> createTopicsRequest))
       def createTpd(version: Int) =
         if (version <= 12) new ProduceRequestData.TopicProduceData()
           .setName(tp.topic())
         else new ProduceRequestData.TopicProduceData()
           .setTopicId(getTopicIds()(tp.topic()))
       for (version <- ApiKeys.PRODUCE.oldestVersion to 
ApiKeys.PRODUCE.latestVersion) {
         val request = requests.ProduceRequest.builder(new ProduceRequestData()
             .setTopicData(new ProduceRequestData.TopicProduceDataCollection(
               util.List.of(createTpd(version)
                   .setPartitionData(util.List.of(
                     new ProduceRequestData.PartitionProduceData()
                       .setIndex(tp.partition)
                       .setRecords(MemoryRecords.withRecords(Compression.NONE, 
new SimpleRecord("test".getBytes))))))
                 .iterator))
             .setAcks(1.toShort)
             .setTimeoutMs(5000))
           .build(version.toShort)
         val data = connectAndReceive[AbstractResponse](request, listenerName = 
listenerName).asInstanceOf[ProduceResponse].data().responses()
         assertEquals(1, data.size())
         val response = if (version <= 12) data.find(tp.topic(), Uuid.ZERO_UUID)
         else data.find("", getTopicIds()(tp.topic()))
         assertEquals(Errors.TOPIC_AUTHORIZATION_FAILED.code(),
           response.partitionResponses().asScala.find(_.index == 
part).get.errorCode, s"unexpected error for produce request version $version")
       }
     }
   ```
   
   we need to test version 13, but it should use topic id instead of topic name.



-- 
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

Reply via email to