aboutsummaryrefslogtreecommitdiff
path: root/src/test/model/pki/crl
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/model/pki/crl')
-rw-r--r--src/test/model/pki/crl/CertificateListContentTest.java37
-rw-r--r--src/test/model/pki/crl/CertificateListTest.java52
-rw-r--r--src/test/model/pki/crl/RevokedCertificateTest.java25
3 files changed, 114 insertions, 0 deletions
diff --git a/src/test/model/pki/crl/CertificateListContentTest.java b/src/test/model/pki/crl/CertificateListContentTest.java
new file mode 100644
index 0000000..ec18629
--- /dev/null
+++ b/src/test/model/pki/crl/CertificateListContentTest.java
@@ -0,0 +1,37 @@
+package model.pki.crl;
+
+import model.TestConstants;
+import model.asn1.*;
+import model.asn1.exceptions.ParseException;
+import model.pki.AlgorithmIdentifier;
+import model.x501.AttributeTypeAndValue;
+import model.x501.Name;
+import model.x501.RelativeDistinguishedName;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+
+import static model.TestConstants.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class CertificateListContentTest {
+ @Test
+ void testConstructor() {
+ assertEquals(1, CRL_CONTENT_1.getVersion().getLong());
+ assertEquals("CN=Test CA", CRL_CONTENT_1.getIssuer().toString());
+ assertArrayEquals(ObjectIdentifier.OID_SHA256_WITH_RSA_ENCRYPTION,
+ CRL_CONTENT_1.getSignature().getType().getInts());
+ assertEquals(GeneralizedTime.TAG.getNumber(),
+ CRL_CONTENT_1.getThisUpdate().getTag().getNumber());
+ assertNull(CRL_CONTENT_1.getNextUpdate());
+ assertEquals(2, CRL_CONTENT_1.getRevokedCertificates().length);
+ }
+
+ @Test
+ void testEncode() {
+ assertArrayEquals(CRL_CONTENT_1_DER, CRL_CONTENT_1.encodeDER());
+ assertArrayEquals(CRL_CONTENT_2_DER, CRL_CONTENT_2.encodeDER());
+ }
+}
diff --git a/src/test/model/pki/crl/CertificateListTest.java b/src/test/model/pki/crl/CertificateListTest.java
new file mode 100644
index 0000000..0f4f06c
--- /dev/null
+++ b/src/test/model/pki/crl/CertificateListTest.java
@@ -0,0 +1,52 @@
+package model.pki.crl;
+
+import model.TestConstants;
+import model.asn1.ASN1Object;
+import model.asn1.BitString;
+import model.asn1.Null;
+import model.asn1.ObjectIdentifier;
+import model.asn1.exceptions.ParseException;
+import model.asn1.parsing.BytesReader;
+import model.pki.AlgorithmIdentifier;
+import model.pki.cert.Certificate;
+import model.pki.cert.TbsCertificate;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static model.TestConstants.combine;
+import static model.TestConstants.mutate;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class CertificateListTest {
+ private CertificateList crl;
+
+ @BeforeEach
+ void setup() {
+ crl = new CertificateList(ASN1Object.TAG_SEQUENCE, null,
+ TestConstants.CRL_CONTENT_1,
+ new AlgorithmIdentifier(ASN1Object.TAG_SEQUENCE, null,
+ new ObjectIdentifier(ObjectIdentifier.TAG, null, ObjectIdentifier.OID_RSA_ENCRYPTION),
+ new Null(Null.TAG, null)),
+ new BitString(BitString.TAG, null, 0, new Byte[]{ 1, 2, 3 }));
+ }
+
+ @Test
+ void testConstructor() {
+ assertEquals(2, crl.getCrl().getRevokedCertificates().length);
+ assertArrayEquals(ObjectIdentifier.OID_RSA_ENCRYPTION,
+ crl.getSignatureAlgorithm().getType().getInts());
+ assertArrayEquals(new Byte[]{ 1, 2, 3 },
+ crl.getSignature().getConvertedVal());
+ }
+
+ @Test
+ void testEncode() {
+ assertArrayEquals(combine((byte) 0x30,
+ TestConstants.CRL_CONTENT_1_DER,
+ new AlgorithmIdentifier(ASN1Object.TAG_SEQUENCE, null,
+ new ObjectIdentifier(ObjectIdentifier.TAG, null, ObjectIdentifier.OID_RSA_ENCRYPTION),
+ new Null(Null.TAG, null)).encodeDER(),
+ new BitString(BitString.TAG, null, 0, new Byte[]{ 1, 2, 3 }).encodeDER()),
+ crl.encodeDER());
+ }
+}
diff --git a/src/test/model/pki/crl/RevokedCertificateTest.java b/src/test/model/pki/crl/RevokedCertificateTest.java
new file mode 100644
index 0000000..659e421
--- /dev/null
+++ b/src/test/model/pki/crl/RevokedCertificateTest.java
@@ -0,0 +1,25 @@
+package model.pki.crl;
+
+import model.asn1.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+
+import static model.TestConstants.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class RevokedCertificateTest {
+ @Test
+ void testConstructor() {
+ assertEquals(123, REVOKED_CESSATION.getSerialNumber().getLong());
+ assertEquals(UtcTime.TAG.getNumber(), REVOKED_CESSATION.getRevocationDate().getTag().getNumber());
+ assertEquals(Reason.CESSATION_OF_OPERATION, REVOKED_CESSATION.getReason());
+ }
+
+ @Test
+ void testEncode() {
+ assertArrayEquals(REVOKED_KEY_COMPROMISE_DER, REVOKED_KEY_COMPROMISE.encodeDER());
+ }
+}