Search in sources :

Example 1 with RsaGenerationParameters

use of org.cloudfoundry.credhub.request.RsaGenerationParameters in project credhub by cloudfoundry-incubator.

the class RsaCredentialVersionTest method matchesGenerationParameters_returnsFalseWhenParametersDontMatch.

@Test
public void matchesGenerationParameters_returnsFalseWhenParametersDontMatch() {
    when(credentialVersionData.getKeyLength()).thenReturn(2048);
    RsaGenerationParameters generationParameters = new RsaGenerationParameters();
    generationParameters.setKeyLength(4096);
    assertThat(subject.matchesGenerationParameters(generationParameters), equalTo(false));
}
Also used : RsaGenerationParameters(org.cloudfoundry.credhub.request.RsaGenerationParameters) Test(org.junit.Test)

Example 2 with RsaGenerationParameters

use of org.cloudfoundry.credhub.request.RsaGenerationParameters in project credhub by cloudfoundry-incubator.

the class RsaGeneratorTest method generateCredential_shouldUseTheProvidedKeyLength.

@Test
public void generateCredential_shouldUseTheProvidedKeyLength() throws Exception {
    RsaGenerationParameters rsaGenerationParameters = new RsaGenerationParameters();
    rsaGenerationParameters.setKeyLength(4096);
    subject.generateCredential(rsaGenerationParameters);
    verify(keyPairGenerator).generateKeyPair(4096);
}
Also used : RsaGenerationParameters(org.cloudfoundry.credhub.request.RsaGenerationParameters) Test(org.junit.Test)

Example 3 with RsaGenerationParameters

use of org.cloudfoundry.credhub.request.RsaGenerationParameters in project credhub by cloudfoundry-incubator.

the class RsaGeneratorTest method generateCredential_shouldReturnAGeneratedCredential.

@Test
public void generateCredential_shouldReturnAGeneratedCredential() throws Exception {
    final RsaCredentialValue rsa = subject.generateCredential(new RsaGenerationParameters());
    verify(keyPairGenerator).generateKeyPair(2048);
    assertThat(rsa.getPublicKey(), equalTo(CertificateFormatter.pemOf(keyPair.getPublic())));
    assertThat(rsa.getPrivateKey(), equalTo(CertificateFormatter.pemOf(keyPair.getPrivate())));
}
Also used : RsaGenerationParameters(org.cloudfoundry.credhub.request.RsaGenerationParameters) RsaCredentialValue(org.cloudfoundry.credhub.credential.RsaCredentialValue) Test(org.junit.Test)

Example 4 with RsaGenerationParameters

use of org.cloudfoundry.credhub.request.RsaGenerationParameters in project credhub by cloudfoundry-incubator.

the class RsaCredentialVersionTest method matchesGenerationParameters_returnsTrueWhenParametersMatch.

@Test
public void matchesGenerationParameters_returnsTrueWhenParametersMatch() {
    when(credentialVersionData.getKeyLength()).thenReturn(4096);
    RsaGenerationParameters generationParameters = new RsaGenerationParameters();
    generationParameters.setKeyLength(4096);
    assertThat(subject.matchesGenerationParameters(generationParameters), equalTo(true));
}
Also used : RsaGenerationParameters(org.cloudfoundry.credhub.request.RsaGenerationParameters) Test(org.junit.Test)

Aggregations

RsaGenerationParameters (org.cloudfoundry.credhub.request.RsaGenerationParameters)4 Test (org.junit.Test)4 RsaCredentialValue (org.cloudfoundry.credhub.credential.RsaCredentialValue)1