From df3eb7af36b6797e0c8e09a179191c329889da57 Mon Sep 17 00:00:00 2001 From: Yuuta Liang Date: Sat, 14 Oct 2023 06:17:57 +0800 Subject: Fix coverage Signed-off-by: Yuuta Liang --- src/test/model/ca/TemplateTest.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/test/model/ca/TemplateTest.java') 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()); + } } -- cgit v1.2.3