@Test
public void getSignedByIssuer_generatesACertificateWithTheRightValues() throws Exception {

  final X509Certificate generatedCertificate = subject
    .getSignedByIssuer(generatedCertificateKeyPair, certificateGenerationParameters,
      certificateAuthorityWithSubjectKeyId, issuerKey.getPrivate());
  assertThat(generatedCertificate.getIssuerDN().getName(), containsString("CN=ca DN"));
  assertThat(generatedCertificate.getIssuerDN().getName(), containsString("O=credhub"));
  assertThat(generatedCertificate.getSerialNumber(), equalTo(BigInteger.valueOf(1337L)));
  assertThat(generatedCertificate.getNotBefore().toString(), equalTo(Date.from(now).toString()));
  assertThat(generatedCertificate.getNotAfter().toString(), equalTo(Date.from(later).toString()));
  assertThat(generatedCertificate.getSubjectDN().toString(), containsString("CN=my cert name"));
  assertThat(generatedCertificate.getPublicKey(), equalTo(generatedCertificateKeyPair.getPublic()));
  assertThat(generatedCertificate.getSigAlgName(), equalTo("SHA256WITHRSA"));
  generatedCertificate.verify(issuerKey.getPublic());
  final byte[] isCaExtension = generatedCertificate.getExtensionValue(Extension.basicConstraints.getId());
  assertThat(Arrays.copyOfRange(isCaExtension, 2, isCaExtension.length),
    equalTo(new BasicConstraints(true).getEncoded()));
}