From 075cb6cd314f4d3d933115e453b9cad544a2c4b7 Mon Sep 17 00:00:00 2001 From: Nathan Zender Date: Mon, 7 Mar 2022 18:10:58 -0500 Subject: [PATCH] Groovy-ify and use types more --- .../acme/AcmeCertRefresherMultiDomainsTaskSpec.groovy | 8 ++++---- .../io/micronaut/acme/AcmeCertRefresherTaskSpec.groovy | 8 ++++---- .../AcmeCertRefresherTaskWithClasspathKeysSpec.groovy | 8 ++++---- .../acme/AcmeCertRefresherTaskWithFileKeysSpec.groovy | 8 ++++---- .../acme/AcmeCertWildcardRefresherTaskSpec.groovy | 8 ++++---- .../AcmeCertRefresherTaskHttp01ChallengeSpec.groovy | 8 ++++---- .../AcmeCertRefresherTaskTlsApln01ChallengeSpec.groovy | 8 ++++---- .../io/micronaut/acme/events/CertificateEventSpec.groovy | 4 ++-- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherMultiDomainsTaskSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherMultiDomainsTaskSpec.groovy index 6a84ed62..f28dd96f 100644 --- a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherMultiDomainsTaskSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherMultiDomainsTaskSpec.groovy @@ -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() diff --git a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSpec.groovy index 7f9716e4..a69992eb 100644 --- a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSpec.groovy @@ -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() diff --git a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithClasspathKeysSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithClasspathKeysSpec.groovy index bae29063..4f2187e0 100644 --- a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithClasspathKeysSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithClasspathKeysSpec.groovy @@ -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() diff --git a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithFileKeysSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithFileKeysSpec.groovy index 70a96da6..4b4e64cc 100644 --- a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithFileKeysSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskWithFileKeysSpec.groovy @@ -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() diff --git a/acme/src/test/groovy/io/micronaut/acme/AcmeCertWildcardRefresherTaskSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/AcmeCertWildcardRefresherTaskSpec.groovy index 9671391d..d41a4ed3 100644 --- a/acme/src/test/groovy/io/micronaut/acme/AcmeCertWildcardRefresherTaskSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/AcmeCertWildcardRefresherTaskSpec.groovy @@ -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() diff --git a/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskHttp01ChallengeSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskHttp01ChallengeSpec.groovy index 91414ed0..ee5e611b 100644 --- a/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskHttp01ChallengeSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskHttp01ChallengeSpec.groovy @@ -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"() { diff --git a/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskTlsApln01ChallengeSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskTlsApln01ChallengeSpec.groovy index b70403ac..cb6515e0 100644 --- a/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskTlsApln01ChallengeSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskTlsApln01ChallengeSpec.groovy @@ -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"() { diff --git a/acme/src/test/groovy/io/micronaut/acme/events/CertificateEventSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/events/CertificateEventSpec.groovy index 736030fe..04c21d90 100644 --- a/acme/src/test/groovy/io/micronaut/acme/events/CertificateEventSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/events/CertificateEventSpec.groovy @@ -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) @@ -110,7 +110,7 @@ ${DOMAIN_CERT} X509Certificate domainCert = cf.generateCertificate(new ByteArrayInputStream(FULL_CHAIN_CERT.bytes)) Collection 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[])