Skip to content

Commit

Permalink
Groovy-ify and use types more
Browse files Browse the repository at this point in the history
  • Loading branch information
zendern committed Mar 7, 2022
1 parent 16b05b6 commit 075cb6c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class AcmeCertRefresherMultiDomainsTaskSpec extends AcmeBaseSpec {
conn.connect()
Certificate[] certs = conn.getServerCertificates()
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(EXPECTED_DOMAIN)
cert.getSubjectAlternativeNames().size() == 2
cert.getSubjectAlternativeNames().collect({d-> d.get(1)}).contains(EXPECTED_DOMAIN)
cert.getSubjectAlternativeNames().collect({d-> d.get(1)}).contains(EXPECTED_ACME_DOMAIN)

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}finally{
if(conn != null){
conn.disconnect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class AcmeCertRefresherTaskSpec extends AcmeBaseSpec {
conn.connect()
Certificate[] certs = conn.getServerCertificates()
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(EXPECTED_DOMAIN)
cert.getSubjectAlternativeNames().size() == 1

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}finally{
if(conn != null){
conn.disconnect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class AcmeCertRefresherTaskWithClasspathKeysSpec extends AcmeBaseSpec {
conn.connect()
Certificate[] certs = conn.getServerCertificates()
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(EXPECTED_DOMAIN)
cert.getSubjectAlternativeNames().size() == 1

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}finally{
if(conn != null){
conn.disconnect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class AcmeCertRefresherTaskWithFileKeysSpec extends AcmeBaseSpec {
conn.connect()
Certificate[] certs = conn.getServerCertificates()
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(EXPECTED_DOMAIN)
cert.getSubjectAlternativeNames().size() == 1

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}finally{
if(conn != null){
conn.disconnect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ class AcmeCertWildcardRefresherTaskSpec extends AcmeBaseSpec {
conn.connect()
Certificate[] certs = conn.getServerCertificates()
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(WILDCARD_DOMAIN)
cert.getSubjectAlternativeNames().size() == 2
cert.getSubjectAlternativeNames().collect({d-> d.get(1)}).contains(WILDCARD_DOMAIN)
cert.getSubjectAlternativeNames().collect({d-> d.get(1)}).contains(EXPECTED_BASE_DOMAIN)

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}finally{
if(conn != null){
conn.disconnect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class AcmeCertRefresherTaskHttp01ChallengeSpec extends AcmeBaseSpec {

then: "we make sure they are from the pebble test server and the domain is as expected"
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(EXPECTED_ACME_DOMAIN)
cert.getSubjectAlternativeNames().size() == 1

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}

void "test send https request when the cert is in place"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class AcmeCertRefresherTaskTlsApln01ChallengeSpec extends AcmeBaseSpec {

then: "we make sure they are from the pebble test server and the domain is as expected"
certs.length == 2
def cert = (X509Certificate) certs[0]
X509Certificate cert = certs[0]
cert.getIssuerDN().getName().contains("Pebble Intermediate CA")
cert.getSubjectDN().getName().contains(EXPECTED_ACME_DOMAIN)
cert.getSubjectAlternativeNames().size() == 1

def cert2 = (X509Certificate) certs[1]
cert2.getIssuerDN().getName().contains("Pebble Root CA")
cert2.getSubjectDN().getName().contains("Pebble Intermediate CA")
X509Certificate cert2 = certs[1]
cert2.issuerDN.name.contains("Pebble Root CA")
cert2.subjectDN.name.contains("Pebble Intermediate CA")
}

void "test send https request when the cert is in place"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ${DOMAIN_CERT}
CertificateFactory cf = CertificateFactory.getInstance(X509_CERT)
X509Certificate cert = cf.generateCertificate(new ByteArrayInputStream(FULL_CHAIN_CERT.bytes))
KeyPair keyPair = KeyPairUtils.createKeyPair(2048)
def validationCert = new Random().nextBoolean()
boolean validationCert = new Random().nextBoolean()

when :
CertificateEvent event = new CertificateEvent(cert, keyPair, validationCert)
Expand Down Expand Up @@ -110,7 +110,7 @@ ${DOMAIN_CERT}
X509Certificate domainCert = cf.generateCertificate(new ByteArrayInputStream(FULL_CHAIN_CERT.bytes))
Collection<X509Certificate> certs = cf.generateCertificates(new ByteArrayInputStream(FULL_CHAIN_CERT.bytes))
KeyPair keyPair = KeyPairUtils.createKeyPair(2048)
def expectedValidationCert = new Random().nextBoolean()
boolean expectedValidationCert = new Random().nextBoolean()

when :
CertificateEvent event = new CertificateEvent(keyPair, expectedValidationCert, certs as X509Certificate[])
Expand Down

0 comments on commit 075cb6c

Please sign in to comment.