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.
Fix for KAFKA-4090: Add an SSL check before to create a client (#136)
* Add ssl check * Review fixes * Review fixes * Review fixes * Review fixes * Review fixes * Fmt --------- Co-authored-by: Jules Ivanic <guizmaii@users.noreply.github.com>
- Loading branch information
Showing
13 changed files
with
276 additions
and
9 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
Binary file not shown.
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,30 @@ | ||
-----BEGIN ENCRYPTED PRIVATE KEY----- | ||
MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIzfQ361sbhwcCAggA | ||
MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECFnRtpSC5wpfBIIEyJcYOkR1kbjO | ||
nnq2FuuObw3k2xwRqI/0EVLeQ8WPh3IPCDVlFLJ71S4HVhoUc9wJd+o+pnS3b9IR | ||
fP8Hf8usTH9LYdnA4m8oeJD79sxbZZzRGaphSMm2AfOGxndhxFXj0uscHWj2b35w | ||
vKDbQdicuxiN1oRo8lZWyVEBgBRDOX8azFoAINPPaTCLj1MSf2YByRMz5CXP83iC | ||
ADkogExPJuIigzQT/UrW+cBPMeQQIvcv/acWAmN8NciQIlzsxJ3gCaFRVIkzuJM0 | ||
CqY0hscXWRCWYtHjm0hF5SQSUsG+/5dfthXprN3/H5AZn3mqnBby8SvtyhoPmK89 | ||
sNy9JbTeA37yDR7ifP8rbIsiMM+WrCTkRLz/SOAlcQ5CyY0DoQiyheKYzTfH8Qr7 |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aioeR5U | ||
ls9bA2CXlduebN+58LhGyJQ8HQ1IDFdXJGv/o8JLvlsa5ePSWo9JGUZM6cIjPXu0 | ||
oLoGxd+vI6wmhS7QjuHH8jvoe7KiycnINAxrezcoW0jy43iisiT/OCxU2QNvmx81 | ||
vjXQ9RoIC20C2XDS2egTjddJFRFOOL23wRXulgtZ11RzrvvqLVoJ5M7xkLcFbq5l | ||
T7LLJiv2KMJkEbZCgZ+pgA== | ||
-----END ENCRYPTED PRIVATE KEY----- |
Binary file added
BIN
+1.22 KB
zio-kafka-test-utils/src/main/resources/truststore/kafka.truststore.jks
Binary file not shown.
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-utils/src/main/scala/zio/kafka/ZIOSpecWithSslKafka.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.ZLayer | ||
import zio.kafka.embedded.Kafka | ||
import zio.test._ | ||
|
||
trait ZIOSpecWithSslKafka extends ZIOSpec[TestEnvironment with Kafka] with KafkaRandom { | ||
override val bootstrap: ZLayer[Any, Any, TestEnvironment with Kafka] = | ||
testEnvironment ++ Kafka.sslEmbedded | ||
} |
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
58 changes: 58 additions & 0 deletions
58
zio-kafka-test/src/test/scala/zio/kafka/OOMSpecXmx300m.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,58 @@ | ||
package zio.kafka | ||
|
||
import org.apache.kafka.clients.producer.ProducerRecord | ||
import zio.kafka.consumer.{ Consumer, Subscription } | ||
import zio.kafka.embedded.Kafka | ||
import zio.kafka.producer.Producer | ||
import zio.kafka.serde.Serde | ||
import zio.test.TestAspect._ | ||
import zio.test._ | ||
|
||
/** | ||
* This test checks the fix for the issue https://issues.apache.org/jira/browse/KAFKA-4090 | ||
*/ | ||
object OOMSpecXmx300m extends ZIOSpecWithSslKafka { | ||
|
||
override val kafkaPrefix: String = "oom-spec" | ||
override def spec: Spec[Kafka, Any] = | ||
suite("OOM check")( | ||
test("producer should fail with ssl check") { | ||
for { | ||
result <- (for { | ||
topic <- randomTopic | ||
_ <- Producer.produce(new ProducerRecord(topic, "boo", "baa"), Serde.string, Serde.string) | ||
} yield ()).provideSomeLayer(KafkaTestUtils.producer).exit | ||
} yield assertTrue(result.isFailure) && | ||
assertTrue( | ||
result.toEither.left.map(_.getMessage()) == Left( | ||
"Received an unexpected SSL packet from the server. Please ensure the client is properly configured with SSL enabled" | ||
) | ||
) | ||
}, | ||
test("consumer should fail with ssl check") { | ||
for { | ||
result <- (for { | ||
topic <- randomTopic | ||
_ <- Consumer.subscribe(Subscription.Topics(Set(topic))) | ||
} yield ()).provideSomeLayer(KafkaTestUtils.consumer("test")).exit | ||
} yield assertTrue(result.isFailure) && | ||
assertTrue( | ||
result.toEither.left.map(_.getMessage()) == Left( | ||
"Received an unexpected SSL packet from the server. Please ensure the client is properly configured with SSL enabled" | ||
) | ||
) | ||
}, | ||
test("admin client should fail with ssl check") { | ||
for { | ||
result <- (KafkaTestUtils.withAdmin { client => | ||
client.listTopics() | ||
}).exit | ||
} yield assertTrue(result.isFailure) && | ||
assertTrue( | ||
result.toEither.left.map(_.getMessage()) == Left( | ||
"Received an unexpected SSL packet from the server. Please ensure the client is properly configured with SSL enabled" | ||
) | ||
) | ||
} | ||
) @@ 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
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
Oops, something went wrong.