Search in sources :

Example 6 with SshGenerationParameters

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

the class SshGeneratorTest method generateCredential_shouldReturnAGeneratedCredential.

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

Example 7 with SshGenerationParameters

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

the class SshCredentialVersionTest method matchesGenerationParameters_returnsTrueWhenParametersMatch.

@Test
public void matchesGenerationParameters_returnsTrueWhenParametersMatch() {
    when(sshPublicKeyParser.getKeyLength()).thenReturn(4096);
    when(sshPublicKeyParser.getComment()).thenReturn("some comment");
    SshGenerationParameters generationParameters = new SshGenerationParameters();
    generationParameters.setKeyLength(4096);
    generationParameters.setSshComment("some comment");
    assertThat(subject.matchesGenerationParameters(generationParameters), equalTo(true));
}
Also used : SshGenerationParameters(org.cloudfoundry.credhub.request.SshGenerationParameters) Test(org.junit.Test)

Aggregations

SshGenerationParameters (org.cloudfoundry.credhub.request.SshGenerationParameters)7 Test (org.junit.Test)5 SshCredentialValue (org.cloudfoundry.credhub.credential.SshCredentialValue)3 RSAPublicKey (java.security.interfaces.RSAPublicKey)2 KeyPair (java.security.KeyPair)1 SshCredentialVersion (org.cloudfoundry.credhub.domain.SshCredentialVersion)1 SshGenerateRequest (org.cloudfoundry.credhub.request.SshGenerateRequest)1