apoorvmittal10 commented on code in PR #20164:
URL: https://github.com/apache/kafka/pull/20164#discussion_r2205584011


##########
core/src/test/scala/unit/kafka/server/KafkaApisTest.scala:
##########
@@ -9510,6 +9620,25 @@ class KafkaApisTest extends Logging {
       requestMetrics, envelope = None)
   }
 
+  private def buildRequestWithPrincipal(request: AbstractRequest,
+                                        principal: KafkaPrincipal,
+                                        clientAddress: InetAddress,
+                                        listenerName: ListenerName = 
ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT),
+                                        fromPrivilegedListener: Boolean = 
false,
+                                        requestHeader: Option[RequestHeader],
+                                        requestMetrics: RequestChannelMetrics 
= requestChannelMetrics): RequestChannel.Request = {
+    val buffer = request.serializeWithHeader(
+      requestHeader.getOrElse(new RequestHeader(request.apiKey, 
request.version, clientId, 0)))
+
+    // read the header from the buffer first so that the body can be read next 
from the Request constructor
+    val header = RequestHeader.parse(buffer)
+    val context = new RequestContext(header, "1", clientAddress, 
Optional.empty(),
+      principal, listenerName, SecurityProtocol.SSL,
+      ClientInformation.EMPTY, fromPrivilegedListener, 
Optional.of(kafkaPrincipalSerde))
+    new RequestChannel.Request(processor = 1, context = context, 
startTimeNanos = 0, MemoryPool.NONE, buffer,
+      requestMetrics, envelope = None)
+  }

Review Comment:
   Seems existing `buildRequest` method can be overloaded with this method. So 
we have common code.



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