Handle HTTPS from config
Change-Id: I48ea5ea2e35e62906b7b5ec5c5e624d06192172b
This commit is contained in:
parent
76a3ecacad
commit
d070ea820b
2 changed files with 13 additions and 5 deletions
|
@ -14,6 +14,7 @@ import pl.touk.mockserver.api.request.AddMock
|
|||
import pl.touk.mockserver.client.RemoteMockServer
|
||||
import pl.touk.mockserver.client.Util
|
||||
import pl.touk.mockserver.server.HttpMockServer
|
||||
import spock.lang.AutoCleanup
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
|
@ -25,6 +26,7 @@ class MockServerHttpsTest extends Specification {
|
|||
|
||||
RemoteMockServer remoteMockServer = new RemoteMockServer('localhost', 19000)
|
||||
|
||||
@AutoCleanup('stop')
|
||||
HttpMockServer httpMockServer = new HttpMockServer(19000)
|
||||
|
||||
@Shared
|
||||
|
@ -44,10 +46,6 @@ class MockServerHttpsTest extends Specification {
|
|||
.loadTrustMaterial(trustStore())
|
||||
.build()
|
||||
|
||||
def cleanup() {
|
||||
httpMockServer.stop()
|
||||
}
|
||||
|
||||
def 'should handle HTTPS server' () {
|
||||
given:
|
||||
remoteMockServer.addMock(new AddMock(
|
||||
|
|
|
@ -122,7 +122,7 @@ class HttpMockServer {
|
|||
throw new RuntimeException('mock already registered')
|
||||
}
|
||||
Mock mock = mockFromConfig(co)
|
||||
HttpServerWrapper child = getOrCreateChildServer(mock.port, null)
|
||||
HttpServerWrapper child = getOrCreateChildServer(mock.port, mock.https)
|
||||
child.addMock(mock)
|
||||
configuration.put(name, co)
|
||||
mockNames << name
|
||||
|
@ -172,6 +172,16 @@ class HttpMockServer {
|
|||
mock.responseHeaders = co.responseHeaders ?: null
|
||||
mock.schema = co.schema ?: null
|
||||
mock.preserveHistory = co.preserveHistory != false
|
||||
if (co.https) {
|
||||
mock.https = new Https(
|
||||
keystorePath: co.https.keystorePath ?: null,
|
||||
keystorePassword: co.https.keystorePassword,
|
||||
keyPassword: co.https.keyPassword,
|
||||
truststorePath: co.https.truststorePath,
|
||||
truststorePassword: co.https.truststorePassword,
|
||||
requireClientAuth: co.https?.requireClientAuth?.asBoolean() ?: false
|
||||
)
|
||||
}
|
||||
return mock
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue