This repository has been archived by the owner on May 9, 2023. It is now read-only.
forked from zio/zio-kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
586 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
zio-kafka-test/src/test/scala/zio/kafka/AdminSaslSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package zio.kafka | ||
|
||
import zio.Scope | ||
import zio.test.Assertion._ | ||
import zio.test.TestAspect._ | ||
import zio.test._ | ||
import zio._ | ||
import zio.kafka.admin.acl.AclBindingFilter | ||
import zio.kafka.admin.resource.ResourcePatternFilter | ||
import zio.kafka.admin.acl.AccessControlEntryFilter | ||
import zio.kafka.admin.acl.AclBinding | ||
import zio.kafka.admin.resource.ResourcePattern | ||
import zio.kafka.admin.acl.AccessControlEntry | ||
import zio.kafka.admin.acl.AclPermissionType | ||
import zio.kafka.admin.acl.AclOperation | ||
import zio.kafka.admin.resource.ResourceType | ||
import zio.kafka.admin.resource.PatternType | ||
import java.util.concurrent.TimeoutException | ||
|
||
object AdminSaslSpec extends ZIOSpecWithSaslKafka { | ||
|
||
override def kafkaPrefix: String = "adminsaslspec" | ||
|
||
override def spec: Spec[Environment with TestEnvironment with Scope, Any] = | ||
suite("client sasl admin test")( | ||
test("ACLs") { | ||
KafkaTestUtils.withSaslAdmin() { client => | ||
for { | ||
topic <- randomTopic | ||
bindings = | ||
Set( | ||
AclBinding( | ||
ResourcePattern(ResourceType.Topic, name = topic, patternType = PatternType.Literal), | ||
AccessControlEntry( | ||
principal = "User:*", | ||
host = "*", | ||
operation = AclOperation.Write, | ||
permissionType = AclPermissionType.Allow | ||
) | ||
) | ||
) | ||
_ <- client.createAcls(bindings) | ||
createdAcls <- | ||
client | ||
.describeAcls(AclBindingFilter(ResourcePatternFilter.Any, AccessControlEntryFilter.Any)) | ||
.repeatWhile(_.isEmpty) // because the createAcls is executed async by the broker | ||
.timeoutFail(new TimeoutException())(100.millis) | ||
deletedAcls <- | ||
client | ||
.deleteAcls(Set(AclBindingFilter(ResourcePatternFilter.Any, AccessControlEntryFilter.Any))) | ||
remainingAcls <- | ||
client | ||
.describeAcls(AclBindingFilter(ResourcePatternFilter.Any, AccessControlEntryFilter.Any)) | ||
.repeatWhile(_.nonEmpty) // because the deleteAcls is executed async by the broker | ||
.timeoutFail(new TimeoutException())(100.millis) | ||
|
||
} yield assert(createdAcls)(equalTo(bindings)) && | ||
assert(deletedAcls)(equalTo(bindings)) && | ||
assert(remainingAcls)(equalTo(Set.empty[AclBinding])) | ||
} | ||
} | ||
) @@ withLiveClock @@ sequential | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package zio.kafka | ||
|
||
import zio.{ Task, ZIO } | ||
|
||
import java.util.UUID | ||
|
||
trait KafkaRandom { | ||
|
||
def kafkaPrefix: String | ||
|
||
def randomThing(prefix: String): Task[String] = | ||
ZIO.attempt(UUID.randomUUID()).map(uuid => s"$prefix-$uuid") | ||
|
||
def randomTopic: Task[String] = randomThing(s"$kafkaPrefix-topic") | ||
|
||
def randomGroup: Task[String] = randomThing(s"$kafkaPrefix-group") | ||
|
||
def randomClient: Task[String] = randomThing(s"$kafkaPrefix-client") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
zio-kafka-test/src/test/scala/zio/kafka/ZIOSpecWithSaslKafka.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package zio.kafka | ||
|
||
import zio.kafka.embedded.Kafka | ||
import zio.test._ | ||
import zio.{ Scope, ZLayer } | ||
|
||
trait ZIOSpecWithSaslKafka extends ZIOSpec[TestEnvironment with Kafka.Sasl] with KafkaRandom { | ||
override val bootstrap: ZLayer[Scope, Any, TestEnvironment with Kafka.Sasl] = | ||
testEnvironment ++ Kafka.saslEmbedded | ||
} |
38 changes: 0 additions & 38 deletions
38
zio-kafka/src/main/scala/zio/kafka/admin/AclOperation.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.