Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii committed Jan 26, 2025
1 parent c47b84c commit efdf12c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions zio-http/jvm/src/test/scala/zio/http/ClientHttpsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,29 @@
package zio.http

import zio._
import zio.test.Assertion._
import zio.test.TestAspect.{flaky, ignore, nonFlaky}
import zio.test.{TestAspect, assertZIO}

import zio.http.netty.NettyConfig
import zio.http.netty.client.NettyClientDriver
import zio.test.Assertion._
import zio.test.TestAspect.{ignore, nonFlaky}
import zio.test.{Spec, TestAspect, TestEnvironment, assertZIO}

abstract class ClientHttpsSpecBase extends ZIOHttpSpec {
val sslConfig: ClientSSLConfig

val zioDev =
private val zioDev =
URL.decode("https://zio.dev").toOption.get

val badRequest =
private val badRequest =
URL
.decode(
"https://httpbin.org/status/400",
)
.toOption
.get

val untrusted =
private val untrusted =
URL.decode("https://untrusted-root.badssl.com/").toOption.get

override def spec = suite("Https Client request")(
def tests(sslConfig: ClientSSLConfig) = suite("Client")(
test("respond Ok") {
val actual = Client.batched(Request.get(zioDev))
assertZIO(actual)(anything)
Expand Down Expand Up @@ -91,17 +89,27 @@ abstract class ClientHttpsSpecBase extends ZIOHttpSpec {

object ClientHttpsSpec extends ClientHttpsSpecBase {

val sslConfig = ClientSSLConfig.FromTrustStoreResource(
private val sslConfig = ClientSSLConfig.FromTrustStoreResource(
trustStorePath = "truststore.jks",
trustStorePassword = "changeit",
)

override def spec: Spec[TestEnvironment & Scope, Throwable] =
suite("Https Client request - From Trust Store")(
tests(sslConfig),
)
}

object ClientHttpsFromJavaxNetSslSpec extends ClientHttpsSpecBase {

val sslConfig =
private val sslConfig =
ClientSSLConfig.FromJavaxNetSsl
.builderWithTrustManagerResource("trustStore.jks")
.trustManagerPassword("changeit")
.build()

override def spec: Spec[TestEnvironment & Scope, Throwable] =
suite("Https Client request - From Javax Net Ssl")(
tests(sslConfig),
)
}

0 comments on commit efdf12c

Please sign in to comment.