Skip to content

Commit

Permalink
Use sytem property to specify the trust store instead of code
Browse files Browse the repository at this point in the history
  • Loading branch information
yaravind committed May 28, 2016
1 parent c859f0f commit 7922cf6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/test/groovy/org/aravind/oss/jenkins/JenkinsClientTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ class JenkinsClientTest extends Specification {
@Shared
Runner httpsMock

def setupSpec() {
def server = jsonHttpServer(9191, pathResource("jenkins-mock-server-cfg.json"))
mock = runner(server)
mock.start()

//trust the self-signed cert.jks
//setTrustStore("/cert.jks", "mocohttps")
System.setProperty("javax.net.ssl.trustStore","src/test/resources/cert.jks")

def httpsServer = httpsServer(9443, HttpsCertificate.certificate(pathResource("cert.jks"), "mocohttps", "mocohttps"))
httpsMock = runner(httpsServer)
httpsMock.start()
}

//Error scenarios

def "Wrong authentication credentials 'username' should return empty response"() {
Expand Down Expand Up @@ -76,19 +90,6 @@ class JenkinsClientTest extends Specification {

//Happy scenarios

def setupSpec() {
def server = jsonHttpServer(9191, pathResource("jenkins-mock-server-cfg.json"))
mock = runner(server)
mock.start()

//trust the self-signed cert.jks
setTrustStore("/cert.jks", "mocohttps")

def httpsServer = httpsServer(9443, HttpsCertificate.certificate(pathResource("cert.jks"), "mocohttps", "mocohttps"))
httpsMock = runner(httpsServer)
httpsMock.start()
}

def "Supports Jenkins without authentication"() {
when:
def url = new URL("http://localhost:9191/")
Expand Down

0 comments on commit 7922cf6

Please sign in to comment.