aboutsummaryrefslogtreecommitdiff
path: root/src/test/model/ca/TemplateTest.java
blob: 0ca7434a09b6fcb6e9f12feccf4b8ff6265a333f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package model.ca;

import model.asn1.exceptions.ParseException;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class TemplateTest {
    @Test
    void testConstructor() {
        Template template = new Template("123", true, null, 123);
        assertEquals("123", template.getName());
        assertTrue(template.isEnabled());
        assertNull(template.getSubject());
        assertEquals(123, template.getValidity());
    }

    @Test
    void testSetSubject() throws ParseException {
        Template template = new Template("123", true, null, 123);
        template.setSubject("123");
        assertEquals("CN=123,C=CA", template.getSubject().toString());
        template.setSubject((String) null);
        assertNull(template.getSubject());
        assertThrows(ParseException.class, () -> template.setSubject("*"));
    }
}