diff options
Diffstat (limited to 'src/test/model/ca/TemplateTest.java')
-rw-r--r-- | src/test/model/ca/TemplateTest.java | 33 |
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()); + } } |