Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use HttpClient::toBlocking #207

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.micronaut.acme


import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions

Expand Down Expand Up @@ -69,13 +67,10 @@ class AcmeCertRefresherMultiDomainsTaskSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/ssl-multidomains"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/ssl-multidomains"), String)

then:
response.body() == "Hello There"
response.body() == "Hello There"
}

@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.micronaut.acme


import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions

Expand Down Expand Up @@ -67,13 +65,10 @@ class AcmeCertRefresherTaskSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/ssl"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/ssl"), String)

then:
response.body() == "Hello SSL"
response.body() == "Hello SSL"
}

@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.micronaut.acme


import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import org.shredzone.acme4j.util.KeyPairUtils
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions
Expand Down Expand Up @@ -82,13 +80,10 @@ class AcmeCertRefresherTaskWithClasspathKeysSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/ssl-using-classpath-keys"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/ssl-using-classpath-keys"), String)

then:
response.body() == "Hello Classpath"
response.body() == "Hello Classpath"
}

@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.micronaut.acme


import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions

Expand Down Expand Up @@ -76,13 +74,10 @@ class AcmeCertRefresherTaskWithFileKeysSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/ssl-using-file-keys"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/ssl-using-file-keys"), String)

then:
response.body() == "Hello File"
response.body() == "Hello File"
}

@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package io.micronaut.acme


import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions

Expand Down Expand Up @@ -74,13 +72,10 @@ class AcmeCertWildcardRefresherTaskSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/wildcardssl"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/wildcardssl"), String)

then:
response.body() == "Hello Wildcard"
response.body() == "Hello Wildcard"
}

@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.HttpStatus
import io.micronaut.http.client.exceptions.HttpClientResponseException
import io.reactivex.Flowable

import static org.testcontainers.shaded.org.apache.commons.lang.RandomStringUtils.randomAlphanumeric

Expand Down Expand Up @@ -52,9 +51,6 @@ class WellKnownTokenControllerSpec extends AcmeBaseSpec {
}

private HttpResponse<String> callWellKnownEndpoint(String randomToken) {
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/.well-known/acme-challenge/$randomToken"), String
))
flowable.blockingFirst()
client.toBlocking().exchange(HttpRequest.GET("/.well-known/acme-challenge/$randomToken"), String)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions

Expand Down Expand Up @@ -70,13 +69,10 @@ class AcmeCertRefresherTaskHttp01ChallengeSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/httpchallenge"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/httpchallenge"), String)

then:
response.body() == "Hello HTTP"
response.body() == "Hello HTTP"
}

@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import io.reactivex.Flowable
import spock.lang.Stepwise
import spock.util.concurrent.PollingConditions

Expand Down Expand Up @@ -68,13 +67,10 @@ class AcmeCertRefresherTaskTlsApln01ChallengeSpec extends AcmeBaseSpec {

void "test send https request when the cert is in place"() {
when:
Flowable<HttpResponse<String>> flowable = Flowable.fromPublisher(client.exchange(
HttpRequest.GET("/tlschallenge"), String
))
HttpResponse<String> response = flowable.blockingFirst()
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/tlschallenge"), String)

then:
response.body() == "Hello TLS"
response.body() == "Hello TLS"
}

@Controller('/')
Expand Down