Skip to content

Commit

Permalink
MINOR: Refactor SSL/SASL admin integration tests to not use a custom …
Browse files Browse the repository at this point in the history
…authorizer (apache#15377)


Reviewers: Mickael Maison <[email protected]>
  • Loading branch information
tinaselenge authored May 24, 2024
1 parent 520aa86 commit c5cd190
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ abstract class BaseAdminIntegrationTest extends IntegrationTestHarness with Logg

@Test
def testCreateDeleteTopics(): Unit = {
client = Admin.create(createConfig)
client = createAdminClient
val topics = Seq("mytopic", "mytopic2", "mytopic3")
val newTopics = Seq(
new NewTopic("mytopic", Map((0: Integer) -> Seq[Integer](1, 2).asJava, (1: Integer) -> Seq[Integer](2, 0).asJava).asJava),
Expand Down Expand Up @@ -163,7 +163,7 @@ abstract class BaseAdminIntegrationTest extends IntegrationTestHarness with Logg

@Test
def testAuthorizedOperations(): Unit = {
client = Admin.create(createConfig)
client = createAdminClient

// without includeAuthorizedOperations flag
var result = client.describeCluster
Expand Down Expand Up @@ -226,12 +226,17 @@ abstract class BaseAdminIntegrationTest extends IntegrationTestHarness with Logg
val config = new util.HashMap[String, Object]
config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers())
config.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, "20000")
val securityProps: util.Map[Object, Object] =
adminClientSecurityConfigs(securityProtocol, trustStoreFile, clientSaslProperties)
securityProps.forEach { (key, value) => config.put(key.asInstanceOf[String], value) }
config.put(AdminClientConfig.DEFAULT_API_TIMEOUT_MS_CONFIG, "40000")
config
}

def createAdminClient: Admin = {
val props = new Properties()
props.putAll(createConfig)
val client = createAdminClient(configOverrides = props)
client
}

def waitForTopics(client: Admin, expectedPresent: Seq[String], expectedMissing: Seq[String]): Unit = {
waitUntilTrue(() => {
val topics = client.listTopics.names.get()
Expand Down
Loading

0 comments on commit c5cd190

Please sign in to comment.