aboutsummaryrefslogtreecommitdiff
path: root/src/test/model/ca/TemplateTest.java
diff options
context:
space:
mode:
authorYuuta Liang <yuutaw@students.cs.ubc.ca>2023-10-14 06:17:57 +0800
committerYuuta Liang <yuutaw@students.cs.ubc.ca>2023-10-14 06:17:57 +0800
commitdf3eb7af36b6797e0c8e09a179191c329889da57 (patch)
treeb2119f13e57b2b391637f3e862b16bce3cd766a2 /src/test/model/ca/TemplateTest.java
parent6f82e5f3238bcc611354b20ed624d65759263032 (diff)
downloadjca-df3eb7af36b6797e0c8e09a179191c329889da57.tar
jca-df3eb7af36b6797e0c8e09a179191c329889da57.tar.gz
jca-df3eb7af36b6797e0c8e09a179191c329889da57.tar.bz2
jca-df3eb7af36b6797e0c8e09a179191c329889da57.zip
Fix coverage
Signed-off-by: Yuuta Liang <yuutaw@students.cs.ubc.ca>
Diffstat (limited to 'src/test/model/ca/TemplateTest.java')
-rw-r--r--src/test/model/ca/TemplateTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/model/ca/TemplateTest.java b/src/test/model/ca/TemplateTest.java
index 0ca7434..4014599 100644
--- a/src/test/model/ca/TemplateTest.java
+++ b/src/test/model/ca/TemplateTest.java
@@ -1,6 +1,12 @@
package model.ca;
+import model.asn1.ASN1Object;
+import model.asn1.ObjectIdentifier;
+import model.asn1.PrintableString;
import model.asn1.exceptions.ParseException;
+import model.x501.AttributeTypeAndValue;
+import model.x501.Name;
+import model.x501.RelativeDistinguishedName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@@ -24,4 +30,31 @@ public class TemplateTest {
assertNull(template.getSubject());
assertThrows(ParseException.class, () -> template.setSubject("*"));
}
+
+ @Test
+ void testSetters() throws ParseException {
+ Template template = new Template("123", true, null, 123);
+
+ template.setName("114514");
+ assertEquals("114514", template.getName());
+
+ template.setSubject(new Name(ASN1Object.TAG_SEQUENCE, null, new RelativeDistinguishedName[]{
+ new RelativeDistinguishedName(ASN1Object.TAG_SET, null, new AttributeTypeAndValue[]{
+ new AttributeTypeAndValue(ASN1Object.TAG_SEQUENCE, null,
+ new ObjectIdentifier(ObjectIdentifier.TAG, null,
+ ObjectIdentifier.OID_CN),
+ new PrintableString(PrintableString.TAG, null, "Test"))}),
+ new RelativeDistinguishedName(ASN1Object.TAG_SET, null, new AttributeTypeAndValue[]{
+ new AttributeTypeAndValue(ASN1Object.TAG_SEQUENCE, null,
+ new ObjectIdentifier(ObjectIdentifier.TAG, null,
+ ObjectIdentifier.OID_C),
+ new PrintableString(PrintableString.TAG, null, "CA"))})}));
+ assertEquals("CN=Test,C=CA", template.getSubject().toString());
+
+ template.setEnabled(false);
+ assertFalse(template.isEnabled());
+
+ template.setValidity(233);
+ assertEquals(233, template.getValidity());
+ }
}