MINOR: Avoid leaking threads in DelegationTokenEndToEndAuthorizationWithOwnerTest.testDescribeTokenForOtherUserFails (#14959)

Reviewers: Lucas Brutschy <lbrutschy@confluent.io>
This commit is contained in:
David Jacot 2023-12-08 08:23:08 +01:00 committed by GitHub
parent b96ded9859
commit 38c873b80f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -105,17 +105,14 @@ class DelegationTokenEndToEndAuthorizationWithOwnerTest extends DelegationTokenE
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
@ValueSource(strings = Array("kraft", "zk"))
def testDescribeTokenForOtherUserFails(quorum: String): Unit = {
val describeTokenFailAdminClient = createScramAdminClient(kafkaClientSaslMechanism, describeTokenFailPrincipal.getName, describeTokenFailPassword)
val otherClientAdminClient = createScramAdminClient(kafkaClientSaslMechanism, otherClientPrincipal.getName, otherClientPassword)
try {
otherClientAdminClient.createDelegationToken().delegationToken().get()
val tokens = describeTokenFailAdminClient.describeDelegationToken(
new DescribeDelegationTokenOptions().owners(Collections.singletonList(otherClientPrincipal)))
.delegationTokens.get.asScala
assertTrue(tokens.isEmpty)
} finally {
describeTokenFailAdminClient.close()
otherClientAdminClient.close()
TestUtils.resource(createScramAdminClient(kafkaClientSaslMechanism, describeTokenFailPrincipal.getName, describeTokenFailPassword)) { describeTokenFailAdminClient =>
TestUtils.resource(createScramAdminClient(kafkaClientSaslMechanism, otherClientPrincipal.getName, otherClientPassword)) { otherClientAdminClient =>
otherClientAdminClient.createDelegationToken().delegationToken().get()
val tokens = describeTokenFailAdminClient.describeDelegationToken(
new DescribeDelegationTokenOptions().owners(Collections.singletonList(otherClientPrincipal))
).delegationTokens.get.asScala
assertTrue(tokens.isEmpty)
}
}
}