You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2018/06/15 13:29:02 UTC
[kafka] branch 2.0 updated: MINOR: Test authorization of
MetadataRequest with existing and non-existing topics (#5155)
This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.0 by this push:
new 410573b MINOR: Test authorization of MetadataRequest with existing and non-existing topics (#5155)
410573b is described below
commit 410573b0d4539d2917dc5cf2570fd6b90974a68d
Author: Edoardo Comar <ec...@uk.ibm.com>
AuthorDate: Wed Jun 13 01:35:26 2018 +0100
MINOR: Test authorization of MetadataRequest with existing and non-existing topics (#5155)
A bug in the original KIP-277 submission was caught during code review,
but it was not detected by the tests. Fix that gap.
Co-authored-by: Edoardo Comar <ec...@uk.ibm.com>
Co-authored-by: Mickael Maison <mi...@gmail.com>
---
.../kafka/api/AuthorizerIntegrationTest.scala | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala b/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala
index c5df68b..177dcaf 100644
--- a/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala
@@ -45,6 +45,8 @@ import org.apache.kafka.common.resource.PatternType.LITERAL
import org.apache.kafka.common.resource.{ResourcePattern, ResourcePatternFilter, ResourceType => AdminResourceType}
import org.apache.kafka.common.security.auth.{KafkaPrincipal, SecurityProtocol}
import org.apache.kafka.common.{KafkaException, Node, TopicPartition, requests}
+import org.apache.kafka.test.{TestUtils => JTestUtils}
+
import org.junit.Assert._
import org.junit.{After, Assert, Before, Test}
@@ -862,6 +864,31 @@ class AuthorizerIntegrationTest extends BaseRequestTest {
}, "Expected topic was not created")
}
+ @Test
+ def testCreatePermissionMetadataRequestAutoCreate() {
+ val readAcls = topicReadAcl.get(topicResource).get
+ addAndVerifyAcls(readAcls, topicResource)
+ assertTrue(zkClient.topicExists(topicResource.name))
+
+ addAndVerifyAcls(readAcls, createTopicResource)
+ assertFalse(zkClient.topicExists(createTopic))
+
+ val metadataRequest = new MetadataRequest.Builder(List(topic, createTopic).asJava, true).build()
+ val metadataResponse = MetadataResponse.parse(connectAndSend(metadataRequest, ApiKeys.METADATA), ApiKeys.METADATA.latestVersion)
+
+ assertEquals(Set(topic).asJava, metadataResponse.topicsByError(Errors.NONE));
+ assertEquals(Set(createTopic).asJava, metadataResponse.topicsByError(Errors.TOPIC_AUTHORIZATION_FAILED))
+
+ val createAcls = topicCreateAcl.get(createTopicResource).get
+ addAndVerifyAcls(createAcls, createTopicResource)
+
+ // retry as topic being created can have MetadataResponse with Errors.LEADER_NOT_AVAILABLE
+ TestUtils.retry(JTestUtils.DEFAULT_MAX_WAIT_MS)(() => {
+ val metadataResponse = MetadataResponse.parse(connectAndSend(metadataRequest, ApiKeys.METADATA), ApiKeys.METADATA.latestVersion)
+ assertEquals(Set(topic, createTopic).asJava, metadataResponse.topicsByError(Errors.NONE))
+ })
+ }
+
@Test(expected = classOf[AuthorizationException])
def testCommitWithNoAccess() {
this.consumers.head.commitSync(Map(tp -> new OffsetAndMetadata(5)).asJava)
--
To stop receiving notification emails like this one, please contact
ijuma@apache.org.