aboutsummaryrefslogtreecommitdiff
path: root/src/test/model/pki/crl/CertificateListTest.java
blob: c117c160129507f2b150b71e512c7aec1470d999 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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.pki.AlgorithmIdentifier;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static model.TestConstants.combine;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

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());
    }
}