@Test
public void getSignedByIssuer_setsKeyUsage_ifPresent() throws Exception {

  X509Certificate generatedCertificate = subject
    .getSignedByIssuer(generatedCertificateKeyPair, certificateGenerationParameters,
      certificateAuthorityWithSubjectKeyId, issuerKey.getPrivate());
  assertThat(generatedCertificate.getExtensionValue(Extension.keyUsage.getId()), nullValue());
  certificateGenerationParameters = parametersContainsExtensions();
  generatedCertificate = subject
    .getSignedByIssuer(generatedCertificateKeyPair, certificateGenerationParameters,
      certificateAuthorityWithSubjectKeyId, issuerKey.getPrivate());
  final byte[] actualKeyUsage = generatedCertificate.getExtensionValue(Extension.keyUsage.getId());
  assertThat(Arrays.copyOfRange(actualKeyUsage, 5, actualKeyUsage.length),
    equalTo(certificateGenerationParameters.getKeyUsage().getBytes()));
}