diff --git a/lib/src/test/java/fi/protonode/certy/TestCertificateRevocationList.java b/lib/src/test/java/fi/protonode/certy/TestCertificateRevocationList.java index 64250f4..c30757a 100644 --- a/lib/src/test/java/fi/protonode/certy/TestCertificateRevocationList.java +++ b/lib/src/test/java/fi/protonode/certy/TestCertificateRevocationList.java @@ -52,7 +52,7 @@ public static void init() throws Exception { } @Test - public void testAdd() throws Exception { + void testAdd() throws Exception { Credential anotherRevokedCert = new Credential().issuer(ca).subject("CN=revoked"); CertificateRevocationList crl = new CertificateRevocationList().add(revokedCert).add(anotherRevokedCert); assertNotNull(crl); @@ -65,7 +65,7 @@ public void testAdd() throws Exception { } @Test - public void testThisUpdate() throws Exception { + void testThisUpdate() throws Exception { Date thisUpdate = Date.from(Instant.parse("2023-01-01T09:00:00Z")); CertificateRevocationList crl = new CertificateRevocationList().thisUpdate(thisUpdate).add(revokedCert); assertNotNull(crl); @@ -76,7 +76,7 @@ public void testThisUpdate() throws Exception { } @Test - public void testNextUpdate() throws Exception { + void testNextUpdate() throws Exception { Date nextUpdate = Date.from(Instant.parse("2100-01-01T09:00:00Z")); CertificateRevocationList crl = new CertificateRevocationList().nextUpdate(nextUpdate).add(revokedCert); assertNotNull(crl); @@ -87,7 +87,7 @@ public void testNextUpdate() throws Exception { } @Test - public void testIssuer() throws Exception { + void testIssuer() throws Exception { CertificateRevocationList crl = new CertificateRevocationList().issuer(ca).add(revokedCert); assertNotNull(crl); @@ -98,7 +98,7 @@ public void testIssuer() throws Exception { } @Test - public void testGetPem() throws Exception { + void testGetPem() throws Exception { CertificateRevocationList crl = new CertificateRevocationList().add(revokedCert); assertNotNull(crl); @@ -115,7 +115,7 @@ public void testGetPem() throws Exception { } @Test - public void testWritingPem(@TempDir Path tempDir) throws Exception { + void testWritingPem(@TempDir Path tempDir) throws Exception { Path crlPath = tempDir.resolve("crl.pem"); CertificateRevocationList crl = new CertificateRevocationList().add(revokedCert).writeAsPem(crlPath); @@ -128,13 +128,13 @@ public void testWritingPem(@TempDir Path tempDir) throws Exception { } @Test - public void testUninitializedCaCertificate(@TempDir Path tempDir) throws Exception { + void testUninitializedCaCertificate(@TempDir Path tempDir) { Credential uninitialized = new Credential().subject("cn=ca"); // We have not called generate() yet. assertDoesNotThrow(() -> new CertificateRevocationList().issuer(uninitialized).writeAsPem(tempDir.resolve("crl.pem"))); } @Test - public void testUninitializedRevokedCertificate(@TempDir Path tempDir) throws Exception { + void testUninitializedRevokedCertificate(@TempDir Path tempDir) { Credential uninitialized = new Credential().issuer(ca).subject("cn=uninitialized"); // We have not called generate() yet. assertDoesNotThrow(() -> new CertificateRevocationList().issuer(ca).add(uninitialized).writeAsPem(tempDir.resolve("crl.pem"))); } diff --git a/lib/src/test/java/fi/protonode/certy/TestCredential.java b/lib/src/test/java/fi/protonode/certy/TestCredential.java index a390d25..858b404 100644 --- a/lib/src/test/java/fi/protonode/certy/TestCredential.java +++ b/lib/src/test/java/fi/protonode/certy/TestCredential.java @@ -22,7 +22,6 @@ import org.bouncycastle.asn1.x509.GeneralName; import org.bouncycastle.asn1.x509.GeneralNames; import org.bouncycastle.asn1.x509.KeyPurposeId; -import org.bouncycastle.cert.X509CRLHolder; import org.bouncycastle.cert.X509CertificateHolder; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.util.io.pem.PemObject; @@ -61,7 +60,7 @@ import java.util.Arrays; import java.util.Date; -public class TestCredential { +class TestCredential { @Test void testSubjectName() throws Exception { @@ -77,7 +76,7 @@ void testSubjectAltName() throws Exception { .getX509Certificate(); assertNotNull(cert); assertEquals("CN=joe", cert.getSubjectX500Principal().getName()); - Object expected[] = new Object[] { + Object[] expected = new Object[] { Arrays.asList(GeneralName.dNSName, "host.example.com"), Arrays.asList(GeneralName.uniformResourceIdentifier, "http://www.example.com"), Arrays.asList(GeneralName.iPAddress, "1.2.3.4") }; @@ -239,20 +238,20 @@ void testNotBeforeAndNotAfter() throws Exception { } @Test - void testInvalidSubject() throws Exception { + void testInvalidSubject() { Credential cred = new Credential(); assertThrows(IllegalArgumentException.class, () -> cred.subject("Foo=Bar")); } @Test - void testEmptySubjectAndSubjectAltNames() throws Exception { + void testEmptySubjectAndSubjectAltNames() { // Both subject and subject alternative name cannot be empty. Credential cred = new Credential(); assertThrows(IllegalArgumentException.class, () -> cred.getX509Certificate()); } @Test - void testInvalidSubjectAltName() throws Exception { + void testInvalidSubjectAltName() { Credential cred = new Credential().subject("CN=joe"); assertThrows(IllegalArgumentException.class, () -> cred.subjectAltName("EMAIL:user@example.com")); assertThrows(IllegalArgumentException.class, () -> cred.subjectAltName("URL:")); @@ -261,7 +260,7 @@ void testInvalidSubjectAltName() throws Exception { } @Test - void testInvalidKeySize() throws Exception { + void testInvalidKeySize() { Credential cred1 = new Credential().subject("CN=joe").keyType(KeyType.EC).keySize(1); assertThrows(IllegalArgumentException.class, () -> cred1.getX509Certificate());