Search in sources :

Example 6 with SshCredentialValue

use of org.cloudfoundry.credhub.credential.SshCredentialValue 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)

Aggregations

SshCredentialValue (org.cloudfoundry.credhub.credential.SshCredentialValue)6 SshGenerationParameters (org.cloudfoundry.credhub.request.SshGenerationParameters)4 Test (org.junit.Test)3 RSAPublicKey (java.security.interfaces.RSAPublicKey)2 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)2 RsaCredentialValue (org.cloudfoundry.credhub.credential.RsaCredentialValue)2 StringCredentialValue (org.cloudfoundry.credhub.credential.StringCredentialValue)2 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)2 Before (org.junit.Before)2 KeyPair (java.security.KeyPair)1 UserContext (org.cloudfoundry.credhub.auth.UserContext)1 UserCredentialValue (org.cloudfoundry.credhub.credential.UserCredentialValue)1 CertificateGenerationParameters (org.cloudfoundry.credhub.domain.CertificateGenerationParameters)1 AuditingHelper (org.cloudfoundry.credhub.helper.AuditingHelper)1 GenerationParameters (org.cloudfoundry.credhub.request.GenerationParameters)1 RsaGenerationParameters (org.cloudfoundry.credhub.request.RsaGenerationParameters)1 Matchers.anyString (org.mockito.Matchers.anyString)1