aboutsummaryrefslogtreecommitdiffstats
path: root/container-disc/src/test/java/com/yahoo/container/jdisc/athenz/impl/CryptoUtilsTest.java
blob: 2a265a3c6fd7c6b93083dc5d5d9f1d14c84a6e9a (plain) (blame)
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 com.yahoo.container.jdisc.athenz.impl;

import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.junit.Test;

import java.io.IOException;
import java.security.KeyPair;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;

/**
 * @author bjorncs
 */
public class CryptoUtilsTest {

    @Test
    public void certificate_signing_request_is_correct_and_can_be_serialized_to_pem() throws IOException {
        KeyPair keyPair = CryptoUtils.createKeyPair();
        PKCS10CertificationRequest csr = CryptoUtils.createCSR(
                "identity-domain", "identity-service", "vespa.cloud.com", "unique.instance.id", keyPair);
        String pem = CryptoUtils.toPem(csr);
        assertThat(pem, containsString("BEGIN CERTIFICATE REQUEST"));
        assertThat(pem, containsString("END CERTIFICATE REQUEST"));
    }

}